aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/script/basic/JDK-8024972.js43
-rw-r--r--test/script/basic/JDK-8024972.js.EXPECTED6
-rw-r--r--test/script/basic/JDK-8025048-2.js36
-rw-r--r--test/script/basic/JDK-8025048.js36
-rw-r--r--test/script/basic/JDK-8025080.js43
-rw-r--r--test/script/basic/JDK-8025080.js.EXPECTED4
-rw-r--r--test/script/basic/JDK-8025090.js35
-rw-r--r--test/script/basic/JDK-8025111.js48
-rw-r--r--test/script/basic/JDK-8025147.js41
-rw-r--r--test/script/basic/JDK-8025147.js.EXPECTED6
-rw-r--r--test/script/basic/JDK-8025149.js47
-rw-r--r--test/script/basic/JDK-8025149.js.EXPECTED9
-rw-r--r--test/script/basic/JDK-8025163.js39
-rw-r--r--test/script/basic/JDK-8025163.js.EXPECTED8
-rw-r--r--test/script/basic/JDK-8025197.js37
-rw-r--r--test/script/basic/JDK-8025197.js.EXPECTED7
-rw-r--r--test/script/basic/JDK-8025312.js35
-rw-r--r--test/script/basic/JDK-8025312.js.EXPECTED1
-rw-r--r--test/script/basic/JDK-8025325.js35
-rw-r--r--test/script/basic/JDK-8025325.js.EXPECTED5
-rw-r--r--test/script/basic/JDK-8025434.js66
-rw-r--r--test/script/basic/JDK-8025486.js55
-rw-r--r--test/script/basic/JDK-8025486.js.EXPECTED3
-rw-r--r--test/script/basic/parser/objectLitExpr.js.EXPECTED10
-rw-r--r--test/script/trusted/JDK-8008305.js2
-rw-r--r--test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java13
26 files changed, 661 insertions, 9 deletions
diff --git a/test/script/basic/JDK-8024972.js b/test/script/basic/JDK-8024972.js
new file mode 100644
index 00000000..2e940812
--- /dev/null
+++ b/test/script/basic/JDK-8024972.js
@@ -0,0 +1,43 @@
+/*
+ * 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-8024972: for (LeftHandSideExpression in Expression) crashes the compiler
+ *
+ * @test
+ * @run
+ */
+
+var obj = {};
+
+var arr = [2, 45, -1, 445];
+for (obj.x in arr) {
+ print(obj.x + "->"+ arr[obj.x]);
+}
+
+var abc = { foo: 'bar', hello: 'world' };
+for (obj.x in abc) {
+ print(obj.x + "->" + abc[obj.x]);
+}
+
+for (obj.x in 0) {}
diff --git a/test/script/basic/JDK-8024972.js.EXPECTED b/test/script/basic/JDK-8024972.js.EXPECTED
new file mode 100644
index 00000000..aa4692fb
--- /dev/null
+++ b/test/script/basic/JDK-8024972.js.EXPECTED
@@ -0,0 +1,6 @@
+0->2
+1->45
+2->-1
+3->445
+foo->bar
+hello->world
diff --git a/test/script/basic/JDK-8025048-2.js b/test/script/basic/JDK-8025048-2.js
new file mode 100644
index 00000000..c11816ba
--- /dev/null
+++ b/test/script/basic/JDK-8025048-2.js
@@ -0,0 +1,36 @@
+/*
+ * 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-8025048: true as case label results in ClassCastException
+ *
+ * @test
+ * @run
+ */
+
+function func(x) {
+ switch(x) {
+ case 8: break; case false:
+ }
+}
+
diff --git a/test/script/basic/JDK-8025048.js b/test/script/basic/JDK-8025048.js
new file mode 100644
index 00000000..75838a98
--- /dev/null
+++ b/test/script/basic/JDK-8025048.js
@@ -0,0 +1,36 @@
+/*
+ * 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-8025048: true as case label results in ClassCastException
+ *
+ * @test
+ * @run
+ */
+
+function func(x) {
+ switch(x) {
+ case 8: break; case true:
+ }
+}
+
diff --git a/test/script/basic/JDK-8025080.js b/test/script/basic/JDK-8025080.js
new file mode 100644
index 00000000..1ea46efa
--- /dev/null
+++ b/test/script/basic/JDK-8025080.js
@@ -0,0 +1,43 @@
+/*
+ * 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-8025080: Object literal getter, setter function with number format property name results in ClassFormatError
+ *
+ * @test
+ * @run
+ */
+
+var obj = {
+ get 1e81() { print("1e81 getter"); },
+ set 1e81(x) { print("1e81 setter"); },
+ get 3.14e-2() { print("3.14e-2 getter");},
+ set 3.14e-2(x) { print("3.14e-2 setter"); }
+};
+
+obj[1e81];
+obj[1e81] = 23;
+
+obj[3.14e-2];
+obj[3.14e-2] = 42;
+
diff --git a/test/script/basic/JDK-8025080.js.EXPECTED b/test/script/basic/JDK-8025080.js.EXPECTED
new file mode 100644
index 00000000..e19e8ae9
--- /dev/null
+++ b/test/script/basic/JDK-8025080.js.EXPECTED
@@ -0,0 +1,4 @@
+1e81 getter
+1e81 setter
+3.14e-2 getter
+3.14e-2 setter
diff --git a/test/script/basic/JDK-8025090.js b/test/script/basic/JDK-8025090.js
new file mode 100644
index 00000000..8e42099c
--- /dev/null
+++ b/test/script/basic/JDK-8025090.js
@@ -0,0 +1,35 @@
+/*
+ * 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-8025090: 'while' statement with 'test' using var before being declared in body results in VerifyError
+ *
+ * @test
+ * @run
+ */
+
+// The following used to result in VerifyError
+function f() {
+ while (x += 2) { var x = 44 }
+}
+
diff --git a/test/script/basic/JDK-8025111.js b/test/script/basic/JDK-8025111.js
new file mode 100644
index 00000000..953f27c0
--- /dev/null
+++ b/test/script/basic/JDK-8025111.js
@@ -0,0 +1,48 @@
+/*
+ * 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-8025111: undefined or null 'with' expression in empty with block should throw TypeError
+ *
+ * @test
+ * @run
+ */
+
+function check(callback, arg) {
+ try {
+ callback(arg);
+ fail("should have thrown TypeError: " + callback + " on " + arg);
+ } catch (e) {
+ if (! (e instanceof TypeError)) {
+ fail("Expected TypeError, got " + e);
+ }
+ }
+}
+
+function func(obj) {
+ with(obj) {}
+}
+
+check(func);
+check(func, undefined);
+check(func, null);
diff --git a/test/script/basic/JDK-8025147.js b/test/script/basic/JDK-8025147.js
new file mode 100644
index 00000000..905a1c9c
--- /dev/null
+++ b/test/script/basic/JDK-8025147.js
@@ -0,0 +1,41 @@
+/*
+ * 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-8025147: Trailing comma is not allowed in JSONArray and JSONObject
+ *
+ * @test
+ * @run
+ */
+
+function check(str) {
+ try {
+ JSON.parse(str);
+ fail("should have thrown SyntaxError for " + str);
+ } catch (e) {
+ print(e);
+ }
+}
+
+check("{ \"a\": 333, }");
+check("[ 4343, ]");
diff --git a/test/script/basic/JDK-8025147.js.EXPECTED b/test/script/basic/JDK-8025147.js.EXPECTED
new file mode 100644
index 00000000..3afb20a8
--- /dev/null
+++ b/test/script/basic/JDK-8025147.js.EXPECTED
@@ -0,0 +1,6 @@
+SyntaxError: Invalid JSON: <json>:1:12 Trailing comma is not allowed in JSON
+{ "a": 333, }
+ ^
+SyntaxError: Invalid JSON: <json>:1:8 Trailing comma is not allowed in JSON
+[ 4343, ]
+ ^
diff --git a/test/script/basic/JDK-8025149.js b/test/script/basic/JDK-8025149.js
new file mode 100644
index 00000000..b1d33a1a
--- /dev/null
+++ b/test/script/basic/JDK-8025149.js
@@ -0,0 +1,47 @@
+/*
+ * 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-8025149: JSON.stringify does not handle 'space' argument as per the spec.
+ *
+ * @test
+ * @run
+ */
+
+print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(Infinity)));
+
+print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(-Infinity)));
+
+try {
+ JSON.stringify({},[],
+ (n = new Number(0), n.valueOf = function() { throw ("inside n.valueOf") }, n));
+} catch (e) {
+ print(e);
+}
+
+try {
+ JSON.stringify({},[],
+ (s = new String(""), s.toString = function() { throw ("inside s.toString") }, s));
+} catch (e) {
+ print(e);
+}
diff --git a/test/script/basic/JDK-8025149.js.EXPECTED b/test/script/basic/JDK-8025149.js.EXPECTED
new file mode 100644
index 00000000..10fd8641
--- /dev/null
+++ b/test/script/basic/JDK-8025149.js.EXPECTED
@@ -0,0 +1,9 @@
+{
+ "foo": 23,
+ "bar": {
+ "x": 22
+ }
+}
+{"foo":23,"bar":{"x":22}}
+inside n.valueOf
+inside s.toString
diff --git a/test/script/basic/JDK-8025163.js b/test/script/basic/JDK-8025163.js
new file mode 100644
index 00000000..1eaa98e8
--- /dev/null
+++ b/test/script/basic/JDK-8025163.js
@@ -0,0 +1,39 @@
+/*
+ * 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-8025163: Date methods should not return -0
+ *
+ * @test
+ * @run
+ */
+
+print(1 / (new Date(0, 0, 1)).getYear());
+print(1 / (new Date(1969, 1, 2)).getDay());
+print(1 / (new Date(1969, 0, 1)).getHours());
+print(1 / (new Date(1969, 0, 1)).getHours());
+print(1 / (new Date(1969, 0, 1)).getMinutes());
+print(1 / (new Date(1969, 0, 1)).getSeconds());
+print(1 / (new Date(1969, 0, 1)).getMilliseconds());
+print(1 / (new Date(1969, 0, 1)).getMilliseconds());
+
diff --git a/test/script/basic/JDK-8025163.js.EXPECTED b/test/script/basic/JDK-8025163.js.EXPECTED
new file mode 100644
index 00000000..cde7e193
--- /dev/null
+++ b/test/script/basic/JDK-8025163.js.EXPECTED
@@ -0,0 +1,8 @@
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
+Infinity
diff --git a/test/script/basic/JDK-8025197.js b/test/script/basic/JDK-8025197.js
new file mode 100644
index 00000000..5099b673
--- /dev/null
+++ b/test/script/basic/JDK-8025197.js
@@ -0,0 +1,37 @@
+/*
+ * 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-8025197: String replace method fails with regexp /$/gi
+ *
+ * @test
+ * @run
+ */
+
+print('dog'.replace(/$/gi, 's'));
+print('dog'.replace(/(?:g)$/gi, 's'));
+print('dog'.replace(/(?:a)$/gi, 's'));
+print('dog'.replace(/(?!g)$/gi, 's'));
+print('dog'.replace(/(?!a)$/gi, 's'));
+print('dog'.replace(/g?$/gi, 's'));
+print('dog'.replace(/.?$/gi, 's'));
diff --git a/test/script/basic/JDK-8025197.js.EXPECTED b/test/script/basic/JDK-8025197.js.EXPECTED
new file mode 100644
index 00000000..9f2a08f6
--- /dev/null
+++ b/test/script/basic/JDK-8025197.js.EXPECTED
@@ -0,0 +1,7 @@
+dogs
+dos
+dog
+dogs
+dogs
+doss
+doss
diff --git a/test/script/basic/JDK-8025312.js b/test/script/basic/JDK-8025312.js
new file mode 100644
index 00000000..6f2b42f3
--- /dev/null
+++ b/test/script/basic/JDK-8025312.js
@@ -0,0 +1,35 @@
+/*
+ * 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-8025312: parseInt should convert 'radix' argument to ToInt32 even if empty string is parsed
+ *
+ * @test
+ * @run
+ */
+
+parseInt("", {
+ valueOf: function() {
+ print("inside valueOf of 'radix'");
+ }
+});
diff --git a/test/script/basic/JDK-8025312.js.EXPECTED b/test/script/basic/JDK-8025312.js.EXPECTED
new file mode 100644
index 00000000..31ffef83
--- /dev/null
+++ b/test/script/basic/JDK-8025312.js.EXPECTED
@@ -0,0 +1 @@
+inside valueOf of 'radix'
diff --git a/test/script/basic/JDK-8025325.js b/test/script/basic/JDK-8025325.js
new file mode 100644
index 00000000..63dfef9d
--- /dev/null
+++ b/test/script/basic/JDK-8025325.js
@@ -0,0 +1,35 @@
+/*
+ * 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-8025325: parseFloat does not handle '.' in exponent part
+ *
+ * @test
+ * @run
+ */
+
+print(parseFloat("2e2."));
+print(parseFloat("2e2.3"));
+print(parseFloat("2e2.fdgdf"));
+print(parseFloat("2e2. gdfgdf"));
+print(parseFloat("2e2. "));
diff --git a/test/script/basic/JDK-8025325.js.EXPECTED b/test/script/basic/JDK-8025325.js.EXPECTED
new file mode 100644
index 00000000..4ddf679a
--- /dev/null
+++ b/test/script/basic/JDK-8025325.js.EXPECTED
@@ -0,0 +1,5 @@
+200
+200
+200
+200
+200
diff --git a/test/script/basic/JDK-8025434.js b/test/script/basic/JDK-8025434.js
new file mode 100644
index 00000000..1d429594
--- /dev/null
+++ b/test/script/basic/JDK-8025434.js
@@ -0,0 +1,66 @@
+/*
+ * 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-8025434: RegExp lastIndex can exceed int range
+ *
+ * @test
+ * @run
+ */
+
+var r = /a/g;
+
+r.lastIndex = 0x100000000;
+if (r.test("a")) {
+ throw new Error("Expected no match");
+}
+
+r.lastIndex = 0x100000000000000;
+if (r.test("a")) {
+ throw new Error("Expected no match");
+}
+
+r.lastIndex = -0x100000000;
+if (r.test("a")) {
+ throw new Error("Expected match");
+}
+
+r.lastIndex = -0x100000000000000;
+if (r.test("a")) {
+ throw new Error("Expected no match");
+}
+
+r.lastIndex = 1;
+if (r.test("a")) {
+ throw new Error("Expected no match");
+}
+
+r.lastIndex = -1;
+if (r.test("a")) {
+ throw new Error("Expected no match");
+}
+
+r.lastIndex = 0;
+if (!r.test("a")) {
+ throw new Error("Expected match");
+}
diff --git a/test/script/basic/JDK-8025486.js b/test/script/basic/JDK-8025486.js
new file mode 100644
index 00000000..8012f723
--- /dev/null
+++ b/test/script/basic/JDK-8025486.js
@@ -0,0 +1,55 @@
+/*
+ * 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-8025486: RegExp constructor arguments are not evaluated in right order
+ *
+ * @test
+ * @run
+ */
+
+new RegExp({
+ toString: function() {
+ print("source");
+ return "a";
+ }
+}, {
+ toString: function() {
+ print("flags");
+ return "g";
+ }
+});
+
+try {
+ new RegExp(/asdf/, {
+ toString: function() {
+ fail("toString should not be called");
+ }
+ });
+ fail("expected TypeError");
+} catch (e) {
+ if (!(e instanceof TypeError)) {
+ fail("expected TypeError");
+ }
+ print(e);
+}
diff --git a/test/script/basic/JDK-8025486.js.EXPECTED b/test/script/basic/JDK-8025486.js.EXPECTED
new file mode 100644
index 00000000..cf46bd7a
--- /dev/null
+++ b/test/script/basic/JDK-8025486.js.EXPECTED
@@ -0,0 +1,3 @@
+source
+flags
+TypeError: Cannot supply flags when constructing one RegExp from another
diff --git a/test/script/basic/parser/objectLitExpr.js.EXPECTED b/test/script/basic/parser/objectLitExpr.js.EXPECTED
index 067c506a..7968d9a4 100644
--- a/test/script/basic/parser/objectLitExpr.js.EXPECTED
+++ b/test/script/basic/parser/objectLitExpr.js.EXPECTED
@@ -126,10 +126,7 @@
},
"value": {
"type": "FunctionExpression",
- "id": {
- "type": "Identifier",
- "name": "get x"
- },
+ "id": null,
"params": [],
"defaults": [],
"rest": null,
@@ -157,10 +154,7 @@
},
"value": {
"type": "FunctionExpression",
- "id": {
- "type": "Identifier",
- "name": "get y"
- },
+ "id": null,
"params": [],
"defaults": [],
"rest": null,
diff --git a/test/script/trusted/JDK-8008305.js b/test/script/trusted/JDK-8008305.js
index e4d052cb..d57b5208 100644
--- a/test/script/trusted/JDK-8008305.js
+++ b/test/script/trusted/JDK-8008305.js
@@ -54,6 +54,6 @@ try {
fail("Expected SecurityException from script!");
} catch (e) {
if (! (e instanceof SecurityException)) {
- faile("Expected SecurityException, but got " + e);
+ fail("Expected SecurityException, but got " + e);
}
}
diff --git a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
index 416669fb..99207de0 100644
--- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
+++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
@@ -37,10 +37,12 @@ import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import javax.script.Compilable;
import javax.script.CompiledScript;
+import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
import org.testng.annotations.Test;
/**
@@ -231,6 +233,17 @@ public class ScriptEngineTest {
}
@Test
+ public void compileAndEvalInDiffContextTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine engine = m.getEngineByName("js");
+ final Compilable compilable = (Compilable) engine;
+ final CompiledScript compiledScript = compilable.compile("foo");
+ final ScriptContext ctxt = new SimpleScriptContext();
+ ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
+ assertEquals(compiledScript.eval(ctxt), "hello");
+ }
+
+ @Test
public void accessGlobalTest() {
final ScriptEngineManager m = new ScriptEngineManager();
final ScriptEngine e = m.getEngineByName("nashorn");