Skip to content

Commit

Permalink
Merge branch 'sebastienros:main' into SourceText
Browse files Browse the repository at this point in the history
  • Loading branch information
scgm0 authored Feb 2, 2024
2 parents 69b73c9 + ac2b527 commit bdd5cae
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: dotnet test --configuration Release --logger GitHubActions

macos:
runs-on: macos-latest
runs-on: macos-14
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Dynamic;
using Jint.Native;
using Jint.Native.Symbol;
using Jint.Tests.Runtime.Domain;

namespace Jint.Tests.Runtime
namespace Jint.Tests.PublicInterface
{
public partial class InteropTests
{
Expand Down Expand Up @@ -143,5 +142,11 @@ public bool ContainsKey(string key)
return _properties.ContainsKey(key);
}
}

private class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Dynamic;
using Jint.Runtime.Interop;

namespace Jint.Tests.Runtime;
namespace Jint.Tests.PublicInterface;

public partial class InteropTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Jint.Runtime;
using Newtonsoft.Json.Linq;

namespace Jint.Tests.Runtime
namespace Jint.Tests.PublicInterface
{
public partial class InteropTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Text.Json.Nodes;
using Jint.Runtime.Interop;

namespace Jint.Tests.Runtime;
namespace Jint.Tests.PublicInterface;

public partial class InteropTests
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public void AccessingJsonNodeShouldWork()
var wrapped = new ObjectWrapper(e, target);
if (target is JsonArray)
{
wrapped.SetPrototypeOf(e.Realm.Intrinsics.Array.PrototypeObject);
wrapped.Prototype = e.Intrinsics.Array.PrototypeObject;
}
return wrapped;
};
Expand Down
24 changes: 24 additions & 0 deletions Jint.Tests.PublicInterface/InteropTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Reflection;

namespace Jint.Tests.PublicInterface
{
public partial class InteropTests : IDisposable
{
private readonly Engine _engine;

public InteropTests()
{
_engine = new Engine(cfg => cfg.AllowClr(
typeof(Console).GetTypeInfo().Assembly,
typeof(File).GetTypeInfo().Assembly))
.SetValue("log", new Action<object>(Console.WriteLine))
.SetValue("assert", new Action<bool>(Assert.True))
.SetValue("equal", new Action<object, object>(Assert.Equal))
;
}

void IDisposable.Dispose()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NodaTime" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions Jint.Tests/Runtime/JsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public void CanParseTabsInProperties()
[InlineData("{\"a\":\"\\u0000\"}", "\0")]
[InlineData("{\"a\":\"\\u0001\"}", "\x01")]
[InlineData("{\"a\":\"\\u0061\"}", "a")]
[InlineData("{\"a\":\"\\u003C\"}", "<")]
[InlineData("{\"a\":\"\\u003E\"}", ">")]
[InlineData("{\"a\":\"\\u003c\"}", "<")]
[InlineData("{\"a\":\"\\u003e\"}", ">")]
public void ShouldParseEscapedCharactersCorrectly(string json, string expectedCharacter)
{
var engine = new Engine();
Expand Down
2 changes: 1 addition & 1 deletion Jint/Native/Json/JsonParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private char ScanHexEscape()
{
if (_index < _length + 1 && IsHexDigit(_source[_index]))
{
char ch = _source[_index++];
char ch = char.ToLower(_source[_index++], CultureInfo.InvariantCulture);
code = code * 16 + "0123456789abcdef".IndexOf(ch);
}
else
Expand Down

0 comments on commit bdd5cae

Please sign in to comment.