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

Side by Side Diff: test/mjsunit/harmony/array-of.js

Issue 851163007: Implement IsConstructor() abstract operation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: All raw pointers converted to handles Created 5 years, 11 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/array-from.js ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/s ource/js/src/jit-test/tests/collections 5 // Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/s ource/js/src/jit-test/tests/collections
6 6
7 // Flags: --harmony-arrays 7 // Flags: --harmony-arrays
8 8
9 9
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 var desc = Object.getOwnPropertyDescriptor(Array, "of"); 153 var desc = Object.getOwnPropertyDescriptor(Array, "of");
154 154
155 assertEquals(desc.configurable, true); 155 assertEquals(desc.configurable, true);
156 assertEquals(desc.enumerable, false); 156 assertEquals(desc.enumerable, false);
157 assertEquals(desc.writable, true); 157 assertEquals(desc.writable, true);
158 assertEquals(Array.of.length, 0); 158 assertEquals(Array.of.length, 0);
159 assertThrows(function() { new Array.of() }, TypeError); // not a constructor 159 assertThrows(function() { new Array.of() }, TypeError); // not a constructor
160 160
161 // When the this-value passed in is not a constructor, the result is an array. 161 // When the this-value passed in is not a constructor, the result is an array.
162 [undefined, null, false, "cow"].forEach(function(val) { 162 [
163 assertEquals(Array.isArray(Array.of(val)), true); 163 undefined,
164 null,
165 false,
166 "cow",
167 NaN,
168 67,
169 Infinity,
170 -Infinity,
171 Math.cos, // builtin functions with no [[Construct]] slot
172 Math.cos.bind(Math) // bound builtin functions with no [[Construct]] slot
173 ].forEach(function(val) {
174 assertEquals(Array.isArray(Array.of.call(val, val)), true);
164 }); 175 });
176
177
178 (function testBoundConstructor() {
179 var boundFn = (function() {}).bind(null);
180 var instance = Array.of.call(boundFn, 1, 2, 3);
181 assertEquals(instance.length, 3);
182 assertEquals(instance instanceof boundFn, true);
183 assertEquals(Array.isArray(instance), false);
184 })();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/array-from.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698