Chromium Code Reviews| 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 } = {}) {} })()"; | |
|
adamk
2016/07/28 18:33:44
Is the outer arrow function an important part of t
| |
| 34 | 35 |
| 35 // Verify the code compiles just fine in non-strict mode | 36 // Verify the code compiles just fine in non-strict mode |
| 36 // (using aliased eval to force non-strict mode) | 37 // (using aliased eval to force non-strict mode) |
| 37 var eval_alias = eval; | 38 var eval_alias = eval; |
| 38 | 39 |
| 39 eval_alias(code1); | 40 eval_alias(code1); |
| 40 eval_alias(code2); | 41 eval_alias(code2); |
| 41 eval_alias(code3); | 42 eval_alias(code3); |
| 42 eval_alias(code4); | 43 eval_alias(code4); |
|
adamk
2016/07/28 18:33:44
Can you add code5 here too?
lpy
2016/08/05 22:15:42
Done.
| |
| 43 | 44 |
| 44 function strict1() { | 45 function strict1() { |
| 45 var exception = false; | 46 var exception = false; |
| 46 try { | 47 try { |
| 47 eval(code1); | 48 eval(code1); |
| 48 } catch (e) { | 49 } catch (e) { |
| 49 exception = true; | 50 exception = true; |
| 50 assertInstanceof(e, SyntaxError); | 51 assertInstanceof(e, SyntaxError); |
| 51 } | 52 } |
| 52 assertTrue(exception); | 53 assertTrue(exception); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 73 | 74 |
| 74 function strict4() { | 75 function strict4() { |
| 75 var exception = false; | 76 var exception = false; |
| 76 try { | 77 try { |
| 77 eval(code4); | 78 eval(code4); |
| 78 } catch (e) { | 79 } catch (e) { |
| 79 exception = true; | 80 exception = true; |
| 80 assertInstanceof(e, SyntaxError); | 81 assertInstanceof(e, SyntaxError); |
| 81 } | 82 } |
| 82 assertTrue(exception); | 83 assertTrue(exception); |
| 84 | |
| 85 function strict5() { | |
| 86 var exception = false; | |
| 87 try { | |
| 88 eval(code5); | |
| 89 } catch (e) { | |
| 90 exception = true; | |
| 91 assertInstanceof(e, SyntaxError); | |
| 92 } | |
| 93 assertTrue(exception); | |
| 94 } | |
| 95 strict5(); | |
| 83 } | 96 } |
| 84 strict4(); | 97 strict4(); |
| 85 } | 98 } |
| 86 strict3(); | 99 strict3(); |
| 87 } | 100 } |
| 88 strict2(); | 101 strict2(); |
| 89 } | 102 } |
| 90 strict1(); | 103 strict1(); |
| OLD | NEW |