-
Notifications
You must be signed in to change notification settings - Fork 859
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BigIntLiteral.toSource includes suffix
- Loading branch information
1 parent
c5c7fa6
commit a754ea6
Showing
2 changed files
with
48 additions
and
1 deletion.
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
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,47 @@ | ||
package org.mozilla.javascript.tests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.IOException; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mozilla.javascript.CompilerEnvirons; | ||
import org.mozilla.javascript.Context; | ||
import org.mozilla.javascript.Parser; | ||
import org.mozilla.javascript.Scriptable; | ||
import org.mozilla.javascript.ast.AstRoot; | ||
import org.mozilla.javascript.tools.shell.Global; | ||
|
||
/** This is a set of tests for parsing and using BigInts. */ | ||
public class BigIntTest { | ||
|
||
private Context cx; | ||
private Scriptable global; | ||
|
||
@Before | ||
public void init() { | ||
cx = Context.enter(); | ||
cx.setLanguageVersion(Context.VERSION_ES6); | ||
cx.getWrapFactory().setJavaPrimitiveWrap(false); | ||
global = new Global(cx); | ||
} | ||
|
||
@After | ||
public void terminate() { | ||
Context.exit(); | ||
} | ||
|
||
@Test | ||
public void parse() throws IOException { | ||
String[] INPUTS = | ||
new String[] {"0n", "12n", "-12n", "1234567890987654321n", "-1234567890987654321n"}; | ||
CompilerEnvirons env = new CompilerEnvirons(); | ||
env.setLanguageVersion(Context.VERSION_ES6); | ||
for (String input : INPUTS) { | ||
String stmt = "x = " + input + ";\n"; | ||
AstRoot root = new Parser(env).parse(stmt, "bigint.js", 1); | ||
assertEquals(stmt, root.toSource()); | ||
} | ||
} | ||
} |