Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for pending issues #744

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions testsrc/org/mozilla/javascript/tests/Issue645Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript.tests;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;

import static org.junit.Assert.assertEquals;

public class Issue645Test {
private Scriptable m_scope;

@Before
public void init() {
Context cx = Context.enter();
cx.setOptimizationLevel(-1);
m_scope = cx.initStandardObjects();
}

@After
public void cleanup() {
Context.exit();
}

private void test(String testCode, Object expected) {
Object result = null;
try{
result = eval(testCode);
} catch(Exception e) {
result = "EXCEPTIONCAUGHT";
}

assertEquals(expected, result);
}

private Object eval(String source) {
Context cx = Context.getCurrentContext();
return cx.evaluateString(m_scope, source, "source", 1, null);

}

@Test
public void testIssue662() { test( "for(({});;){ }", null); }
}
52 changes: 52 additions & 0 deletions testsrc/org/mozilla/javascript/tests/Issue662Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript.tests;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.EcmaError;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Undefined;

import static org.junit.Assert.assertEquals;

public class Issue662Test {
private Scriptable m_scope;

@Before
public void init() {
Context cx = Context.enter();
cx.setOptimizationLevel(-1);
m_scope = cx.initStandardObjects();
}

@After
public void cleanup() {
Context.exit();
}

private void test(String testCode, Object expected) {
Object result = null;
try{
result = eval(testCode);
} catch(Exception e) {
result = "EXCEPTIONCAUGHT";
}

assertEquals(expected, result);
}

private Object eval(String source) {
Context cx = Context.getCurrentContext();
return cx.evaluateString(m_scope, source, "source", 1, null);

}

@Test
public void testIssue662() {
test( "[\"\".h]=y", null);
}
}
53 changes: 53 additions & 0 deletions testsrc/org/mozilla/javascript/tests/Issue663Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript.tests;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.EcmaError;
import org.mozilla.javascript.Scriptable;

import static org.junit.Assert.assertEquals;

public class Issue663Test {
private Scriptable m_scope;

@Before
public void init() {
Context cx = Context.enter();
cx.setOptimizationLevel(-1);
m_scope = cx.initStandardObjects();
}

@After
public void cleanup() {
Context.exit();
}

private void test(String testCode, Object expected) {
Object result = null;
try{
result = eval(testCode);
} catch(EcmaError e) {
// Expected
} catch(Exception e) {
result = "EXCEPTIONCAUGHT";
}

assertEquals(expected, result);
}

private Object eval(String source) {
Context cx = Context.getCurrentContext();
return cx.evaluateString(m_scope, source, "source", 1, null);

}

@Test
public void testIssue663() {
test("\\u000a:S<6", null);
}
}