Browse Source

Implementing javascript test driver

Sebastien Ros 12 years ago
parent
commit
b9d28c56e5
1 changed files with 14 additions and 2 deletions
  1. 14 2
      Jint.Tests.Ecma/EcmaTest.cs

+ 14 - 2
Jint.Tests.Ecma/EcmaTest.cs

@@ -20,6 +20,18 @@ namespace Jint.Tests
 
         }
 
+        private const string Driver = @"
+            function runTestCase(f) {
+                assert(f());
+            }
+        ";
+
+        private const string NegativeDriver = @"
+            function runTestCase(f) {
+                assert(!f());
+            }
+        ";
+
         protected void RunTest(string sourceFilename, bool negative)
         {
             _lastError = null;
@@ -39,7 +51,7 @@ namespace Jint.Tests
             {
                 try
                 {
-                    engine.Execute(code);
+                    engine.Execute(code + Environment.NewLine + NegativeDriver);
                     Assert.NotNull(_lastError);
                     Assert.False(true);
                 }
@@ -51,7 +63,7 @@ namespace Jint.Tests
             }
             else
             {
-                Assert.DoesNotThrow(() => engine.Execute(code));
+                Assert.DoesNotThrow(() => engine.Execute(code + Environment.NewLine + Driver));
                 Assert.Null(_lastError);
             }
         }