author | hannesw |
Tue, 16 Dec 2014 17:02:54 +0100 | |
changeset 28127 | 08a5e0d3248d |
parent 25423 | ca63828cf996 |
permissions | -rw-r--r-- |
24995
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
1 |
/* |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
4 |
* |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
8 |
* |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
14 |
* |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
18 |
* |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
21 |
* questions. |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
22 |
*/ |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
23 |
|
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
24 |
/** |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
25 |
* JDK-8047057: Add a regression test for the passing test cases from JDK-8042304 |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
26 |
* |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
27 |
* @test |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
28 |
* @run |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
29 |
*/ |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
30 |
|
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
31 |
// commented out makeFuncAndCall calls are still result in crash |
25234
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24995
diff
changeset
|
32 |
// Tests commented with //** fail only when assertions are turned on |
24995
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
33 |
|
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
34 |
function makeFuncAndCall(code) { |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
35 |
Function(code)(); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
36 |
} |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
37 |
|
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
38 |
function makeFuncExpectError(code, ErrorType) { |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
39 |
try { |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
40 |
makeFuncAndCall(code); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
41 |
} catch (e) { |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
42 |
if (! (e instanceof ErrorType)) { |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
43 |
fail(ErrorType.name + " expected, got " + e); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
44 |
} |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
45 |
} |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
46 |
} |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
47 |
|
25244
627d7e86f3b5
8047357: More precise synthetic return + unreachable throw
attila
parents:
25237
diff
changeset
|
48 |
makeFuncAndCall("switch(0) { default: {break;} return }"); |
627d7e86f3b5
8047357: More precise synthetic return + unreachable throw
attila
parents:
25237
diff
changeset
|
49 |
makeFuncAndCall("L: { { break L; } return; }"); |
24995
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
50 |
makeFuncAndCall("L: { while(0) break L; return; }"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
51 |
makeFuncExpectError("L: {while(0) break L; return [](); }", TypeError); |
25423
ca63828cf996
8047067: all eval arguments need to be copied in Lower
attila
parents:
25244
diff
changeset
|
52 |
makeFuncAndCall("do with({}) break ; while(0);"); |
24995
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
53 |
makeFuncAndCall("while(0) with({}) continue ;"); |
25234
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24995
diff
changeset
|
54 |
makeFuncAndCall("eval([]);"); |
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24995
diff
changeset
|
55 |
makeFuncAndCall("try{} finally{[]}"); |
24995
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
56 |
makeFuncAndCall("try { } catch(x if 1) { try { } catch(x2) { } }"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
57 |
makeFuncAndCall("try { } catch(x if 1) { try { return; } catch(x2) { { } } }"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
58 |
makeFuncAndCall("Error() * (false)[-0]--"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
59 |
makeFuncAndCall("try { var x = 1, x = null; } finally { }"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
60 |
makeFuncAndCall("try { var x = {}, x = []; } catch(x3) { }"); |
25234
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24995
diff
changeset
|
61 |
makeFuncAndCall("[delete this]"); |
25423
ca63828cf996
8047067: all eval arguments need to be copied in Lower
attila
parents:
25244
diff
changeset
|
62 |
makeFuncAndCall("if(eval('', eval('', function() {}))) { }"); |
ca63828cf996
8047067: all eval arguments need to be copied in Lower
attila
parents:
25244
diff
changeset
|
63 |
makeFuncAndCall("if(eval('', eval('', function() {}))) { }"); |
ca63828cf996
8047067: all eval arguments need to be copied in Lower
attila
parents:
25244
diff
changeset
|
64 |
makeFuncAndCall("eval(\"[,,];\", [11,12,13,14].some)"); |
ca63828cf996
8047067: all eval arguments need to be copied in Lower
attila
parents:
25244
diff
changeset
|
65 |
makeFuncAndCall("eval(\"1.2e3\", ({})[ /x/ ])"); |
25234
e2f9df6b8797
8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable
lagergren
parents:
24995
diff
changeset
|
66 |
makeFuncExpectError("eval(\"x4\", x3);", ReferenceError); |
24995
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
67 |
makeFuncAndCall("with({5.0000000000000000000000: String()}){(false); }"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
68 |
makeFuncAndCall("try { var x = undefined, x = 5.0000000000000000000000; } catch(x) { x = undefined; }"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
69 |
makeFuncAndCall("(function (x){ x %= this}(false))"); |
25237 | 70 |
makeFuncAndCall("eval.apply.apply(function(){ eval('') })"); |
24995
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
71 |
makeFuncAndCall("(false % !this) && 0"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
72 |
makeFuncAndCall("with({8: 'fafafa'.replace()}){ }"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
73 |
makeFuncAndCall("(function (x) '' )(true)"); |
5f6ef4c9cbd4
8047057: Add a regression test for the passing test cases from JDK-8042304
sundar
parents:
diff
changeset
|
74 |
makeFuncExpectError("new eval(function(){})", TypeError); |
25423
ca63828cf996
8047067: all eval arguments need to be copied in Lower
attila
parents:
25244
diff
changeset
|
75 |
makeFuncAndCall('eval("23", ({})[/x/])'); |