Browse Source

Handle case when expected error and receives none

toby 8 years ago
parent
commit
04df7a51d2
2 changed files with 19 additions and 1 deletions
  1. 8 1
      src/js/test/TestRegister.js
  2. 11 0
      src/js/test/tests/core.js

+ 8 - 1
src/js/test/TestRegister.js

@@ -74,7 +74,14 @@
                             ].join("\n");
                         }
                     } else {
-                        if (result.result === test.expectedOutput) {
+                        if (test.expectedError) {
+                            test.status = "failing";
+                            test.output = [
+                                "Failing",
+                                "-------",
+                                "Expected an error but did not receive one.",
+                            ].join("\n");
+                        } else if (result.result === test.expectedOutput) {
                             test.status = "passing";
                         } else {
                             test.status = "failing";

+ 11 - 0
src/js/test/tests/core.js

@@ -21,6 +21,17 @@ TestRegister.addTests([
             },
         ],
     },
+    {
+        name: "Example non-error when error was expected",
+        input: "1",
+        expectedError: true,
+        recipeConfig: [
+            {
+                op: "To Base",
+                args: [16],
+            },
+        ],
+    },
     {
         name: "Example fail",
         input: "1\n2\na\n4",