SingleTest.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Linq;
  5. using Xunit;
  6. namespace Jint.Tests.Test262
  7. {
  8. public class RunnableInDebugOnlyAttribute : FactAttribute
  9. {
  10. public RunnableInDebugOnlyAttribute()
  11. {
  12. if (!Debugger.IsAttached)
  13. {
  14. Skip = "Only running in interactive mode.";
  15. }
  16. }
  17. }
  18. public class SingleTest : Test262Test
  19. {
  20. // helper to test single test case
  21. [RunnableInDebugOnly]
  22. public void TestSingle()
  23. {
  24. const string Target = @"built-ins/Math/pow/applying-the-exp-operator_A19.js";
  25. //const string Target = @"built-ins/Array/from/calling-from-valid-2.js";
  26. var sourceFile = SourceFiles("built-ins", false)
  27. .SelectMany(x => x)
  28. .Cast<SourceFile>()
  29. .First(x => x.Source == Target);
  30. var code = File.ReadAllText(sourceFile.FullPath);
  31. if (code.IndexOf("onlyStrict", StringComparison.Ordinal) < 0)
  32. {
  33. RunTestCode(code, strict: false);
  34. }
  35. if (code.IndexOf("noStrict", StringComparison.Ordinal) < 0)
  36. {
  37. RunTestCode(code, strict: true);
  38. }
  39. }
  40. }
  41. }