Skip to content

Commit 2891423

Browse files
committed
In JavaScriptEngineSwitcher.Jint added support of Jint version 3.0.0 Beta 2031
1 parent dab93da commit 2891423

File tree

8 files changed

+39
-50
lines changed

8 files changed

+39
-50
lines changed

src/JavaScriptEngineSwitcher.Jint/Helpers/JintJsErrorHelpers.cs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,26 @@ internal static class JintJsErrorHelpers
2222

2323
private const string OriginalAnonymousFunctionName = "(anonymous)";
2424
private const string WrapperAnonymousFunctionName = "Anonymous function";
25+
private const string DelegateFunctionName = "delegate";
2526

2627
/// <summary>
2728
/// Regular expression for working with line of the script error location
2829
/// </summary>
2930
private static readonly Regex _errorLocationLineRegex =
3031
new Regex(@"^[ ]{3}at " +
3132
@"(?:" +
32-
@"(?<functionName>" +
33-
@"[\w][\w ]*" +
33+
@"(?:" +
34+
@"(?<functionName>" +
35+
@"[\w][\w ]*" +
36+
@"|" +
37+
CommonRegExps.JsFullNamePattern +
38+
@"|" +
39+
Regex.Escape(OriginalAnonymousFunctionName) +
40+
@") " +
41+
@"\((?:" + CommonRegExps.JsFullNamePattern + @"(?:, " + CommonRegExps.JsFullNamePattern + @")*)?\)" +
3442
@"|" +
35-
CommonRegExps.JsFullNamePattern +
36-
@"|" +
37-
Regex.Escape(OriginalAnonymousFunctionName) +
43+
@"(?<functionName>" + Regex.Escape(DelegateFunctionName) + @")" +
3844
@") " +
39-
@"(?:\(" + CommonRegExps.JsFullNamePattern + @"(?:, " + CommonRegExps.JsFullNamePattern + @")*\) )?" +
4045
@")?" +
4146
@"(?<documentName>" + CommonRegExps.DocumentNamePattern + @"):" +
4247
@"(?<lineNumber>\d+)(?::(?<columnNumber>\d+))?$");
@@ -92,29 +97,18 @@ public static ErrorLocationItem[] ParseErrorLocation(string errorLocation)
9297
/// Fixes a error location items
9398
/// </summary>
9499
/// <param name="errorLocationItems">An array of <see cref="ErrorLocationItem"/> instances</param>
95-
/// <param name="currentDocumentName">Current document name</param>
96-
public static void FixErrorLocationItems(ErrorLocationItem[] errorLocationItems, string currentDocumentName)
100+
public static void FixErrorLocationItems(ErrorLocationItem[] errorLocationItems)
97101
{
98102
foreach (ErrorLocationItem errorLocationItem in errorLocationItems)
99103
{
100104
string functionName = errorLocationItem.FunctionName;
101-
if (functionName.Length > 0)
102-
{
103-
if (functionName == OriginalAnonymousFunctionName)
104-
{
105-
errorLocationItem.FunctionName = WrapperAnonymousFunctionName;
106-
}
107-
}
108-
else
105+
if (functionName.Length == 0 || functionName == DelegateFunctionName)
109106
{
110107
errorLocationItem.FunctionName = "Global code";
111108
}
112-
113-
if (errorLocationItem.DocumentName == ":0" && errorLocationItem.LineNumber == 1)
109+
else if (functionName == OriginalAnonymousFunctionName)
114110
{
115-
errorLocationItem.DocumentName = currentDocumentName;
116-
errorLocationItem.LineNumber = 0;
117-
errorLocationItem.ColumnNumber = 0;
111+
errorLocationItem.FunctionName = WrapperAnonymousFunctionName;
118112
}
119113
}
120114
}

src/JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@
1818
<Import Project="../../build/nuget-for-dotnet-lib.props" />
1919

2020
<PropertyGroup>
21-
<Description>JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the Jint JavaScript Engine (http://github.com/sebastienros/jint) version 3.0.0 Beta 2002).</Description>
21+
<Description>JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the Jint JavaScript Engine (http://github.com/sebastienros/jint) version 3.0.0 Beta 2031).</Description>
2222
<PackageTags>$(PackageCommonTags);Jint</PackageTags>
2323
<PackageIconFullPath>../../Icons/JavaScriptEngineSwitcher_Jint_Logo128x128.png</PackageIconFullPath>
24-
<PackageReleaseNotes>1. Runtime exceptions now contain a stack trace;
25-
2. In configuration settings of the Jint JS engine a `AllowDebuggerStatement` property has been returned so as not to break compatibility with previous versions.</PackageReleaseNotes>
24+
<PackageReleaseNotes>Jint was updated to version 3.0.0 Beta 2031.</PackageReleaseNotes>
2625
</PropertyGroup>
2726

2827
<ItemGroup>
2928
<PackageReference Include="AdvancedStringBuilder" Version="0.1.0" />
30-
<PackageReference Include="Jint" Version="3.0.0-beta-2002" />
29+
<PackageReference Include="Jint" Version="3.0.0-beta-2031" />
3130

3231
<ProjectReference Include="../JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj" />
3332
</ItemGroup>

src/JavaScriptEngineSwitcher.Jint/JintJsEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public sealed class JintJsEngine : JsEngineBase
5252
/// <summary>
5353
/// Version of original JS engine
5454
/// </summary>
55-
private const string EngineVersion = "3.0.0 Beta 2002";
55+
private const string EngineVersion = "3.0.0 Beta 2031";
5656

5757
/// <summary>
5858
/// Jint JS engine
@@ -255,7 +255,7 @@ private WrapperRuntimeException WrapRuntimeException(OriginalRuntimeException or
255255
originalJavaScriptException.StackTrace);
256256
if (callStackItems.Length > 0)
257257
{
258-
JintJsErrorHelpers.FixErrorLocationItems(callStackItems, documentName);
258+
JintJsErrorHelpers.FixErrorLocationItems(callStackItems);
259259
callStack = JsErrorHelpers.StringifyErrorLocationItems(callStackItems, true);
260260
}
261261

src/JavaScriptEngineSwitcher.Jint/readme.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313
===========
1414
JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the
1515
Jint JavaScript Engine (http://github.com/sebastienros/jint) version
16-
3.0.0 Beta 2002).
16+
3.0.0 Beta 2031).
1717

1818
=============
1919
RELEASE NOTES
2020
=============
21-
1. Runtime exceptions now contain a stack trace;
22-
2. In configuration settings of the Jint JS engine a `AllowDebuggerStatement`
23-
property has been returned so as not to break compatibility with previous
24-
versions.
21+
Jint was updated to version 3.0.0 Beta 2031.
2522

2623
=============
2724
DOCUMENTATION

src/JavaScriptEngineSwitcher.V8/V8Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public bool DisableGlobalMembers
6868
/// or malicious script can still cause an application to fail by exhausting its address
6969
/// space or total available memory. On-demand heap expansion is recommended for use in
7070
/// conjunction with heap size monitoring (see <see cref="MaxHeapSize"/> property to help
71-
/// contain runaway scripts.
71+
/// contain runaway scripts).
7272
/// </para>
7373
/// </remarks>
7474
public double HeapExpansionMultiplier

test/JavaScriptEngineSwitcher.Tests/Jint/CommonTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public void GenerationOfRuntimeErrorMessageIsCorrect()
454454
string targetOutput = "ReferenceError: bar is not defined" + Environment.NewLine +
455455
" at foo (functions.js:4:3)" + Environment.NewLine +
456456
" at Anonymous function (functions.js:12:2)" + Environment.NewLine +
457-
" at Global code (functions.js)"
457+
" at Global code (functions.js:13:2)"
458458
;
459459

460460
JsRuntimeException exception = null;

test/JavaScriptEngineSwitcher.Tests/Jint/InteropTests.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,8 @@ public override void CallingOfEmbeddedDelegateWithMissingParameter()
8989

9090
#region Recursive calls
9191

92-
[Fact]
93-
public override void RecursiveEvaluationOfFilesIsCorrect()
94-
{ }
95-
96-
[Fact]
97-
public override void RecursiveExecutionOfFilesIsCorrect()
98-
{ }
99-
10092
#region Mapping of errors
10193

102-
/*
10394
[Fact]
10495
public void MappingCompilationErrorDuringRecursiveEvaluationOfFilesIsCorrect()
10596
{
@@ -182,7 +173,12 @@ public void MappingRuntimeErrorDuringRecursiveEvaluationOfFilesIsCorrect()
182173
Assert.Equal(10, exception.LineNumber);
183174
Assert.Equal(4, exception.ColumnNumber);
184175
Assert.Empty(exception.SourceFragment);
185-
Assert.Empty(exception.CallStack);
176+
Assert.Equal(
177+
" at sum (math.js:10:4)" + Environment.NewLine +
178+
" at calculateResult (index.js:7:13)" + Environment.NewLine +
179+
" at Global code (Script Document:1:1)",
180+
exception.CallStack
181+
);
186182
}
187183

188184
[Fact]
@@ -220,7 +216,6 @@ public void MappingHostErrorDuringRecursiveEvaluationOfFilesIsCorrect()
220216
Assert.NotNull(exception);
221217
Assert.StartsWith("Could not find file '", exception.Message);
222218
}
223-
*/
224219

225220
[Fact]
226221
public void MappingCompilationErrorDuringRecursiveExecutionOfFilesIsCorrect()
@@ -297,8 +292,12 @@ public void MappingRuntimeErrorDuringRecursiveExecutionOfFilesIsCorrect()
297292
Assert.Equal("second-file.js", exception.DocumentName);
298293
Assert.Equal(1, exception.LineNumber);
299294
Assert.Equal(1, exception.ColumnNumber);
300-
Assert.Equal("", exception.SourceFragment);
301-
Assert.Equal(" at Global code (second-file.js:1:1)", exception.CallStack
295+
Assert.Empty(exception.SourceFragment);
296+
Assert.Equal(
297+
" at Global code (second-file.js:1:1)" + Environment.NewLine +
298+
" at Global code (first-file.js:2:1)" + Environment.NewLine +
299+
" at Global code (main-file.js:2:1)",
300+
exception.CallStack
302301
);
303302
}
304303

test/JavaScriptEngineSwitcher.Tests/Jint/PrecompilationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void MappingRuntimeErrorDuringExecutionOfPrecompiledCodeIsCorrect()
101101
// Assert
102102
Assert.NotNull(exception);
103103
Assert.Equal("Runtime error", exception.Category);
104-
Assert.Equal("Cannot read property 'items' of null", exception.Description);
104+
Assert.Equal("Cannot read property '5' of null", exception.Description);
105105
Assert.Equal("TypeError", exception.Type);
106106
Assert.Equal("get-item.js", exception.DocumentName);
107107
Assert.Equal(2, exception.LineNumber);
@@ -110,7 +110,7 @@ public void MappingRuntimeErrorDuringExecutionOfPrecompiledCodeIsCorrect()
110110
Assert.Equal(
111111
" at getItem (get-item.js:2:19)" + Environment.NewLine +
112112
" at Anonymous function (get-item.js:9:10)" + Environment.NewLine +
113-
" at Global code (get-item.js)",
113+
" at Global code (get-item.js:13:2)",
114114
exception.CallStack
115115
);
116116
}
@@ -180,7 +180,7 @@ public void GenerationOfRuntimeErrorMessageIsCorrect()
180180
string targetOutput = "ReferenceError: middleName is not defined" + Environment.NewLine +
181181
" at getFullName (get-full-name.js:2:2)" + Environment.NewLine +
182182
" at Anonymous function (get-full-name.js:12:9)" + Environment.NewLine +
183-
" at Global code (get-full-name.js)"
183+
" at Global code (get-full-name.js:13:2)"
184184
;
185185

186186
JsRuntimeException exception = null;

0 commit comments

Comments
 (0)