OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 "use strict"; | 28 "use strict"; |
29 | 29 |
30 var code1 = "function f(eval) {}"; | 30 var code1 = "function f(eval) {}"; |
31 var code2 = "function f(a, a) {}"; | 31 var code2 = "function f(a, a) {}"; |
32 var code3 = "var x = '\\020;'"; | 32 var code3 = "var x = '\\020;'"; |
33 var code4 = "function arguments() {}"; | 33 var code4 = "function arguments() {}"; |
| 34 var code5 = "(() => { function a({ eval = false } = {}) {} })()"; |
| 35 var code6 = "function f() { var {eval} = {}; }" |
34 | 36 |
35 // Verify the code compiles just fine in non-strict mode | 37 // Verify the code compiles just fine in non-strict mode |
36 // (using aliased eval to force non-strict mode) | 38 // (using aliased eval to force non-strict mode) |
37 var eval_alias = eval; | 39 var eval_alias = eval; |
38 | 40 |
39 eval_alias(code1); | 41 eval_alias(code1); |
40 eval_alias(code2); | 42 eval_alias(code2); |
41 eval_alias(code3); | 43 eval_alias(code3); |
42 eval_alias(code4); | 44 eval_alias(code4); |
| 45 eval_alias(code5); |
| 46 eval_alias(code6); |
43 | 47 |
44 function strict1() { | 48 function strict1() { |
45 var exception = false; | 49 var exception = false; |
46 try { | 50 try { |
47 eval(code1); | 51 eval(code1); |
48 } catch (e) { | 52 } catch (e) { |
49 exception = true; | 53 exception = true; |
50 assertInstanceof(e, SyntaxError); | 54 assertInstanceof(e, SyntaxError); |
51 } | 55 } |
52 assertTrue(exception); | 56 assertTrue(exception); |
(...skipping 20 matching lines...) Expand all Loading... |
73 | 77 |
74 function strict4() { | 78 function strict4() { |
75 var exception = false; | 79 var exception = false; |
76 try { | 80 try { |
77 eval(code4); | 81 eval(code4); |
78 } catch (e) { | 82 } catch (e) { |
79 exception = true; | 83 exception = true; |
80 assertInstanceof(e, SyntaxError); | 84 assertInstanceof(e, SyntaxError); |
81 } | 85 } |
82 assertTrue(exception); | 86 assertTrue(exception); |
| 87 |
| 88 function strict5() { |
| 89 var exception = false; |
| 90 try { |
| 91 eval(code5); |
| 92 } catch (e) { |
| 93 exception = true; |
| 94 assertInstanceof(e, SyntaxError); |
| 95 } |
| 96 assertTrue(exception); |
| 97 |
| 98 function strict6() { |
| 99 var exception = false; |
| 100 try { |
| 101 eval(code6); |
| 102 } catch (e) { |
| 103 exception = true; |
| 104 assertInstanceof(e, SyntaxError); |
| 105 } |
| 106 assertTrue(exception); |
| 107 } |
| 108 strict6(); |
| 109 } |
| 110 strict5(); |
83 } | 111 } |
84 strict4(); | 112 strict4(); |
85 } | 113 } |
86 strict3(); | 114 strict3(); |
87 } | 115 } |
88 strict2(); | 116 strict2(); |
89 } | 117 } |
90 strict1(); | 118 strict1(); |
OLD | NEW |