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

Side by Side Diff: test/mjsunit/harmony/block-const-assign.js

Issue 1007783002: Remove --harmony-scoping flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CR feedback Created 5 years, 9 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
« no previous file with comments | « test/mjsunit/harmony/block-conflicts.js ('k') | test/mjsunit/harmony/block-early-errors.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 // Flags: --harmony-scoping --harmony-computed-property-names
29
30 // Test that we throw early syntax errors in harmony mode
31 // when using an immutable binding in an assigment or with
32 // prefix/postfix decrement/increment operators.
33
34 "use strict";
35
36 const decls = [
37 // Const declaration.
38 function(use) { return "const c = 1; " + use + ";" }, TypeError,
39 function(use) { return "const x = 0, c = 1; " + use + ";" }, TypeError,
40 function(use) { return "const c = 1, x = (" + use + ");" }, TypeError,
41 function(use) { return use + "; const c = 1;" }, ReferenceError,
42 function(use) { return use + "; const x = 0, c = 1;" }, ReferenceError,
43 function(use) { return "const x = (" + use + "), c = 1;" }, ReferenceError,
44 function(use) { return "const c = (" + use + ");" }, ReferenceError,
45
46 // Function expression.
47 function(use) { return "(function c() { " + use + "; })();"; }, TypeError,
48 // TODO(rossberg): Once we have default parameters, test using 'c' there.
49
50 // Class expression.
51 function(use) {
52 return "new class c { constructor() { " + use + " } };";
53 }, TypeError,
54 function(use) {
55 return "(new class c { m() { " + use + " } }).m();";
56 }, TypeError,
57 function(use) {
58 return "(new class c { get a() { " + use + " } }).a;";
59 }, TypeError,
60 function(use) {
61 return "(new class c { set a(x) { " + use + " } }).a = 0;";
62 }, TypeError,
63 function(use) {
64 return "(class c { static m() { " + use + " } }).s();";
65 }, TypeError,
66 function(use) {
67 return "(class c extends (" + use + ") {});";
68 }, ReferenceError,
69 function(use) {
70 return "(class c { [" + use + "]() {} });";
71 }, ReferenceError,
72 function(use) {
73 return "(class c { get [" + use + "]() {} });";
74 }, ReferenceError,
75 function(use) {
76 return "(class c { set [" + use + "](x) {} });";
77 }, ReferenceError,
78 function(use) {
79 return "(class c { static [" + use + "]() {} });";
80 }, ReferenceError,
81
82 // For loop.
83 function(use) {
84 return "for (const c = 0; " + use + ";) {}"
85 }, TypeError,
86 function(use) {
87 return "for (const x = 0, c = 0; " + use + ";) {}"
88 }, TypeError,
89 function(use) {
90 return "for (const c = 0; ; " + use + ") {}"
91 }, TypeError,
92 function(use) {
93 return "for (const x = 0, c = 0; ; " + use + ") {}"
94 }, TypeError,
95 function(use) {
96 return "for (const c = 0; ;) { " + use + "; }"
97 }, TypeError,
98 function(use) {
99 return "for (const x = 0, c = 0; ;) { " + use + "; }"
100 }, TypeError,
101 function(use) {
102 return "for (const c in {a: 1}) { " + use + "; }"
103 }, TypeError,
104 function(use) {
105 return "for (const c of [1]) { " + use + "; }"
106 }, TypeError,
107 function(use) {
108 return "for (const x = (" + use + "), c = 0; ;) {}"
109 }, ReferenceError,
110 function(use) {
111 return "for (const c = (" + use + "); ;) {}"
112 }, ReferenceError,
113 ]
114
115 let uses = [
116 'c = 1',
117 'c += 1',
118 '++c',
119 'c--',
120 ];
121
122 let declcontexts = [
123 function(decl) { return decl; },
124 function(decl) { return "eval(\'" + decl + "\')"; },
125 function(decl) { return "{ " + decl + " }"; },
126 function(decl) { return "(function() { " + decl + " })()"; },
127 ];
128
129 let usecontexts = [
130 function(use) { return use; },
131 function(use) { return "eval(\"" + use + "\")"; },
132 function(use) { return "(function() { " + use + " })()"; },
133 function(use) { return "(function() { eval(\"" + use + "\"); })()"; },
134 function(use) { return "eval(\"(function() { " + use + "; })\")()"; },
135 ];
136
137 function Test(program, error) {
138 program = "'use strict'; " + program;
139 try {
140 print(program, " // throw " + error.name);
141 eval(program);
142 } catch (e) {
143 assertInstanceof(e, error);
144 if (e === TypeError) {
145 assertTrue(e.toString().indexOf("Assignment to constant variable") >= 0);
146 }
147 return;
148 }
149 assertUnreachable();
150 }
151
152 for (var d = 0; d < decls.length; d += 2) {
153 for (var u = 0; u < uses.length; ++u) {
154 for (var o = 0; o < declcontexts.length; ++o) {
155 for (var i = 0; i < usecontexts.length; ++i) {
156 Test(declcontexts[o](decls[d](usecontexts[i](uses[u]))), decls[d + 1]);
157 }
158 }
159 }
160 }
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/block-conflicts.js ('k') | test/mjsunit/harmony/block-early-errors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698