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

Side by Side Diff: test/mjsunit/harmony/classes-subclass-arrays.js

Issue 1213813003: [es6] Remove harmony-classes flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove empty flags field from json Created 5 years, 5 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
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-classes
6 'use strict';
7
8 (function TestDefaultConstructor() {
9 class Stack extends Array { }
10 {
11 let s1 = new Stack();
12 assertSame(Stack.prototype, s1.__proto__);
13 assertTrue(Array.isArray(s1));
14 assertSame(0, s1.length);
15 s1[0] = 'xyz';
16 assertSame(1, s1.length);
17 assertSame('xyz', s1[0]);
18 s1.push(42);
19 assertSame(2, s1.length);
20 assertSame('xyz', s1[0]);
21 assertSame(42, s1[1]);
22 }
23
24 {
25 let s2 = new Stack(10);
26 assertSame(Stack.prototype, s2.__proto__);
27 assertTrue(Array.isArray(s2));
28 assertSame(10, s2.length);
29 assertSame(undefined, s2[0]);
30 }
31
32 {
33 let a = [1,2,3];
34 let s3 = new Stack(a);
35 assertSame(Stack.prototype, s3.__proto__);
36 assertTrue(Array.isArray(s3));
37 assertSame(1, s3.length);
38 assertSame(a, s3[0]);
39 }
40
41 {
42 let s4 = new Stack(1, 2, 3);
43 assertSame(Stack.prototype, s4.__proto__);
44 assertTrue(Array.isArray(s4));
45 assertSame(3, s4.length);
46 assertSame(1, s4[0]);
47 assertSame(2, s4[1]);
48 assertSame(3, s4[2]);
49 }
50
51 {
52 let s5 = new Stack(undefined, undefined, undefined);
53 assertSame(Stack.prototype, s5.__proto__);
54 assertTrue(Array.isArray(s5));
55 assertSame(3, s5.length);
56 assertSame(undefined, s5[0]);
57 assertSame(undefined, s5[1]);
58 assertSame(undefined, s5[2]);
59 }
60 }());
61
62
63 (function TestEmptyArgsSuper() {
64 class Stack extends Array {
65 constructor() { super(); }
66 }
67 let s1 = new Stack();
68 assertSame(Stack.prototype, s1.__proto__);
69 assertTrue(Array.isArray(s1));
70 assertSame(0, s1.length);
71 s1[0] = 'xyz';
72 assertSame(1, s1.length);
73 assertSame('xyz', s1[0]);
74 s1.push(42);
75 assertSame(2, s1.length);
76 assertSame('xyz', s1[0]);
77 assertSame(42, s1[1]);
78 }());
79
80
81 (function TestOneArgSuper() {
82 class Stack extends Array {
83 constructor(x) {
84 super(x);
85 }
86 }
87
88 {
89 let s2 = new Stack(10, 'ignored arg');
90 assertSame(Stack.prototype, s2.__proto__);
91 assertTrue(Array.isArray(s2));
92 assertSame(10, s2.length);
93 assertSame(undefined, s2[0]);
94 }
95
96 {
97 let a = [1,2,3];
98 let s3 = new Stack(a, 'ignored arg');
99 assertSame(Stack.prototype, s3.__proto__);
100 assertTrue(Array.isArray(s3));
101 assertSame(1, s3.length);
102 assertSame(a, s3[0]);
103 }
104 }());
105
106
107 (function TestMultipleArgsSuper() {
108 class Stack extends Array {
109 constructor(x, y, z) {
110 super(x, y, z);
111 }
112 }
113 {
114 let s4 = new Stack(1, 2, 3, 4, 5);
115 assertSame(Stack.prototype, s4.__proto__);
116 assertTrue(Array.isArray(s4));
117 assertSame(3, s4.length);
118 assertSame(1, s4[0]);
119 assertSame(2, s4[1]);
120 assertSame(3, s4[2]);
121 }
122
123 {
124 let s5 = new Stack(undefined);
125 assertSame(Stack.prototype, s5.__proto__);
126 assertTrue(Array.isArray(s5));
127 assertTrue(s5.__proto__ == Stack.prototype);
128 assertSame(3, s5.length);
129 assertSame(undefined, s5[0]);
130 assertSame(undefined, s5[1]);
131 assertSame(undefined, s5[2]);
132 }
133 }());
134
135
136 (function TestArrayConcat() {
137 class Stack extends Array { }
138 let s1 = new Stack(1,2,3);
139
140 assertArrayEquals([1,2,3,4,5,6], s1.concat([4,5,6]));
141 assertArrayEquals([4,5,6,1,2,3], [4,5,6].concat(s1));
142 }());
143
144
145 (function TestJSONStringify() {
146 class Stack extends Array { }
147
148 let s1 = new Stack(1,2,3);
149 assertSame("[1,2,3]", JSON.stringify(s1));
150 }());
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/classes-maps.js ('k') | test/mjsunit/harmony/computed-property-names-classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698