OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 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 // Flags: --harmony-proxies --harmony-reflect | 5 // Flags: --harmony-proxies --harmony-reflect --allow-natives-syntax |
6 | 6 |
7 | 7 |
8 function sloppyDefaultSet(o, p, v) { return o[p] = v } | 8 function sloppyDefaultSet(o, p, v) { return o[p] = v } |
9 function sloppyReflectSet(o, p, v) { return Reflect.set(o, p, v) } | 9 function sloppyReflectSet(o, p, v) { return Reflect.set(o, p, v) } |
10 function strictDefaultSet(o, p, v) { "use strict"; return o[p] = v } | 10 function strictDefaultSet(o, p, v) { "use strict"; return o[p] = v } |
11 function strictReflectSet(o, p, v) { "use strict"; return Reflect.set(o, p, v) } | 11 function strictReflectSet(o, p, v) { "use strict"; return Reflect.set(o, p, v) } |
12 | 12 |
13 sloppyDefaultSet.shouldThrow = false; | 13 sloppyDefaultSet.shouldThrow = false; |
14 sloppyReflectSet.shouldThrow = false; | 14 sloppyReflectSet.shouldThrow = false; |
15 strictDefaultSet.shouldThrow = true; | 15 strictDefaultSet.shouldThrow = true; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 for (var receiver of [null, undefined, 1]) { | 303 for (var receiver of [null, undefined, 1]) { |
304 Reflect.set(object, p, 42, receiver); | 304 Reflect.set(object, p, 42, receiver); |
305 assertEquals(1, observations.length); | 305 assertEquals(1, observations.length); |
306 assertArrayEquals([target, toKey(p), 42, receiver], observations[0]); | 306 assertArrayEquals([target, toKey(p), 42, receiver], observations[0]); |
307 assertSame(target, observations[0][0]); | 307 assertSame(target, observations[0][0]); |
308 assertSame(receiver, observations[0][3]); | 308 assertSame(receiver, observations[0][3]); |
309 observations = []; | 309 observations = []; |
310 } | 310 } |
311 } | 311 } |
312 })(); | 312 })(); |
| 313 |
| 314 |
| 315 (function testSetPrivateSymbol() { |
| 316 var symbol = %CreatePrivateSymbol("secret"); |
| 317 var O = {}; |
| 318 var proxy = new Proxy(O, { set(t, name, val) { assertUnreachable(); }}); |
| 319 O[symbol] = "value"; |
| 320 proxy[symbol] = "value"; |
| 321 assertEquals(undefined, proxy[symbol]); |
| 322 assertEquals(false, Reflect.set(proxy, symbol, "otherValue")); |
| 323 assertEquals("value", O[symbol]); |
| 324 assertEquals(true, Reflect.set(O, symbol, "otherValue")); |
| 325 })(); |
OLD | NEW |