OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 f_own_property_names.sort(); | 48 f_own_property_names.sort(); |
49 g_own_property_names.sort(); | 49 g_own_property_names.sort(); |
50 | 50 |
51 assertArrayEquals(f_own_property_names, g_own_property_names); | 51 assertArrayEquals(f_own_property_names, g_own_property_names); |
52 var i; | 52 var i; |
53 for (i = 0; i < f_own_property_names.length; i++) { | 53 for (i = 0; i < f_own_property_names.length; i++) { |
54 var prop = f_own_property_names[i]; | 54 var prop = f_own_property_names[i]; |
55 var f_desc = Object.getOwnPropertyDescriptor(f, prop); | 55 var f_desc = Object.getOwnPropertyDescriptor(f, prop); |
56 var g_desc = Object.getOwnPropertyDescriptor(g, prop); | 56 var g_desc = Object.getOwnPropertyDescriptor(g, prop); |
57 assertEquals(f_desc.configurable, g_desc.configurable, prop); | 57 assertEquals(f_desc.configurable, g_desc.configurable, prop); |
58 assertEquals(f_desc.writable, g_desc.writable, prop); | 58 if (prop === 'arguments' || prop === 'caller') { |
| 59 // Unlike sloppy functions, which have read-only data arguments and caller |
| 60 // properties, sloppy generators have a poison pill implemented via |
| 61 // accessors |
| 62 assertFalse('writable' in g_desc, prop); |
| 63 assertTrue(g_desc.get instanceof Function, prop); |
| 64 assertEquals(g_desc.get, g_desc.set, prop); |
| 65 } else { |
| 66 assertEquals(f_desc.writable, g_desc.writable, prop); |
| 67 } |
59 assertEquals(f_desc.enumerable, g_desc.enumerable, prop); | 68 assertEquals(f_desc.enumerable, g_desc.enumerable, prop); |
60 } | 69 } |
61 } | 70 } |
62 TestGeneratorFunctionInstance(); | 71 TestGeneratorFunctionInstance(); |
63 | 72 |
64 | 73 |
65 // Generators have an additional object interposed in the chain between | 74 // Generators have an additional object interposed in the chain between |
66 // themselves and Function.prototype. | 75 // themselves and Function.prototype. |
67 function TestGeneratorFunctionPrototype() { | 76 function TestGeneratorFunctionPrototype() { |
68 // Sanity check. | 77 // Sanity check. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 assertTrue((function*(){}).prototype !== (function*(){}).prototype); | 130 assertTrue((function*(){}).prototype !== (function*(){}).prototype); |
122 assertTrue((function*(){}).prototype !== g.prototype); | 131 assertTrue((function*(){}).prototype !== g.prototype); |
123 assertTrue(g.prototype instanceof GeneratorFunctionPrototype); | 132 assertTrue(g.prototype instanceof GeneratorFunctionPrototype); |
124 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); | 133 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); |
125 assertTrue(!(g.prototype instanceof Function)); | 134 assertTrue(!(g.prototype instanceof Function)); |
126 assertSame(typeof (g.prototype), "object"); | 135 assertSame(typeof (g.prototype), "object"); |
127 | 136 |
128 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); | 137 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); |
129 } | 138 } |
130 TestPerGeneratorPrototype(); | 139 TestPerGeneratorPrototype(); |
OLD | NEW |