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-reflect | 5 // Flags: --harmony-reflect |
6 | 6 |
7 // TODO(neis): Test with proxies. | 7 // TODO(neis): Test with proxies. |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 assertThrows(function() { Reflect.getOwnPropertyDescriptor(target, b); }, | 533 assertThrows(function() { Reflect.getOwnPropertyDescriptor(target, b); }, |
534 "gaga"); | 534 "gaga"); |
535 })(); | 535 })(); |
536 | 536 |
537 | 537 |
538 // See reflect-get-own-property-descriptor.js for further tests. | 538 // See reflect-get-own-property-descriptor.js for further tests. |
539 | 539 |
540 | 540 |
541 | 541 |
542 //////////////////////////////////////////////////////////////////////////////// | 542 //////////////////////////////////////////////////////////////////////////////// |
543 // Reflect.ownKeys | |
544 | |
545 | |
546 (function testReflectOwnKeysArity() { | |
547 assertEquals(1, Reflect.ownKeys.length); | |
548 })(); | |
549 | |
550 | |
551 (function testReflectOwnKeysOnNonObject() { | |
552 assertThrows(function() { Reflect.ownKeys(); }, TypeError); | |
553 assertThrows(function() { Reflect.ownKeys(42); }, TypeError); | |
554 assertThrows(function() { Reflect.ownKeys(null); }, TypeError); | |
555 })(); | |
556 | |
557 | |
558 (function testReflectOwnKeysOnObject(){ | |
559 assertEquals(["z", "y", "x"], Reflect.ownKeys({z: 3, y: 2, x: 1})); | |
560 assertEquals(["length"], Reflect.ownKeys([])); | |
561 | |
562 var s1 = Symbol("foo"); | |
563 var s2 = Symbol("bar"); | |
564 var obj = { [s1]: 0, "bla": 0, 42: 0, "0": 0, | |
565 [s2]: 0, "-1": 0, "88": 0, "aaa": 0 }; | |
566 assertEquals(["0", "42", "88", "bla", "-1", "aaa", s1, s2], | |
567 Reflect.ownKeys(obj)); | |
568 })(); | |
569 | |
570 | |
571 // See reflect-own-keys.js for further tests. | |
572 | |
573 | |
574 | |
575 //////////////////////////////////////////////////////////////////////////////// | |
576 // Reflect.preventExtensions | 543 // Reflect.preventExtensions |
577 | 544 |
578 | 545 |
579 (function testReflectPreventExtensionsArity() { | 546 (function testReflectPreventExtensionsArity() { |
580 assertEquals(1, Reflect.preventExtensions.length); | 547 assertEquals(1, Reflect.preventExtensions.length); |
581 })(); | 548 })(); |
582 | 549 |
583 | 550 |
584 (function testReflectPreventExtensionsOnNonObject() { | 551 (function testReflectPreventExtensionsOnNonObject() { |
585 assertThrows(function() { Reflect.preventExtensions(); }, TypeError); | 552 assertThrows(function() { Reflect.preventExtensions(); }, TypeError); |
586 assertThrows(function() { Reflect.preventExtensions(42); }, TypeError); | 553 assertThrows(function() { Reflect.preventExtensions(42); }, TypeError); |
587 assertThrows(function() { Reflect.preventExtensions(null); }, TypeError); | 554 assertThrows(function() { Reflect.preventExtensions(null); }, TypeError); |
588 })(); | 555 })(); |
589 | 556 |
590 | 557 |
591 // See reflect-prevent-extensions.js for further tests. | 558 // See reflect-prevent-extensions.js for further tests. |
592 | 559 |
593 // TODO(neis): Need proxies to test the situation where | 560 // TODO(neis): Need proxies to test the situation where |
594 // [[preventExtensions]] returns false. | 561 // [[preventExtensions]] returns false. |
OLD | NEW |