forked from sebastienros/jint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix BigInt arithmetic assignments (sebastienros#1887)
- Loading branch information
Showing
4 changed files
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Jint.Native; | ||
|
||
namespace Jint.Tests.Runtime; | ||
|
||
public class BigIntTests | ||
{ | ||
[Theory] | ||
[InlineData("a = a + b;", "146")] | ||
[InlineData("a = a - b;", "100")] | ||
[InlineData("a = a * b;", "2829")] | ||
[InlineData("a = a / b;", "5")] | ||
[InlineData("a += b;", "146")] | ||
[InlineData("a -= b;", "100")] | ||
[InlineData("a *= b;", "2829")] | ||
[InlineData("a /= b;", "5")] | ||
public void BasicOperations(string statement, string expected) | ||
{ | ||
var outputValues = new List<JsValue>(); | ||
var engine = new Engine() | ||
.SetValue("log", outputValues.Add); | ||
engine.Evaluate("let a = 123n; let b = 23n;"); | ||
|
||
engine.Evaluate(statement); | ||
|
||
engine.Evaluate("log(a)"); | ||
Assert.True(outputValues[0].IsBigInt(), "The type of the value is expected to stay BigInt"); | ||
Assert.Equal(expected, outputValues[0].ToString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters