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

Side by Side Diff: test/mjsunit/harmony/species.js

Issue 1558543002: Add a --harmony-species flag, defining @@species on constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 | « src/js/prologue.js ('k') | tools/gyp/v8.gyp » ('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 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-species
6
7 // Test the ES2015 @@species feature
8
9 'use strict';
10
11 let TypedArray = Uint8Array.__proto__;
12
13 // The @@species property exists on the right objects and has the right values
14
15 let classesWithSpecies = [RegExp, Array, TypedArray, ArrayBuffer, Map, Set, Prom ise];
16 let classesWithoutSpecies = [Object, Function, String, Number, Symbol, WeakMap, WeakSet];
17
18 for (let constructor of classesWithSpecies) {
19 assertEquals(constructor, constructor[Symbol.species]);
20 assertThrows(function() { constructor[Symbol.species] = undefined }, TypeError );
21 let descriptor = Object.getOwnPropertyDescriptor(constructor, Symbol.species);
22 assertTrue(descriptor.configurable);
23 assertFalse(descriptor.enumerable);
24 assertEquals(undefined, descriptor.writable);
25 assertEquals(undefined, descriptor.set);
26 assertEquals('function', typeof descriptor.get);
27 }
28
29 // @@species is defined with distinct getters
30 assertEquals(classesWithSpecies.length,
31 new Set(classesWithSpecies.map(constructor =>
32 Object.getOwnPropertyDescriptor(
33 constructor, Symbol.species).get)
34 ).size);
35
36 for (let constructor of classesWithoutSpecies)
37 assertEquals(undefined, constructor[Symbol.species]);
OLDNEW
« no previous file with comments | « src/js/prologue.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698