Skip to content
Snippets Groups Projects
Commit 9e914d6d authored by hansen's avatar hansen
Browse files

improved function detection

parent 75c5ddac
No related branches found
No related tags found
No related merge requests found
......@@ -1225,6 +1225,9 @@ public class Typechecker extends DepthFirstAdapter implements ITypechecker {
}
private boolean compareElementsOfList(ArrayList<Node> list) {
if(list.size() == 1){
return true;
}
try {
if (list.get(0) instanceof AIntegerExpression) {
HashSet<Integer> set = new HashSet<Integer>();
......
......@@ -62,8 +62,8 @@ public class FunctionTest {
+ "PROPERTIES {(1|->2|->3)} = %a,b.(a = b | a+b)\n"
+ "END";
String expected = "---- MODULE test ----\n"
+ "EXTENDS Integers\n"
+ "ASSUME {<<<<1, 2>>,3>>} = {<<<<a, b>>, a + b>> : <<a, b>> \\in { <<a, b>> \\in ((Int) \\times (Int)) : a = b}}\n"
+ "EXTENDS Integers, TLC\n"
+ "ASSUME (<<1, 2>>:>3) = [<<a, b>> \\in {<<a, b>> \\in ((Int) \\times (Int)) : a = b} |-> a + b] \n"
+ "====";
compare(expected, machine);
}
......
......@@ -22,6 +22,17 @@ public class FunctionTest {
assertEquals("FUNC(INTEGER,INTEGER)", t.constants.get("k").toString());
}
@Test
public void testOverride() throws BException {
String machine = "MACHINE test\n"
+ "CONSTANTS k,k2,p \n"
+ "PROPERTIES p = 1 & k = %x.(x : {1} | 1) & k2 = k <+ {1|->2}\n"
+ "END";
TestTypechecker t = new TestTypechecker(machine);
assertEquals("FUNC(INTEGER,INTEGER)", t.constants.get("k").toString());
assertEquals("FUNC(INTEGER,INTEGER)", t.constants.get("k2").toString());
}
@Test
public void testSetOperatorOnFunction() throws BException {
......
......@@ -85,7 +85,7 @@ public class RelationsTest {
+ "PROPERTIES k = {1} <| {(k2, TRUE)} \n"
+ "END";
TestTypechecker t = new TestTypechecker(machine);
assertEquals("POW(INTEGER*BOOL)", t.constants.get("k").toString());
assertEquals("FUNC(INTEGER,BOOL)", t.constants.get("k").toString());
assertEquals("INTEGER", t.constants.get("k2").toString());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment