aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsundar <none@none>2013-11-22 08:52:45 +0530
committersundar <none@none>2013-11-22 08:52:45 +0530
commitd7bc2e09c91bf4e73047b3f81c07d8087ba98461 (patch)
tree6d139bb757730f824182c35ee4d6b440d176c48f /test
parentf16f59e2492b1e5e48395fadd4bc9cea1505be15 (diff)
parent1423afcf0b8e0e087be21667a7438c6adb3b8608 (diff)
downloadnashorn-d7bc2e09c91bf4e73047b3f81c07d8087ba98461.tar.gz
Merge
Diffstat (limited to 'test')
-rw-r--r--test/script/basic/JDK-8028210.js83
-rw-r--r--test/script/basic/JDK-8028210.js.EXPECTED38
-rw-r--r--test/script/basic/JDK-8028434.js58
-rw-r--r--test/script/basic/JDK-8028434.js.EXPECTED1
-rw-r--r--test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java2
5 files changed, 181 insertions, 1 deletions
diff --git a/test/script/basic/JDK-8028210.js b/test/script/basic/JDK-8028210.js
new file mode 100644
index 00000000..54f113a0
--- /dev/null
+++ b/test/script/basic/JDK-8028210.js
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8028210: Missing conversions on array index expression
+ *
+ * @test
+ * @run
+ */
+
+var array = [1, 2];
+var key1 = [[[0]]];
+var key2 = new String("1");
+var key3 = {
+ toString: function() {
+ print("toString called");
+ return "2";
+ }
+};
+
+print(array[key1]);
+print(array[key2]);
+array[key3] = 3;
+print(array[key3]);
+print(key3 in array);
+print(array.hasOwnProperty(key3));
+print(delete array[key3]);
+print(array[key3]);
+
+// string access
+print("abc"[key1]);
+print("abc"[key2]);
+print("abc"[key3]);
+
+// arguments object
+(function(a, b, c) {
+ print(arguments[key3]);
+ delete arguments[key3];
+ print(arguments[key3], c);
+})(1, 2, 3);
+
+// int keys
+array = [];
+array[4294967294] = 1;
+print(array[-2]);
+print(array[4294967294]);
+print(-2 in array);
+print(4294967294 in array);
+print(delete(array[-2]));
+print(array[4294967294]);
+print(delete(array[4294967294]));
+print(array[4294967294]);
+
+array = [];
+array[-2] = 1;
+print(array[-2]);
+print(array[4294967294]);
+print(-2 in array);
+print(4294967294 in array);
+print(delete(array[4294967294]));
+print(array[-2]);
+print(delete(array[-2]));
+print(array[-2]);
diff --git a/test/script/basic/JDK-8028210.js.EXPECTED b/test/script/basic/JDK-8028210.js.EXPECTED
new file mode 100644
index 00000000..0ac098e6
--- /dev/null
+++ b/test/script/basic/JDK-8028210.js.EXPECTED
@@ -0,0 +1,38 @@
+1
+2
+toString called
+toString called
+3
+toString called
+true
+toString called
+true
+toString called
+true
+toString called
+undefined
+a
+b
+toString called
+c
+toString called
+3
+toString called
+toString called
+undefined 3
+undefined
+1
+false
+true
+true
+1
+true
+undefined
+1
+undefined
+true
+false
+true
+1
+true
+undefined
diff --git a/test/script/basic/JDK-8028434.js b/test/script/basic/JDK-8028434.js
new file mode 100644
index 00000000..c3374151
--- /dev/null
+++ b/test/script/basic/JDK-8028434.js
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8028434: Check that the line number of the tests in while and do while loops
+ * is correct. It needs to correspond to the line with the test expression.
+ *
+ * @test
+ * @run
+ */
+
+try {
+ while (test.apa < 0) {
+ print("x");
+ }
+} catch (e) {
+ var st = e.getStackTrace();
+ if (st.length != 1) {
+ print("erroneous stacktrace length " + s.length);
+ }
+ if (st[0].lineNumber !== 33) {
+ print("erroneous stacktrace element, lineNumber=" + st[0].lineNumber + " elem=" + st);
+ }
+}
+
+try {
+ do {
+ print("x");
+ } while (test.apa < 0);
+} catch (e) {
+ var st = e.getStackTrace();
+ if (st.length != 1) {
+ print("erroneous stacktrace length " + s.length);
+ }
+ if (st[0].lineNumber !== 49) {
+ print("erroneous stacktrace element, lineNumber= " + st[0].lineNumber + " elem=" + st);
+ }
+}
diff --git a/test/script/basic/JDK-8028434.js.EXPECTED b/test/script/basic/JDK-8028434.js.EXPECTED
new file mode 100644
index 00000000..587be6b4
--- /dev/null
+++ b/test/script/basic/JDK-8028434.js.EXPECTED
@@ -0,0 +1 @@
+x
diff --git a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
index 55aacb34..2c7df64d 100644
--- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
+++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
@@ -50,7 +50,7 @@ import org.testng.annotations.Test;
*
* @test
* @build jdk.nashorn.api.scripting.Window jdk.nashorn.api.scripting.WindowEventHandler jdk.nashorn.api.scripting.VariableArityTestInterface jdk.nashorn.api.scripting.ScriptEngineTest
- * @run testng jdk.nashorn.api.scripting.ScriptEngineTest
+ * @run testng/othervm jdk.nashorn.api.scripting.ScriptEngineTest
*/
public class ScriptEngineTest {