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

Side by Side Diff: test/mjsunit/modules-namespace1.js

Issue 2578053003: [modules] Remove @@iterator on namespace objects. (Closed)
Patch Set: Skip out-of-date tests262 tests. Created 4 years 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
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 // MODULE 5 // MODULE
6 6
7 let ja = 42; 7 let ja = 42;
8 export {ja as yo}; 8 export {ja as yo};
9 export const bla = "blaa"; 9 export const bla = "blaa";
10 export {foo as foo_again}; 10 export {foo as foo_again};
11 // See further below for the actual star import that declares "foo". 11 // See further below for the actual star import that declares "foo".
12 12
13 // The object itself. 13 // The object itself.
14 assertEquals("object", typeof foo); 14 assertEquals("object", typeof foo);
15 assertThrows(() => foo = 666, TypeError); 15 assertThrows(() => foo = 666, TypeError);
16 assertFalse(Reflect.isExtensible(foo)); 16 assertFalse(Reflect.isExtensible(foo));
17 assertTrue(Reflect.preventExtensions(foo)); 17 assertTrue(Reflect.preventExtensions(foo));
18 assertThrows(() => Reflect.apply(foo, {}, [])); 18 assertThrows(() => Reflect.apply(foo, {}, []));
19 assertThrows(() => Reflect.construct(foo, {}, [])); 19 assertThrows(() => Reflect.construct(foo, {}, []));
20 assertSame(null, Reflect.getPrototypeOf(foo)); 20 assertSame(null, Reflect.getPrototypeOf(foo));
21 assertTrue(Reflect.setPrototypeOf(foo, null)); 21 assertTrue(Reflect.setPrototypeOf(foo, null));
22 assertFalse(Reflect.setPrototypeOf(foo, {})); 22 assertFalse(Reflect.setPrototypeOf(foo, {}));
23 assertSame(null, Reflect.getPrototypeOf(foo)); 23 assertSame(null, Reflect.getPrototypeOf(foo));
24 assertEquals( 24 assertEquals(
25 ["bla", "foo_again", "yo", Symbol.toStringTag, Symbol.iterator], 25 ["bla", "foo_again", "yo", Symbol.toStringTag], Reflect.ownKeys(foo));
26 Reflect.ownKeys(foo));
27 26
28 // Its "yo" property. 27 // Its "yo" property.
29 assertEquals( 28 assertEquals(
30 {value: 42, enumerable: true, configurable: false, writable: true}, 29 {value: 42, enumerable: true, configurable: false, writable: true},
31 Reflect.getOwnPropertyDescriptor(foo, "yo")); 30 Reflect.getOwnPropertyDescriptor(foo, "yo"));
32 assertFalse(Reflect.deleteProperty(foo, "yo")); 31 assertFalse(Reflect.deleteProperty(foo, "yo"));
33 assertTrue(Reflect.has(foo, "yo")); 32 assertTrue(Reflect.has(foo, "yo"));
34 assertFalse(Reflect.set(foo, "yo", true)); 33 assertFalse(Reflect.set(foo, "yo", true));
35 // TODO(neis): The next two should be False. 34 // TODO(neis): The next two should be False.
36 assertTrue(Reflect.defineProperty(foo, "yo", 35 assertTrue(Reflect.defineProperty(foo, "yo",
37 Reflect.getOwnPropertyDescriptor(foo, "yo"))); 36 Reflect.getOwnPropertyDescriptor(foo, "yo")));
38 assertTrue(Reflect.defineProperty(foo, "yo", {})); 37 assertTrue(Reflect.defineProperty(foo, "yo", {}));
39 assertFalse(Reflect.defineProperty(foo, "yo", {get() {return 1}})); 38 assertFalse(Reflect.defineProperty(foo, "yo", {get() {return 1}}));
40 assertEquals(42, Reflect.get(foo, "yo")); 39 assertEquals(42, Reflect.get(foo, "yo"));
41 assertEquals(43, (ja++, foo.yo)); 40 assertEquals(43, (ja++, foo.yo));
42 41
43 // Its "foo_again" property. 42 // Its "foo_again" property.
44 assertSame(foo, foo.foo_again); 43 assertSame(foo, foo.foo_again);
45 44
46 // Its @@toStringTag property. 45 // Its @@toStringTag property.
47 assertTrue(Reflect.has(foo, Symbol.toStringTag)); 46 assertTrue(Reflect.has(foo, Symbol.toStringTag));
48 assertEquals("string", typeof Reflect.get(foo, Symbol.toStringTag)); 47 assertEquals("string", typeof Reflect.get(foo, Symbol.toStringTag));
49 assertEquals( 48 assertEquals(
50 {value: "Module", configurable: true, writable: false, enumerable: false}, 49 {value: "Module", configurable: true, writable: false, enumerable: false},
51 Reflect.getOwnPropertyDescriptor(foo, Symbol.toStringTag)); 50 Reflect.getOwnPropertyDescriptor(foo, Symbol.toStringTag));
52 51
53 // Its @@iterator property.
54 assertTrue(Reflect.has(foo, Symbol.iterator));
55 assertEquals("function", typeof Reflect.get(foo, Symbol.iterator));
56 assertEquals("[Symbol.iterator]", foo[Symbol.iterator].name);
57 assertEquals(0, foo[Symbol.iterator].length);
58 assertSame(Function.prototype, foo[Symbol.iterator].__proto__);
59 assertEquals(
60 {value: foo[Symbol.iterator],
61 configurable: true, writable: true, enumerable: false},
62 Reflect.getOwnPropertyDescriptor(foo, Symbol.iterator));
63 assertEquals(["bla", "foo_again", "yo"], [...foo]);
64 assertThrows(() => (42, foo[Symbol.iterator])(), TypeError);
65 {
66 let it = foo[Symbol.iterator]();
67 assertSame(it.__proto__, ([][Symbol.iterator]()).__proto__.__proto__);
68 assertEquals(["next"], Reflect.ownKeys(it));
69 assertEquals(
70 {value: it.next, configurable: true, writable: true, enumerable: false},
71 Reflect.getOwnPropertyDescriptor(it, "next"));
72 assertEquals("function", typeof it.next);
73 assertEquals("next", it.next.name);
74 assertEquals(0, it.next.length);
75 assertSame(Function.prototype, it.next.__proto__);
76 assertFalse(it === foo[Symbol.iterator]());
77 assertFalse(it.next === foo[Symbol.iterator]().next);
78 assertThrows(() => (42, it.next)(), TypeError);
79 assertThrows(() => it.next.call(foo[Symbol.iterator]()), TypeError);
80 let next = it.next;
81 assertEquals(42, (it.next = 42, it.next));
82 assertEquals(43, (it.bla = 43, it.bla));
83 assertTrue(delete it.next);
84 assertThrows(() => next.call(foo[Symbol.iterator]()), TypeError);
85 }
86
87 // TODO(neis): Clarify spec w.r.t. other symbols. 52 // TODO(neis): Clarify spec w.r.t. other symbols.
88 53
89 // Nonexistant properties. 54 // Nonexistant properties.
90 let nonexistant = ["gaga", 123, Symbol('')]; 55 let nonexistant = ["gaga", 123, Symbol('')];
91 for (let key of nonexistant) { 56 for (let key of nonexistant) {
92 assertSame(undefined, Reflect.getOwnPropertyDescriptor(foo, key)); 57 assertSame(undefined, Reflect.getOwnPropertyDescriptor(foo, key));
93 assertTrue(Reflect.deleteProperty(foo, key)); 58 assertTrue(Reflect.deleteProperty(foo, key));
94 assertFalse(Reflect.set(foo, key, true)); 59 assertFalse(Reflect.set(foo, key, true));
95 assertSame(undefined, Reflect.get(foo, key)); 60 assertSame(undefined, Reflect.get(foo, key));
96 assertFalse(Reflect.defineProperty(foo, key, {get() {return 1}})); 61 assertFalse(Reflect.defineProperty(foo, key, {get() {return 1}}));
97 assertFalse(Reflect.has(foo, key)); 62 assertFalse(Reflect.has(foo, key));
98 } 63 }
99 64
100 // The actual star import that we are testing. Namespace imports are 65 // The actual star import that we are testing. Namespace imports are
101 // initialized before evaluation. 66 // initialized before evaluation.
102 import * as foo from "modules-namespace1.js"; 67 import * as foo from "modules-namespace1.js";
103 68
104 // There can be only one namespace object. 69 // There can be only one namespace object.
105 import * as bar from "modules-namespace1.js"; 70 import * as bar from "modules-namespace1.js";
106 assertSame(foo, bar); 71 assertSame(foo, bar);
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/SuperCallAndSpread.golden ('k') | test/mjsunit/modules-namespace2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698