Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: test/mjsunit/strict-mode-eval.js

Issue 2185223002: Fix not throwing error when redefine eval or arguments in strict mode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« test/cctest/test-parsing.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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();
OLDNEW
« test/cctest/test-parsing.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698