|
@@ -1,10 +1,8 @@
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.IO;
|
|
-using System.Linq;
|
|
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
using Jint.Runtime;
|
|
using Jint.Runtime;
|
|
-using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
using Xunit;
|
|
using Xunit;
|
|
|
|
|
|
@@ -13,6 +11,7 @@ namespace Jint.Tests.Ecma
|
|
public class EcmaTest
|
|
public class EcmaTest
|
|
{
|
|
{
|
|
private static string _lastError;
|
|
private static string _lastError;
|
|
|
|
+ private static string staSource;
|
|
protected Action<string> Error = s => { _lastError = s; };
|
|
protected Action<string> Error = s => { _lastError = s; };
|
|
protected string BasePath;
|
|
protected string BasePath;
|
|
|
|
|
|
@@ -21,11 +20,7 @@ namespace Jint.Tests.Ecma
|
|
var assemblyPath = new Uri(typeof(EcmaTest).GetTypeInfo().Assembly.CodeBase).LocalPath;
|
|
var assemblyPath = new Uri(typeof(EcmaTest).GetTypeInfo().Assembly.CodeBase).LocalPath;
|
|
var assemblyDirectory = new FileInfo(assemblyPath).Directory;
|
|
var assemblyDirectory = new FileInfo(assemblyPath).Directory;
|
|
|
|
|
|
-#if NET451
|
|
|
|
- BasePath = assemblyDirectory.Parent.Parent.Parent.Parent.FullName;
|
|
|
|
-#else
|
|
|
|
BasePath = assemblyDirectory.Parent.Parent.Parent.FullName;
|
|
BasePath = assemblyDirectory.Parent.Parent.Parent.FullName;
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
protected void RunTestCode(string code, bool negative)
|
|
protected void RunTestCode(string code, bool negative)
|
|
@@ -37,9 +32,13 @@ namespace Jint.Tests.Ecma
|
|
var engine = new Engine(cfg => cfg.LocalTimeZone(pacificTimeZone));
|
|
var engine = new Engine(cfg => cfg.LocalTimeZone(pacificTimeZone));
|
|
|
|
|
|
// loading driver
|
|
// loading driver
|
|
|
|
+ if (staSource == null)
|
|
|
|
+ {
|
|
|
|
+ var driverFilename = Path.Combine(BasePath, "TestCases\\sta.js");
|
|
|
|
+ staSource = File.ReadAllText(driverFilename);
|
|
|
|
+ }
|
|
|
|
|
|
- var driverFilename = Path.Combine(BasePath, "TestCases\\sta.js");
|
|
|
|
- engine.Execute(File.ReadAllText(driverFilename));
|
|
|
|
|
|
+ engine.Execute(staSource);
|
|
|
|
|
|
if (negative)
|
|
if (negative)
|
|
{
|
|
{
|
|
@@ -77,9 +76,9 @@ namespace Jint.Tests.Ecma
|
|
[Theory(DisplayName = "Ecma")]
|
|
[Theory(DisplayName = "Ecma")]
|
|
[MemberData(nameof(SourceFiles), false)]
|
|
[MemberData(nameof(SourceFiles), false)]
|
|
[MemberData(nameof(SourceFiles), true, Skip = "Skipped")]
|
|
[MemberData(nameof(SourceFiles), true, Skip = "Skipped")]
|
|
- protected void RunTest(string test)
|
|
|
|
|
|
+ protected void RunTest(string localPath, SourceFile sourceFile)
|
|
{
|
|
{
|
|
- var fullName = Path.Combine(BasePath, test);
|
|
|
|
|
|
+ var fullName = Path.Combine(BasePath, localPath, sourceFile.Source);
|
|
if (!File.Exists(fullName))
|
|
if (!File.Exists(fullName))
|
|
{
|
|
{
|
|
throw new ArgumentException("Could not find source file: " + fullName);
|
|
throw new ArgumentException("Could not find source file: " + fullName);
|
|
@@ -97,20 +96,24 @@ namespace Jint.Tests.Ecma
|
|
var assemblyPath = new Uri(typeof(EcmaTest).GetTypeInfo().Assembly.CodeBase).LocalPath;
|
|
var assemblyPath = new Uri(typeof(EcmaTest).GetTypeInfo().Assembly.CodeBase).LocalPath;
|
|
var assemblyDirectory = new FileInfo(assemblyPath).Directory;
|
|
var assemblyDirectory = new FileInfo(assemblyPath).Directory;
|
|
|
|
|
|
- var root = assemblyDirectory.Parent.Parent.Parent.FullName;
|
|
|
|
|
|
+ var localPath = assemblyDirectory.Parent.Parent.Parent.FullName;
|
|
|
|
|
|
- var fixturesPath = Path.Combine(root, @"TestCases\alltests.json");
|
|
|
|
|
|
+ var fixturesPath = Path.Combine(localPath, @"TestCases\alltests.json");
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var content = File.ReadAllText(fixturesPath);
|
|
var content = File.ReadAllText(fixturesPath);
|
|
var doc = JArray.Parse(content);
|
|
var doc = JArray.Parse(content);
|
|
var results = new List<object[]>();
|
|
var results = new List<object[]>();
|
|
|
|
+ var path = Path.Combine(localPath, "TestCases");
|
|
|
|
+
|
|
foreach(JObject entry in doc)
|
|
foreach(JObject entry in doc)
|
|
{
|
|
{
|
|
- if (skipped == entry["skip"].Value<bool>())
|
|
|
|
|
|
+ var sourceFile = new SourceFile(entry);
|
|
|
|
+
|
|
|
|
+ if (skipped == sourceFile.Skip)
|
|
{
|
|
{
|
|
- results.Add(new object[] { Path.Combine(root, "TestCases", entry["source"].ToString()) });
|
|
|
|
|
|
+ results.Add(new object [] { path, sourceFile });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -119,8 +122,27 @@ namespace Jint.Tests.Ecma
|
|
catch
|
|
catch
|
|
{
|
|
{
|
|
throw;
|
|
throw;
|
|
- //return Enumerable.Empty<object[]>();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public class SourceFile
|
|
|
|
+ {
|
|
|
|
+ public SourceFile(JObject node)
|
|
|
|
+ {
|
|
|
|
+ Skip = node["skip"].Value<bool>();
|
|
|
|
+ Source = node["source"].ToString();
|
|
|
|
+ Reason = node["reason"].ToString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public string Source { get; set; }
|
|
|
|
+ public bool Skip { get; set; }
|
|
|
|
+ public string Reason { get; set; }
|
|
|
|
+
|
|
|
|
+ public override string ToString()
|
|
|
|
+ {
|
|
|
|
+ return Source;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|