| 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: --allow-natives-syntax --harmony-reflect --harmony-regexp-subclass | 5 // Flags: --allow-natives-syntax --harmony-reflect --harmony-regexp-subclass |
| 6 // Flags: --expose-gc --strong-mode | 6 // Flags: --expose-gc --strong-mode |
| 7 | 7 |
| 8 "use strict"; | 8 "use strict"; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 gc(); | 72 gc(); |
| 73 })(); | 73 })(); |
| 74 | 74 |
| 75 | 75 |
| 76 (function() { | 76 (function() { |
| 77 class A extends Function { | 77 class A extends Function { |
| 78 constructor(...args) { | 78 constructor(...args) { |
| 79 assertFalse(new.target === undefined); | 79 assertFalse(new.target === undefined); |
| 80 super(...args); | 80 super(...args); |
| 81 // Strong functions are not extensible, so don't add fields. | |
| 82 if (args[args.length - 1].indexOf("use strong") >= 0) { | |
| 83 assertThrows(()=>{ this.a = 10; }, TypeError); | |
| 84 return; | |
| 85 } | |
| 86 this.a = 42; | 81 this.a = 42; |
| 87 this.d = 4.2; | 82 this.d = 4.2; |
| 88 this.o = {foo:153}; | 83 this.o = {foo:153}; |
| 89 } | 84 } |
| 90 } | 85 } |
| 91 var sloppy_func = new A(""); | 86 var sloppy_func = new A(""); |
| 92 var strict_func = new A("'use strict';"); | 87 var strict_func = new A("'use strict';"); |
| 93 assertNull(sloppy_func.caller); | 88 assertNull(sloppy_func.caller); |
| 94 assertThrows("strict_f.caller"); | 89 assertThrows("strict_f.caller"); |
| 95 assertNull(Object.getOwnPropertyDescriptor(sloppy_func, "caller").value); | 90 assertNull(Object.getOwnPropertyDescriptor(sloppy_func, "caller").value); |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 assertTrue(%HaveSameMap(sloppy_func, sloppy_func1)); | 647 assertTrue(%HaveSameMap(sloppy_func, sloppy_func1)); |
| 653 | 648 |
| 654 // Strict generator function | 649 // Strict generator function |
| 655 var strict_func = new A("'use strict'; " + source); | 650 var strict_func = new A("'use strict'; " + source); |
| 656 assertFalse(%HaveSameMap(strict_func, sloppy_func)); | 651 assertFalse(%HaveSameMap(strict_func, sloppy_func)); |
| 657 CheckFunction(strict_func, false); | 652 CheckFunction(strict_func, false); |
| 658 | 653 |
| 659 var strict_func1 = new A("'use strict'; yield 312;"); | 654 var strict_func1 = new A("'use strict'; yield 312;"); |
| 660 assertTrue(%HaveSameMap(strict_func, strict_func1)); | 655 assertTrue(%HaveSameMap(strict_func, strict_func1)); |
| 661 | 656 |
| 662 // Strong generator function | |
| 663 var strong_func = new A("'use strong'; " + source); | |
| 664 assertFalse(%HaveSameMap(strong_func, sloppy_func)); | |
| 665 assertFalse(%HaveSameMap(strong_func, strict_func)); | |
| 666 CheckFunction(strong_func, true); | |
| 667 | |
| 668 var strong_func1 = new A("'use strong'; yield 312;"); | |
| 669 assertTrue(%HaveSameMap(strong_func, strong_func1)); | |
| 670 | |
| 671 gc(); | 657 gc(); |
| 672 })(); | 658 })(); |
| 673 | 659 |
| 674 | 660 |
| 675 (function() { | 661 (function() { |
| 676 class A extends Promise { | 662 class A extends Promise { |
| 677 constructor(...args) { | 663 constructor(...args) { |
| 678 assertFalse(new.target === undefined); | 664 assertFalse(new.target === undefined); |
| 679 super(...args); | 665 super(...args); |
| 680 this.a = 42; | 666 this.a = 42; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 | 933 |
| 948 Object.defineProperty(pattern, Symbol.match, { | 934 Object.defineProperty(pattern, Symbol.match, { |
| 949 get() { log.push("match"); f.prototype = p2; return false; }}); | 935 get() { log.push("match"); f.prototype = p2; return false; }}); |
| 950 | 936 |
| 951 var o = Reflect.construct(RegExp, [pattern], f); | 937 var o = Reflect.construct(RegExp, [pattern], f); |
| 952 assertEquals(["match", "tostring"], log); | 938 assertEquals(["match", "tostring"], log); |
| 953 assertEquals(/biep/, o); | 939 assertEquals(/biep/, o); |
| 954 assertTrue(o.__proto__ === p2); | 940 assertTrue(o.__proto__ === p2); |
| 955 assertTrue(f.prototype === p3); | 941 assertTrue(f.prototype === p3); |
| 956 })(); | 942 })(); |
| OLD | NEW |