Vladislav Folts 12 ani în urmă
părinte
comite
7f320f5e18
2 a modificat fișierele cu 12 adăugiri și 3 ștergeri
  1. 2 1
      src/module.js
  2. 10 2
      test/test_unit.js

+ 2 - 1
src/module.js

@@ -33,7 +33,8 @@ var doProcSymbol = (function(){
             var type = e.type();
             if (!(type instanceof Type.String))
                 throw new Errors.Error(
-                    "string is expected as an argument of " + description);
+                    "string is expected as an argument of " + description
+                    + ", got " + type.description());
             
             this.__code = type.value();
             return Procedure.CallGenerator.prototype.checkArgument.call(this, pos, e);

+ 10 - 2
test/test_unit.js

@@ -1160,8 +1160,16 @@ var testSuite = {
     Grammar.module,
     pass("MODULE m; IMPORT JS; END m.",
          "MODULE m; IMPORT JS; BEGIN JS.alert(\"test\") END m.",
-         "MODULE m; IMPORT JS; BEGIN JS.console.info(123) END m."
-         )
+         "MODULE m; IMPORT JS; BEGIN JS.console.info(123) END m.",
+         "MODULE m; IMPORT JS; BEGIN JS.do(\"throw new Error()\") END m."
+         ),
+    fail(["MODULE m; IMPORT JS; BEGIN JS.do(123) END m.",
+          "string is expected as an argument of JS predefined procedure 'do', got INTEGER"],
+         ["MODULE m; IMPORT JS; BEGIN JS.do(\"a\", \"b\") END m.",
+          "1 argument(s) expected, got 2"],
+         ["MODULE m; IMPORT JS; VAR s: ARRAY 10 OF CHAR; BEGIN JS.do(s) END m.",
+          "string is expected as an argument of JS predefined procedure 'do', got ARRAY OF CHAR"]
+          )
     ),
 "import unknown module": testWithGrammar(
     Grammar.module,