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

Side by Side Diff: test/mjsunit/harmony/reflect.js

Issue 1405243006: [es6] Partially implement Reflect.ownKeys. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 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
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 ////////////////////////////////////////////////////////////////////////////////
543 // Reflect.preventExtensions 576 // Reflect.preventExtensions
544 577
545 578
546 (function testReflectPreventExtensionsArity() { 579 (function testReflectPreventExtensionsArity() {
547 assertEquals(1, Reflect.preventExtensions.length); 580 assertEquals(1, Reflect.preventExtensions.length);
548 })(); 581 })();
549 582
550 583
551 (function testReflectPreventExtensionsOnNonObject() { 584 (function testReflectPreventExtensionsOnNonObject() {
552 assertThrows(function() { Reflect.preventExtensions(); }, TypeError); 585 assertThrows(function() { Reflect.preventExtensions(); }, TypeError);
553 assertThrows(function() { Reflect.preventExtensions(42); }, TypeError); 586 assertThrows(function() { Reflect.preventExtensions(42); }, TypeError);
554 assertThrows(function() { Reflect.preventExtensions(null); }, TypeError); 587 assertThrows(function() { Reflect.preventExtensions(null); }, TypeError);
555 })(); 588 })();
556 589
557 590
558 // See reflect-prevent-extensions.js for further tests. 591 // See reflect-prevent-extensions.js for further tests.
559 592
560 // TODO(neis): Need proxies to test the situation where 593 // TODO(neis): Need proxies to test the situation where
561 // [[preventExtensions]] returns false. 594 // [[preventExtensions]] returns false.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698