Added tests for pending issues

This commit is contained in:
Luis Pina 2020-07-06 16:13:19 -05:00
Родитель c4d5e78720
Коммит 0fb3d53656
3 изменённых файлов: 153 добавлений и 0 удалений

Просмотреть файл

@ -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); }
}

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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);
}
}