TestHarness.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.IO;
  3. using System.Threading.Tasks;
  4. using Esprima;
  5. namespace Jint.Tests.Test262;
  6. /// <summary>
  7. /// Handles initializing testing state.
  8. /// </summary>
  9. public partial class TestHarness
  10. {
  11. private static partial Task InitializeCustomState()
  12. {
  13. // NOTE: The Date tests in test262 assume the local timezone is Pacific Standard Time
  14. try
  15. {
  16. State.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
  17. }
  18. catch (TimeZoneNotFoundException)
  19. {
  20. // https://stackoverflow.com/questions/47848111/how-should-i-fetch-timezoneinfo-in-a-platform-agnostic-way
  21. // should be natively supported soon https://github.com/dotnet/runtime/issues/18644
  22. State.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
  23. }
  24. foreach (var file in State.HarnessFiles)
  25. {
  26. var source = file.Program;
  27. State.Sources[Path.GetFileName(file.FileName)] = new JavaScriptParser(source, new ParserOptions(file.FileName)).ParseScript();
  28. }
  29. return Task.CompletedTask;
  30. }
  31. }