Skip to content

Commit

Permalink
test z
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Nov 24, 2023
1 parent 8acd55e commit 2b31b13
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Jint.Tests.CommonScripts/Jint.Tests.CommonScripts.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyOriginatorKeyFile>..\Jint\Jint.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
4 changes: 2 additions & 2 deletions Jint.Tests.Test262/Jint.Tests.Test262.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!--<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net461</TargetFrameworks>-->
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<!--<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>-->
<AssemblyOriginatorKeyFile>..\Jint\Jint.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion Jint.Tests/Jint.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
<AssemblyOriginatorKeyFile>..\Jint\Jint.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 1 addition & 1 deletion Jint.Tests/Runtime/EngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ public void TestDateToStringFormat(DateTime testDate)
{
var customTimeZone = _pacificTimeZone;

Assert.Equal("", customTimeZone.ToString());
Assert.Equal("Pacific Standard Time", customTimeZone.StandardName);

Check failure on line 1222 in Jint.Tests/Runtime/EngineTests.cs

View workflow job for this annotation

GitHub Actions / linux

Jint.Tests.Runtime.EngineTests.TestDateToStringFormat(testDate: 1900-06-01T00:15:15.0150000)

Assert.Equal() Failure: Strings differ ↓ (pos 0) Expected: "Pacific Standard Time" Actual: ""

Check failure on line 1222 in Jint.Tests/Runtime/EngineTests.cs

View workflow job for this annotation

GitHub Actions / linux

Jint.Tests.Runtime.EngineTests.TestDateToStringFormat(testDate: 2000-01-01T00:00:00.0000000)

Assert.Equal() Failure: Strings differ ↓ (pos 0) Expected: "Pacific Standard Time" Actual: ""

Check failure on line 1222 in Jint.Tests/Runtime/EngineTests.cs

View workflow job for this annotation

GitHub Actions / linux

Jint.Tests.Runtime.EngineTests.TestDateToStringFormat(testDate: 2000-01-01T00:15:15.0150000)

Assert.Equal() Failure: Strings differ ↓ (pos 0) Expected: "Pacific Standard Time" Actual: ""

Check failure on line 1222 in Jint.Tests/Runtime/EngineTests.cs

View workflow job for this annotation

GitHub Actions / linux

Jint.Tests.Runtime.EngineTests.TestDateToStringFormat(testDate: 1900-01-01T00:15:15.0150000)

Assert.Equal() Failure: Strings differ ↓ (pos 0) Expected: "Pacific Standard Time" Actual: ""

Check failure on line 1222 in Jint.Tests/Runtime/EngineTests.cs

View workflow job for this annotation

GitHub Actions / linux

Jint.Tests.Runtime.EngineTests.TestDateToStringFormat(testDate: 1900-01-01T00:00:00.0000000)

Assert.Equal() Failure: Strings differ ↓ (pos 0) Expected: "Pacific Standard Time" Actual: ""

Check failure on line 1222 in Jint.Tests/Runtime/EngineTests.cs

View workflow job for this annotation

GitHub Actions / linux

Jint.Tests.Runtime.EngineTests.TestDateToStringFormat(testDate: 2000-06-01T00:15:15.0150000)

Assert.Equal() Failure: Strings differ ↓ (pos 0) Expected: "Pacific Standard Time" Actual: ""

var engine = new Engine(ctx => ctx.LocalTimeZone(customTimeZone));
var dt = new DateTimeOffset(testDate, customTimeZone.GetUtcOffset(testDate));
Expand Down
5 changes: 5 additions & 0 deletions Jint/Extensions/Polyfills.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ internal static class Polyfills
internal static bool Contains(this string source, char c) => source.IndexOf(c) != -1;
#endif

#if NETFRAMEWORK
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool Contains(this ReadOnlySpan<string> source, string c) => source.IndexOf(c) != -1;
#endif

#if NETFRAMEWORK || NETSTANDARD2_0
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool StartsWith(this string source, char c) => source.Length > 0 && source[0] == c;
Expand Down
23 changes: 15 additions & 8 deletions Jint/Extensions/SearchValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,33 @@ internal static class SearchValues

internal sealed class SearchValues<T>
{
private readonly char[] _data;
private readonly bool[] _data;
private readonly char _min;
private readonly char _max;

internal SearchValues(string input)
{
_data = new char[input.Length];
for (var i = 0; i < input.Length; i++)
_min = char.MaxValue;
_max = char.MinValue;
foreach (var c in input)
{
var c = input[i];
_data[i] = c;
_min = (char) Math.Min(_min, c);
_max = (char) Math.Max(_max, c);
}

_data = input.ToCharArray();
Array.Sort(_data);
_data = new bool[_max - _min + 1];
foreach (var c in input)
{
_data[c - _min] = true;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(char c) => c >= _min && c <= _max && Array.BinarySearch(_data, c) > -1;
public bool Contains(char c)
{
var i = (uint) (c - _min);
var temp = _data;
return i < temp.Length && temp[i];
}
}
#endif
2 changes: 1 addition & 1 deletion Jint/Jint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'netstandard2.1' ">
<PropertyGroup Condition=" '$(TargetFramework)' != 'net462' and '$(TargetFramework)' != 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_PARSE;SUPPORTS_WEAK_TABLE_ADD_OR_UPDATE;SUPPORTS_WEAK_TABLE_CLEAR</DefineConstants>
</PropertyGroup>

Expand Down

0 comments on commit 2b31b13

Please sign in to comment.