Skip to content
Snippets Groups Projects
Commit 6792f885 authored by Jan Gruteser's avatar Jan Gruteser
Browse files

add more tests for reals

parent 8bc7cc10
No related branches found
No related tags found
No related merge requests found
Pipeline #134997 passed
...@@ -83,6 +83,12 @@ public class MCTest { ...@@ -83,6 +83,12 @@ public class MCTest {
runModule(file); runModule(file);
} }
@Test
public void testRealDefinition() throws Exception {
String file = "src/test/resources/MCTests/InvariantReals/RealInvariant.tla";
runModule(file);
}
@Test @Test
public void testMacroTest() throws Exception { public void testMacroTest() throws Exception {
String file = "src/test/resources/renamer/MacroTest/MacroTest.tla"; String file = "src/test/resources/renamer/MacroTest/MacroTest.tla";
......
...@@ -9,15 +9,29 @@ public class ModuleAndExpressionTest { ...@@ -9,15 +9,29 @@ public class ModuleAndExpressionTest {
@Test @Test
public void testCon() throws Exception { public void testCon() throws Exception {
String module = "---- MODULE Testing ----\n" + "CONSTANTS k \n" String module = "---- MODULE Testing ----\n"
+ "ASSUME k = 4" + "==============="; + "CONSTANTS k \n"
+ "ASSUME k = 4"
+ "===============";
compareExprIncludingModel("k = 1", "k = 1", module); compareExprIncludingModel("k = 1", "k = 1", module);
} }
@Test(expected = TypeErrorException.class) @Test(expected = TypeErrorException.class)
public void testTypeError() throws Exception { public void testTypeError() throws Exception {
String module = "---- MODULE Testing ----\n" + "CONSTANTS k \n" String module = "---- MODULE Testing ----\n"
+ "ASSUME k = 4" + "==============="; + "CONSTANTS k \n"
+ "ASSUME k = 4"
+ "===============";
compareExprIncludingModel(null, "k = TRUE", module); compareExprIncludingModel(null, "k = TRUE", module);
} }
@Test
public void testReals() throws Exception {
String module = "---- MODULE Testing ----\n"
+ "EXTENDS Reals\n"
+ "CONSTANTS k, t1, t2 \n"
+ "ASSUME k = 2.0 /\\ t1 = k*k /\\ t2 = (k < 5.0)"
+ "===============";
compareExprIncludingModel("t2 = TRUE", "t2 = TRUE", module);
}
} }
...@@ -66,6 +66,23 @@ public class TestModuleReals { ...@@ -66,6 +66,23 @@ public class TestModuleReals {
TestUtil.typeCheckString(module); TestUtil.typeCheckString(module);
} }
@Test
public void testRelationalOperators() throws
TLA2BException {
final String module = "-------------- MODULE Testing ----------------\n"
+ "EXTENDS Reals \n"
+ "CONSTANTS l, leq, g, geq \n"
+ "ASSUME l = (2.0 < 1.0) /\\ leq = (2.0 <= 1.0) /\\ g = (2.0 > 1.0) /\\ geq = (2.0 >= 1.0)\n"
+ "=================================";
TestTypeChecker t = TestUtil.typeCheckString(module);
assertEquals("BOOL", t.getConstantType("l"));
assertEquals("BOOL", t.getConstantType("leq"));
assertEquals("BOOL", t.getConstantType("g"));
assertEquals("BOOL", t.getConstantType("geq"));
}
@Test(expected = TypeErrorException.class) @Test(expected = TypeErrorException.class)
public void testRelationalOperatorsException1() throws public void testRelationalOperatorsException1() throws
TLA2BException { TLA2BException {
......
INIT
Init
NEXT
Next
INVARIANT
Inv
--------------------------- MODULE RealInvariant ---------------------------
EXTENDS Reals
VARIABLES x,y
Init == x = 1.0 /\ y = 2.0
Next == x' = 2.0 /\ y' = 3.0
TestExpression == x*x + y*y
Inv == TestExpression <= 10.0
============================================================================
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment