Browse Source

Trying out the conformance tests engine

The base path needs to be resolved dynamically.
The suite needs to be downloaded before the tests are run.
Sebastien Ros 12 years ago
parent
commit
e4489181ee
3 changed files with 49 additions and 0 deletions
  1. 2 0
      .gitignore
  2. 1 0
      Jint.Tests/Jint.Tests.csproj
  3. 46 0
      Jint.Tests/Test262.cs

+ 2 - 0
.gitignore

@@ -1,6 +1,8 @@
 ## Ignore Visual Studio temporary files, build results, and
 ## files generated by popular Visual Studio add-ons.
 
+Jint.Tests/suite/
+
 # User-specific files
 *.suo
 *.user

+ 1 - 0
Jint.Tests/Jint.Tests.csproj

@@ -48,6 +48,7 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Test262.cs" />
     <Compile Include="Parser\JavascriptParserTests.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Runtime\EngineTests.cs" />

+ 46 - 0
Jint.Tests/Test262.cs

@@ -0,0 +1,46 @@
+using System;
+using System.IO;
+using System.Reflection;
+using Jint.Runtime;
+using Xunit;
+using Xunit.Extensions;
+
+namespace Jint.Tests
+{
+    public class Test262
+    {
+        private string _basePath;
+
+        public Test262()
+        {
+            _basePath = @"C:\Users\sebros\Documents\My Projects\Jint\Jint.Tests\suite\"; // typeof (Test262).Assembly.Location;
+        }
+
+        private void Run(string filename)
+        {
+            var assembly = Assembly.GetExecutingAssembly();
+            var scriptPath = Path.Combine(_basePath, filename);
+            string fileContent = File.ReadAllText(scriptPath);
+            RunTest(fileContent);
+        }
+
+        private Action<string> ERROR = s => { throw new Exception(s); };
+
+        private void RunTest(string source)
+        {
+            var engine = new Engine(cfg => cfg
+                .WithDelegate("$ERROR", ERROR)
+            );
+
+            engine.Execute(source);
+        }
+
+        [Theory]
+        [Trait("Description", "Test for handling of supplementary characters")]
+        [InlineData("ch06/6.1.js")]
+        public void TestForHandlingSupplimentaryCharacters(string file)
+        {
+            Run(file);
+        }
+    }
+}