diff --git a/test/org/rascalmpl/MatchFingerprintTest.java b/test/org/rascalmpl/MatchFingerprintTest.java index 16781a03f93..abe33556702 100644 --- a/test/org/rascalmpl/MatchFingerprintTest.java +++ b/test/org/rascalmpl/MatchFingerprintTest.java @@ -20,6 +20,7 @@ import org.rascalmpl.interpreter.env.ModuleEnvironment; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IInteger; +import io.usethesource.vallang.ISourceLocation; import io.usethesource.vallang.exceptions.FactTypeUseException; import io.usethesource.vallang.io.StandardTextReader; import io.usethesource.vallang.type.Type; @@ -60,6 +61,7 @@ public void testFunctionFingerPrintStability() { public void testTreeApplFingerPrintStability() { String prodString = "prod(sort(\"E\"),[],{})"; + ISourceLocation loc = VF.sourceLocation("BLABLA"); try { IConstructor prod = (IConstructor) new StandardTextReader().read(VF, RascalFunctionValueFactory.getStore(), RascalFunctionValueFactory.Production, new StringReader(prodString)); @@ -67,6 +69,12 @@ public void testTreeApplFingerPrintStability() { assertEquals(tree.getMatchFingerprint(), "appl".hashCode() + 131 * 2); assertEquals(tree.getConcreteMatchFingerprint(), "tree".hashCode() + 41 * prod.hashCode()); + + // and now WITH a keyword parameter + tree = (ITree) tree.asWithKeywordParameters().setParameter("src", loc); + + assertEquals(tree.getMatchFingerprint(), "appl".hashCode() + 131 * 2); + assertEquals(tree.getConcreteMatchFingerprint(), "tree".hashCode() + 41 * prod.hashCode()); } catch (FactTypeUseException | IOException e) { fail(e.getMessage()); @@ -76,6 +84,7 @@ public void testTreeApplFingerPrintStability() { public void testTreeAmbFingerPrintStability() { String prodString1 = "prod(sort(\"E\"),[],{})"; String prodString2 = "prod(sort(\"E\"),[empty()],{})"; + ISourceLocation loc = VF.sourceLocation("BLABLA"); try { IConstructor prod1= (IConstructor) new StandardTextReader().read(VF, RascalFunctionValueFactory.getStore(), RascalFunctionValueFactory.Production, new StringReader(prodString1)); @@ -87,6 +96,12 @@ public void testTreeAmbFingerPrintStability() { assertEquals(amb.getMatchFingerprint(), "amb".hashCode() + 131); assertEquals(amb.getConcreteMatchFingerprint(), "amb".hashCode() + 43 * TreeAdapter.getType(amb).hashCode()); + + // and now WITH a keyword parameter + amb = (ITree) amb.asWithKeywordParameters().setParameter("src", loc); + + assertEquals(amb.getMatchFingerprint(), "amb".hashCode() + 131); + assertEquals(amb.getConcreteMatchFingerprint(), "amb".hashCode() + 43 * TreeAdapter.getType(amb).hashCode()); } catch (FactTypeUseException | IOException e) { fail(e.getMessage()); @@ -94,11 +109,19 @@ public void testTreeAmbFingerPrintStability() { } public void testTreeCharFingerPrintStability() { + ISourceLocation loc = VF.sourceLocation("BLABLA"); + try { ITree theChar = (ITree) new StandardTextReader().read(VF, RascalFunctionValueFactory.getStore(), RascalFunctionValueFactory.Tree, new StringReader("char(32)")); assertEquals(theChar.getMatchFingerprint(), "char".hashCode() + 131); assertEquals(theChar.getConcreteMatchFingerprint(), "char".hashCode() + ((IInteger) theChar.get(0)).intValue()); + + // and now WITH a keyword parameter + theChar = (ITree) theChar.asWithKeywordParameters().setParameter("src", loc); + + assertEquals(theChar.getMatchFingerprint(), "char".hashCode() + 131); + assertEquals(theChar.getConcreteMatchFingerprint(), "char".hashCode() + ((IInteger) theChar.get(0)).intValue()); } catch (FactTypeUseException | IOException e) { fail(e.getMessage()); @@ -106,11 +129,19 @@ public void testTreeCharFingerPrintStability() { } public void testTreeCycleFingerPrintStability() { + ISourceLocation loc = VF.sourceLocation("BLABLA"); + try { ITree theCycle = (ITree) new StandardTextReader().read(VF, RascalFunctionValueFactory.getStore(), RascalFunctionValueFactory.Tree, new StringReader("cycle(sort(\"A\"), 3)")); assertEquals(theCycle.getMatchFingerprint(), "cycle".hashCode() + 2 * 131); assertEquals(theCycle.getConcreteMatchFingerprint(), "cycle".hashCode() + 13 * theCycle.get(0).hashCode()); + + // and now WITH a keyword parameter + theCycle = (ITree) theCycle.asWithKeywordParameters().setParameter("src", loc); + + assertEquals(theCycle.getMatchFingerprint(), "cycle".hashCode() + 2 * 131); + assertEquals(theCycle.getConcreteMatchFingerprint(), "cycle".hashCode() + 13 * theCycle.get(0).hashCode()); } catch (FactTypeUseException | IOException e) { fail(e.getMessage());