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 // Flags: --harmony-object-spread --allow-natives-syntax | |
|
adamk
2017/01/05 22:39:14
No need for --allow-natives-syntax, that's only re
gsathya
2017/01/05 22:56:29
Done.
| |
| 6 | |
| 7 // assertEquals(42, proxy[symbol] = 42); | |
| 8 // assertThrows(function() { "use strict"; proxy[symbol] = 42 }, TypeError); | |
|
adamk
2017/01/05 22:39:14
What's up with these two lines?
gsathya
2017/01/05 22:56:29
copy paste fail
| |
| 9 | |
| 10 var x = {a: 1}; | |
| 11 var y = { ...x}; | |
| 12 assertEquals(x, y); | |
| 13 assertEquals(x, y = { ...x}); | |
|
adamk
2017/01/05 22:39:14
What is this testing that's different from the abo
gsathya
2017/01/05 22:56:29
testing AssignmentExpression actually, since i use
| |
| 14 | |
| 15 assertEquals({}, y = { ...{} } ); | |
| 16 assertEquals({}, y = { ...undefined }); | |
| 17 assertEquals({}, y = { ...null }); | |
| 18 | |
| 19 assertEquals({}, y = { ...1 }); | |
| 20 assertEquals({0: 'f', 1: 'o', 2: 'o'}, y = { ...'foo' }); | |
| 21 assertEquals({0: 0, 1: 1}, y = { ...[0, 1] }); | |
| 22 assertEquals({}, { ...new Proxy({}, {}) }); | |
| 23 | |
| 24 assertEquals({a: 2}, y = { ...x, a: 2 }); | |
| 25 assertEquals({a: 1, b: 1}, y = { ...x, b: 1 }); | |
| 26 assertEquals({a: 1}, y = { a: 2, ...x }); | |
| 27 assertEquals({a: 1, b: 1}, y = { a:2, ...x, b: 1 }); | |
| 28 assertEquals({a: 3}, y = { a: 2, ...x, a: 3 }); | |
| 29 | |
| 30 var z = { b: 1} | |
| 31 assertEquals({a: 1, b: 1}, y = { ...x, ...z }); | |
| 32 assertEquals({a: 1, b: 1}, y = { a: 2, ...x, ...z }); | |
| 33 assertEquals({a: 1, b: 1}, y = { b: 2, ...z, ...x }); | |
| 34 assertEquals({a: 1, b: 1}, y = { a: 1, ...x, b: 2, ...z }); | |
| 35 assertEquals({a: 1, b: 2}, y = { a: 1, ...x, ...z, b: 2 }); | |
| 36 assertEquals({a: 2, b: 2}, y = { ...x, ...z, a:2, b: 2 }); | |
| 37 | |
| 38 var x = {} | |
| 39 Object.defineProperty(x, 'a', { | |
| 40 enumerable: false, | |
| 41 configurable: false, | |
| 42 writable: false, | |
| 43 value: 1 | |
| 44 }); | |
| 45 assertEquals({}, { ...x }); | |
| 46 | |
| 47 var x = {} | |
| 48 Object.defineProperty(x, 'a', { | |
| 49 enumerable: true, | |
| 50 configurable: false, | |
| 51 writable: false, | |
| 52 value: 1 | |
| 53 }); | |
| 54 var y = { ...x }; | |
| 55 var prop = Object.getOwnPropertyDescriptor(y, 'a'); | |
| 56 assertEquals(prop.value, 1); | |
| 57 assertTrue(prop.enumerable); | |
| 58 assertTrue(prop.configurable); | |
| 59 assertTrue(prop.writable); | |
| 60 | |
| 61 var x = { __proto__: z } | |
| 62 assertEquals({}, { ...x }); | |
| 63 | |
| 64 var x = { [1+1]: 2, ['a']: 1}; | |
| 65 assertEquals({2: 2, a: 1}, y = { ...x }); | |
|
adamk
2017/01/05 22:39:14
Don't think you need this test, it's just testing
gsathya
2017/01/05 22:56:29
Done.
| |
| 66 | |
| 67 var x = { | |
| 68 get a() { return 1; }, | |
| 69 set a(_) { assertUnreachable("setter called"); }, | |
| 70 }; | |
| 71 assertEquals({ a: 1 }, y = { ...x }); | |
| 72 | |
| 73 var x = { | |
| 74 method() { return 1; }, | |
| 75 }; | |
| 76 assertEquals(x, y = { ...x }); | |
| 77 | |
| 78 var x = { | |
| 79 *gen() { return {value: 1, done: true} ; }, | |
| 80 }; | |
| 81 assertEquals(x, y = { ...x }); | |
| 82 | |
| 83 var x = { | |
| 84 get a() { throw new Error(); }, | |
| 85 }; | |
| 86 assertThrows(() => { y = { ...x } }); | |
| 87 | |
| 88 var p = new Proxy({}, { | |
| 89 ownKeys() { throw new Error(); } | |
| 90 }); | |
| 91 assertThrows(() => { y = { ...p } }); | |
| 92 | |
| 93 var p = new Proxy({}, { | |
| 94 ownKeys() { [1]; }, | |
| 95 get() { throw new Error(); } | |
| 96 }); | |
| 97 assertThrows(() => { y = { ...p } }); | |
| 98 | |
| 99 var p = new Proxy({}, { | |
| 100 ownKeys() { [1]; }, | |
| 101 getOwnPropertyDescriptor() { throw new Error(); } | |
| 102 }); | |
| 103 assertThrows(() => { y = { ...p } }); | |
|
adamk
2017/01/05 22:39:14
Can you also add a non-error, non-empty Proxy case
gsathya
2017/01/05 22:56:29
Done.
| |
| 104 | |
| 105 var x = { a:1 }; | |
| 106 assertEquals(x, y = { set a(_) { throw new Error(); }, ...x }); | |
| 107 | |
| 108 var x = { a:1 }; | |
| 109 assertEquals(x, y = { get a() { throw new Error(); }, ...x }); | |
| OLD | NEW |