Home | History | Annotate | Download | only in mjsunit

Lines Matching full:const

28 // Flags: --legacy-const
30 // Test for const semantics.
91 TestConflict("const x", "var x");
92 TestConflict("const x = 0", "var x");
93 TestConflict("const x", "var x = 0");
94 TestConflict("const x = 0", "var x = 0");
96 TestConflict("var x", "const x");
97 TestConflict("var x = 0", "const x");
98 TestConflict("var x", "const x = 0");
99 TestConflict("var x = 0", "const x = 0");
101 TestConflict("const x = undefined", "var x");
102 TestConflict("const x", "var x = undefined");
103 TestConflict("const x = undefined", "var x = undefined");
105 TestConflict("var x = undefined", "const x");
106 TestConflict("var x", "const x = undefined");
107 TestConflict("var x = undefined", "const x = undefined");
109 TestConflict("const x = undefined", "var x = 0");
110 TestConflict("const x = 0", "var x = undefined");
112 TestConflict("var x = undefined", "const x = 0");
113 TestConflict("var x = 0", "const x = undefined");
115 TestConflict("const x", "function x() { }");
116 TestConflict("const x = 0", "function x() { }");
117 TestConflict("const x = undefined", "function x() { }");
119 TestConflict("function x() { }", "const x");
120 TestConflict("function x() { }", "const x = 0");
121 TestConflict("function x() { }", "const x = undefined");
123 TestConflict("const x, y", "var x");
124 TestConflict("const x, y", "var y");
125 TestConflict("const x = 0, y", "var x");
126 TestConflict("const x = 0, y", "var y");
127 TestConflict("const x, y = 0", "var x");
128 TestConflict("const x, y = 0", "var y");
129 TestConflict("const x = 0, y = 0", "var x");
130 TestConflict("const x = 0, y = 0", "var y");
132 TestConflict("var x", "const x, y");
133 TestConflict("var y", "const x, y");
134 TestConflict("var x", "const x = 0, y");
135 TestConflict("var y", "const x = 0, y");
136 TestConflict("var x", "const x, y = 0");
137 TestConflict("var y", "const x, y = 0");
138 TestConflict("var x", "const x = 0, y = 0");
139 TestConflict("var y", "const x = 0, y = 0");
143 TestConflict("var x, y", "const x, y");
146 // Test that repeated const declarations throw redeclaration errors.
147 TestConflict("const x", "const x");
148 TestConflict("const x = 0", "const x");
149 TestConflict("const x", "const x = 0");
150 TestConflict("const x = 0", "const x = 0");
152 TestConflict("const x = undefined", "const x");
153 TestConflict("const x", "const x = undefined");
154 TestConflict("const x = undefined", "const x = undefined");
156 TestConflict("const x = undefined", "const x = 0");
157 TestConflict("const x = 0", "const x = undefined");
159 TestConflict("const x, y", "const x");
160 TestConflict("const x, y", "const y");
161 TestConflict("const x = 0, y", "const x");
162 TestConflict("const x = 0, y", "const y");
163 TestConflict("const x, y = 0", "const x");
164 TestConflict("const x, y = 0", "const y");
165 TestConflict("const x = 0, y = 0", "const x");
166 TestConflict("const x = 0, y = 0", "const y");
168 TestConflict("const x", "const x, y");
169 TestConflict("const y", "const x, y");
170 TestConflict("const x", "const x = 0, y");
171 TestConflict("const y", "const x = 0, y");
172 TestConflict("const x", "const x, y = 0");
173 TestConflict("const y", "const x, y = 0");
174 TestConflict("const x", "const x = 0, y = 0");
175 TestConflict("const y", "const x = 0, y = 0");
178 // Test that multiple const conflicts do not cause issues.
179 TestConflict("const x, y", "const x, y");
182 // Test that const inside loop behaves correctly.
183 var loop = "for (var i = 0; i < 3; i++) { const x = i; }";
188 // Test that const inside with behaves correctly.
189 TestAll(87, "with ({x:42}) { const x = 87; }", "x");
190 TestAll(undefined, "with ({x:42}) { const x; }", "x");
194 // the values of the var/const in question.
206 const e = 1; eval('var e = 2');
209 const h; eval('var h = 1');
213 + "const i = 7;"
219 // The const declaration stays configurable, so the declaration above goes
220 // through even though the const declaration is hoisted above.
221 const j = 2;
225 try { eval('const k'); } catch(e) { }
227 try { eval('const k = 10'); } catch(e) { }