Browse Source

JSON parser should handle negative number 2

Updated unit tests according to Sebatiean Ros demand
Frederic Torres 11 years ago
parent
commit
ca12781d4c
1 changed files with 6 additions and 6 deletions
  1. 6 6
      Jint.Tests/Runtime/EngineTests.cs

+ 6 - 6
Jint.Tests/Runtime/EngineTests.cs

@@ -716,29 +716,29 @@ namespace Jint.Tests.Runtime
                 function f() {
                     try {
                         JSON.parse('{ ""x"": -.1 }'); // Not allowed
+                        return false;
                     }
                     catch(ex) {
-                        return ex.toString();
+                        return ex.toString().indexOf('Unexpected token') !== -1;
                     }
                 }
                 f();
             ";
-            var resultS = engine.Execute(code).GetCompletionValue().AsString();
-            Assert.True(resultS.Contains("Unexpected token"));
+            Assert.True(engine.Execute(code).GetCompletionValue().AsBoolean());
 
             code = @"
                 function f() {
                     try {
                         JSON.parse('{ ""x"": - 1 }'); // Not allowed
+                        return false;
                     }
                     catch(ex) {
-                        return ex.toString();
+                        return ex.toString().indexOf('Unexpected token') !== -1;
                     }
                 }
                 f();
             ";
-            resultS = engine.Execute(code).GetCompletionValue().AsString();
-            Assert.True(resultS.Contains("Unexpected token"));
+            Assert.True(engine.Execute(code).GetCompletionValue().AsBoolean());
         }
 
         [Fact]