test/src/jdk/nashorn/internal/runtime/ContextTest.java
Print this page
*** 27,36 ****
--- 27,37 ----
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.Map;
+ import jdk.nashorn.internal.objects.Global;
import jdk.nashorn.internal.runtime.options.Options;
import org.testng.annotations.Test;
/**
* Basic Context API tests.
*** 43,53 ****
@Test
public void evalTest() {
final Options options = new Options("");
final ErrorManager errors = new ErrorManager();
final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
! final ScriptObject oldGlobal = Context.getGlobal();
Context.setGlobal(cx.createGlobal());
try {
String code = "22 + 10";
assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());
--- 44,54 ----
@Test
public void evalTest() {
final Options options = new Options("");
final ErrorManager errors = new ErrorManager();
final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
! final Global oldGlobal = Context.getGlobal();
Context.setGlobal(cx.createGlobal());
try {
String code = "22 + 10";
assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());
*** 63,73 ****
public void reflectionTest() {
final Options options = new Options("");
final ErrorManager errors = new ErrorManager();
final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
final boolean strict = cx.getEnv()._strict;
! final ScriptObject oldGlobal = Context.getGlobal();
Context.setGlobal(cx.createGlobal());
try {
final String code = "var obj = { x: 344, y: 42 }";
eval(cx, "<reflectionTest>", code);
--- 64,74 ----
public void reflectionTest() {
final Options options = new Options("");
final ErrorManager errors = new ErrorManager();
final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
final boolean strict = cx.getEnv()._strict;
! final Global oldGlobal = Context.getGlobal();
Context.setGlobal(cx.createGlobal());
try {
final String code = "var obj = { x: 344, y: 42 }";
eval(cx, "<reflectionTest>", code);