Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // MODULE | |
| 6 | |
| 7 let ja = 42; | |
| 8 export {ja as yo}; | |
| 9 export const bla = "blaa"; | |
| 10 export {foo as foo_again}; | |
| 11 // See further below for the actual star import that declares "foo". | |
| 12 | |
| 13 // The object itself. | |
| 14 assertEquals("object", typeof foo); | |
| 15 assertThrows(() => foo = 666, TypeError); | |
| 16 assertFalse(Reflect.isExtensible(foo)); | |
| 17 assertTrue(Reflect.preventExtensions(foo)); | |
| 18 assertThrows(() => Reflect.apply(foo, {}, [])); | |
| 19 assertThrows(() => Reflect.construct(foo, {}, [])); | |
| 20 assertSame(null, Reflect.getPrototypeOf(foo)); | |
| 21 // assertFalse(Reflect.setPrototypeOf(foo, null)); | |
|
adamk
2016/10/04 18:26:53
Can you change this assertion to assertTrue and ad
neis
2016/10/05 08:18:42
Done.
| |
| 22 assertFalse(Reflect.setPrototypeOf(foo, {})); | |
| 23 assertSame(null, Reflect.getPrototypeOf(foo)); | |
| 24 assertEquals( | |
| 25 ["bla", "foo_again", "yo", Symbol.toStringTag], | |
| 26 // , Symbol.iterator], | |
|
adamk
2016/10/04 18:26:53
Please add a TODO here.
neis
2016/10/05 08:18:42
Done.
| |
| 27 Reflect.ownKeys(foo)); | |
| 28 | |
| 29 // Its "yo" property. | |
| 30 assertEquals( | |
| 31 {value: 42, enumerable: true, configurable: false, writable: true}, | |
| 32 Reflect.getOwnPropertyDescriptor(foo, "yo")); | |
| 33 assertFalse(Reflect.deleteProperty(foo, "yo")); | |
| 34 assertTrue(Reflect.has(foo, "yo")); | |
| 35 // assertFalse(Reflect.set(foo, "yo", true)); | |
| 36 // assertFalse(Reflect.defineProperty(foo, "yo", | |
| 37 // Reflect.getOwnPropertyDescriptor(foo, "yo"))); | |
| 38 // assertFalse(Reflect.defineProperty(foo, "yo", {})); | |
|
adamk
2016/10/04 18:26:53
Please add a TODO above this block of asserts; I a
neis
2016/10/05 08:18:42
Yes, it's the setter issue. Will create a bug repo
| |
| 39 assertFalse(Reflect.defineProperty(foo, "yo", {get() {return 1}})); | |
| 40 assertEquals(42, Reflect.get(foo, "yo")); | |
| 41 assertEquals(43, (ja++, foo.yo)); | |
| 42 | |
| 43 // Its "foo_again" property. | |
| 44 assertSame(foo, foo.foo_again); | |
| 45 | |
| 46 // Its @@toStringTag property. | |
| 47 assertTrue(Reflect.has(foo, Symbol.toStringTag)); | |
| 48 assertEquals("string", typeof Reflect.get(foo, Symbol.toStringTag)); | |
| 49 assertEquals( | |
| 50 {value: "Module", configurable: true, writable: false, enumerable: false}, | |
| 51 Reflect.getOwnPropertyDescriptor(foo, Symbol.toStringTag)); | |
| 52 | |
| 53 // Its @@iterator property. | |
| 54 // assertTrue(Reflect.has(foo, Symbol.iterator)); | |
| 55 // assert("function", typeof Reflect.get(foo, Symbol.iterator)); | |
| 56 // assertEquals(["bla", "yo"], [...foo]); | |
| 57 // assertThrows(() => (42, foo[Symbol.iterator])(), TypeError); | |
| 58 // assertSame(foo[Symbol.iterator]().__proto__, | |
| 59 // ([][Symbol.iterator]()).__proto__.__proto__); | |
| 60 | |
| 61 // TODO(neis): Clarify spec w.r.t. other symbols. | |
| 62 | |
| 63 // Nonexistant properties. | |
| 64 let nonexistant = ["gaga", 123, Symbol('')]; | |
| 65 for (let key of nonexistant) { | |
| 66 assertSame(undefined, Reflect.getOwnPropertyDescriptor(foo, key)); | |
| 67 assertTrue(Reflect.deleteProperty(foo, key)); | |
| 68 assertFalse(Reflect.set(foo, key, true)); | |
| 69 assertSame(undefined, Reflect.get(foo, key)); | |
| 70 assertFalse(Reflect.defineProperty(foo, key, {get() {return 1}})); | |
| 71 assertFalse(Reflect.has(foo, key)); | |
| 72 } | |
| 73 | |
| 74 // The actual star import that we are testing. Namespace imports are | |
| 75 // initialized before evaluation | |
| 76 import * as foo from "modules-namespace1.js"; | |
| 77 | |
| 78 // There can be only one namespace object. | |
| 79 import * as bar from "modules-namespace1.js"; | |
| 80 assertSame(foo, bar); | |
| OLD | NEW |