[433103] Test 2-valued Booleans, fix broken testLoadAsString
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateBooleanOperationsTest4.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateBooleanOperationsTest4.java
index 6f2ea96..fff2a67 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateBooleanOperationsTest4.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateBooleanOperationsTest4.java
@@ -78,6 +78,8 @@
@Test public void testBooleanAnd() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryFalse(null, "false and false");
ocl.assertQueryFalse(null, "false and true");
ocl.assertQueryFalse(null, "true and false");
@@ -99,23 +101,37 @@
ocl.assertQueryNull(null, "let a : Boolean = null, b : Boolean = null in a and b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = null in a and b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in Sequence{true}->at(0) and b");
+ //
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self = null in a and b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a and b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a and b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a and b");
+ //
+ ocl.assertQueryInvalid(null, "let a : Boolean = null in a and Sequence{true}->at(0) and a");
ocl.dispose();
}
@Test public void testBooleanAnd2() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryFalse(null, "false and2 false");
ocl.assertQueryFalse(null, "false and2 true");
ocl.assertQueryFalse(null, "true and2 false");
ocl.assertQueryTrue(null, "true and2 true");
// invalid
- ocl.assertQueryFalse(null, "let b : Boolean = invalid in false and2 b");
+ if (PivotTestSuite.useCodeGen) {
+ ocl.assertQueryInvalid(null, "let b : Boolean = invalid in false and2 b");
+ }
+ else { // FIXME Bug 552782, need static isInvalid analysis
+ ocl.assertQueryFalse(null, "let b : Boolean = invalid in false and2 b");
+ }
ocl.assertQueryInvalid(null, "let b : Boolean = invalid in true and2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in a and2 false");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in a and2 true");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = invalid in a and2 b");
// null
- ocl.assertQueryFalse(null, "let b : Boolean = null in false and2 b");
+ ocl.assertQueryInvalid(null, "let b : Boolean = null in false and2 b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in true and2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = null in a and2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = invalid in a and2 b");
@@ -125,6 +141,11 @@
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = null in a and2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = null in a and2 b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in Sequence{true}->at(0) and2 b");
+ //
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self = null in a and2 b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a and2 b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a and2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a and2 b");
ocl.dispose();
}
@@ -149,6 +170,8 @@
@Test public void testBooleanImplies() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryTrue(null, "false implies false");
ocl.assertQueryTrue(null, "false implies true");
ocl.assertQueryFalse(null, "true implies false");
@@ -169,23 +192,35 @@
ocl.assertQueryNull(null, "let a : Boolean = null, b : Boolean = null in a implies b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = null in a implies b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in Sequence{true}->at(0) implies b");
+ //
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self = null in a implies b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a implies b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a implies b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a implies b");
ocl.dispose();
}
@Test public void testBooleanImplies2() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryTrue(null, "false implies2 false");
ocl.assertQueryTrue(null, "false implies2 true");
ocl.assertQueryFalse(null, "true implies2 false");
ocl.assertQueryTrue(null, "true implies2 true");
// invalid
- ocl.assertQueryTrue(null, "let b : Boolean = invalid in false implies2 b");
+ if (PivotTestSuite.useCodeGen) {
+ ocl.assertQueryInvalid(null, "let b : Boolean = invalid in false implies2 b");
+ }
+ else { // FIXME Bug 552782, need static isInvalid analysis
+ ocl.assertQueryTrue(null, "let b : Boolean = invalid in false implies2 b");
+ }
ocl.assertQueryInvalid(null, "let b : Boolean = invalid in true implies2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in a implies2 false");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in a implies2 true");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = invalid in a implies2 b");
// null
- ocl.assertQueryTrue(null, "let b : Boolean = null in false implies2 b");
+ ocl.assertQueryInvalid(null, "let b : Boolean = null in false implies2 b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in true implies2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = invalid in a implies2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null in a implies2 Sequence{true}->at(0)");
@@ -194,28 +229,43 @@
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = null in a implies2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = null in a implies2 b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in Sequence{true}->at(0) implies2 b");
+ //
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self = null in a implies2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a implies2 b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a implies2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a implies2 b");
ocl.dispose();
}
@Test public void testBooleanNot() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryTrue(null, "not false");
ocl.assertQueryFalse(null, "not true");
// invalid
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in not a");
// null
ocl.assertQueryNull(null, "let a : Boolean = null in not a");
+ //
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null in not a");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null in not a");
ocl.dispose();
}
@Test public void testBooleanNot2() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryTrue(null, "not2 false");
ocl.assertQueryFalse(null, "not2 true");
// invalid
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in not2 a");
// null
ocl.assertQueryInvalid(null, "let a : Boolean = null in not2 a");
+ //
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null in not2 a");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null in not2 a");
ocl.dispose();
}
@@ -240,6 +290,8 @@
@Test public void testBooleanOr() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryFalse(null, "false or false");
ocl.assertQueryTrue(null, "false or true");
ocl.assertQueryTrue(null, "true or false");
@@ -261,24 +313,36 @@
ocl.assertQueryNull(null, "let a : Boolean = null, b : Boolean = null in a or b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = null in a or b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in Sequence{true}->at(0) or b");
+ //
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self = null in a or b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a or b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a or b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a or b");
ocl.dispose();
}
@Test public void testBooleanOr2() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryFalse(null, "false or2 false");
ocl.assertQueryTrue(null, "false or2 true");
ocl.assertQueryTrue(null, "true or2 false");
ocl.assertQueryTrue(null, "true or2 true");
// invalid
ocl.assertQueryInvalid(null, "let b : Boolean = invalid in false or2 b");
- ocl.assertQueryTrue(null, "let b : Boolean = invalid in true or2 b");
+ if (PivotTestSuite.useCodeGen) {
+ ocl.assertQueryInvalid(null, "let b : Boolean = invalid in true or2 b");
+ }
+ else { // FIXME Bug 552782, need static isInvalid analysis
+ ocl.assertQueryTrue(null, "let b : Boolean = invalid in true or2 b");
+ }
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in a or2 false");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid in a or2 true");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = invalid in a or2 b");
// null
ocl.assertQueryInvalid(null, "let b : Boolean = null in false or2 b");
- ocl.assertQueryTrue(null, "let b : Boolean = null in true or2 b");
+ ocl.assertQueryInvalid(null, "let b : Boolean = null in true or2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = null in a or2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = invalid in a or2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null in a or2 Sequence{true}->at(0)");
@@ -287,6 +351,11 @@
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = null in a or2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = invalid, b : Boolean = null in a or2 b");
ocl.assertQueryInvalid(null, "let b : Boolean = null in Sequence{true}->at(0) or2 b");
+ //
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self = null in a or2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a or2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a or2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a or2 b");
ocl.dispose();
}
@@ -300,6 +369,8 @@
@Test public void testBooleanXor() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryFalse(null, "false xor false");
ocl.assertQueryTrue(null, "false xor true");
ocl.assertQueryTrue(null, "true xor false");
@@ -320,11 +391,18 @@
ocl.assertQueryNull(null, "let b : Boolean = null in true xor b");
ocl.assertQueryNull(null, "let a : Boolean = null in a xor true");
ocl.assertQueryNull(null, "let a : Boolean = null, b : Boolean = null in a xor b");
+ //
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self = null in a xor b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a xor b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a xor b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a xor b");
ocl.dispose();
}
@Test public void testBooleanXor2() {
TestOCL ocl = createOCL();
+ org.eclipse.ocl.pivot.Class classType = ocl.getStandardLibrary().getClassType();
+ //
ocl.assertQueryFalse(null, "false xor2 false");
ocl.assertQueryTrue(null, "false xor2 true");
ocl.assertQueryTrue(null, "true xor2 false");
@@ -345,6 +423,11 @@
ocl.assertQueryInvalid(null, "let b : Boolean = null in true xor2 b");
ocl.assertQueryInvalid(null, "let a : Boolean = null in a xor2 true");
ocl.assertQueryInvalid(null, "let a : Boolean = null, b : Boolean = null in a xor2 b");
+ //
+ ocl.assertQueryFalse(classType, "let a : Boolean = self = null, b : Boolean = self = null in a xor2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self = null, b : Boolean = self <> null in a xor2 b");
+ ocl.assertQueryTrue(classType, "let a : Boolean = self <> null, b : Boolean = self = null in a xor2 b");
+ ocl.assertQueryFalse(classType, "let a : Boolean = self <> null, b : Boolean = self <> null in a xor2 b");
ocl.dispose();
}
}
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/OCLstdlibTests.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/OCLstdlibTests.java
index 5751546..a906b09 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/OCLstdlibTests.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/OCLstdlibTests.java
@@ -223,6 +223,7 @@
" type OclEnumeration conformsTo OclAny {}\n"+
" type OclInvalid : InvalidType {}\n"+
" type OclSelf : SelfType conformsTo OclAny {}\n"+
+ " type OclVoid : VoidType {}\n"+
" type OrderedCollection(T) : CollectionType conformsTo Collection(T) {}\n"+
" type OrderedSet(T) : OrderedSetType conformsTo Collection(T) {}\n"+
" type Real : PrimitiveType conformsTo OclComparable {}\n"+