Vladislav Folts 11 سال پیش
والد
کامیت
05742b6b30
1فایلهای تغییر یافته به همراه12 افزوده شده و 4 حذف شده
  1. 12 4
      test/test_unit_eberon.js

+ 12 - 4
test/test_unit_eberon.js

@@ -450,7 +450,6 @@ exports.suite = {
              "ORD(b IS PDerived) * ORD(b.flag) = 0",
              "ORD(b IS PDerived) * ORD(b.flag) = 0",
              "((b IS PDerived) = FALSE) & b.flag",
              "((b IS PDerived) = FALSE) & b.flag",
              "b IS PDerived); ASSERT(b.flag"
              "b IS PDerived); ASSERT(b.flag"
-             // TODO: move to statements test "bVar := b IS PDerived; ASSERT(b.flag)",
              )
              )
         ),
         ),
     "invert type promotion in expression": testWithContext(
     "invert type promotion in expression": testWithContext(
@@ -474,6 +473,11 @@ exports.suite = {
              "~(b IS PDerived) OR b.flag = b.flag"
              "~(b IS PDerived) OR b.flag = b.flag"
             )
             )
         ),
         ),
+    "type promotion in separate statements": testWithContext(
+        temporaryValues.context,
+        pass(),
+        temporaryValues.failStatements("bVar := b IS PDerived; ASSERT(b.flag)")
+        ),
     "type promotion in IF": testWithContext(
     "type promotion in IF": testWithContext(
         temporaryValues.context,
         temporaryValues.context,
         temporaryValues.passStatements(
         temporaryValues.passStatements(
@@ -491,9 +495,6 @@ exports.suite = {
             "IF bVar THEN ELSIF b IS PDerived THEN ELSE END; b.flag := FALSE",
             "IF bVar THEN ELSIF b IS PDerived THEN ELSE END; b.flag := FALSE",
             "IF b IS PDerived THEN ELSE b.flag := FALSE; END",
             "IF b IS PDerived THEN ELSE b.flag := FALSE; END",
             "IF b IS PDerived THEN ELSIF TRUE THEN b.flag := FALSE; END"
             "IF b IS PDerived THEN ELSIF TRUE THEN b.flag := FALSE; END"
-             //TODO: separate test
-             //["PROCEDURE p(); BEGIN b <- pBase; IF b IS PDerived THEN bVar := b IS PDerived; b.flag := FALSE; END; END p;",
-             // "invalid type test: 'Derived' is not an extension of 'Derived'"]
              )
              )
         ),
         ),
     "invert type promotion in IF": testWithContext(
     "invert type promotion in IF": testWithContext(
@@ -539,6 +540,13 @@ exports.suite = {
               "type mismatch for argument 1: cannot pass 'PDerived' as VAR parameter of type 'PBase'"]
               "type mismatch for argument 1: cannot pass 'PDerived' as VAR parameter of type 'PBase'"]
             )
             )
         ),
         ),
+    "IS expression after type promotion": testWithContext(
+        temporaryValues.context,
+        pass(),
+        fail(["PROCEDURE p(); BEGIN b <- pBase; IF b IS PDerived THEN bVar := b IS PDerived; b.flag := FALSE; END; END p;",
+              "invalid type test: 'Derived' is not an extension of 'Derived'"]
+            )
+        ),
     "as references": testWithContext(
     "as references": testWithContext(
           context(grammar.declarationSequence,
           context(grammar.declarationSequence,
                 "TYPE Base = RECORD pBase: POINTER TO Base END; Derived = RECORD (Base) END;"
                 "TYPE Base = RECORD pBase: POINTER TO Base END; Derived = RECORD (Base) END;"