| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 f_own_property_names.sort(); | 46 f_own_property_names.sort(); |
| 47 g_own_property_names.sort(); | 47 g_own_property_names.sort(); |
| 48 | 48 |
| 49 assertArrayEquals(f_own_property_names, g_own_property_names); | 49 assertArrayEquals(f_own_property_names, g_own_property_names); |
| 50 var i; | 50 var i; |
| 51 for (i = 0; i < f_own_property_names.length; i++) { | 51 for (i = 0; i < f_own_property_names.length; i++) { |
| 52 var prop = f_own_property_names[i]; | 52 var prop = f_own_property_names[i]; |
| 53 var f_desc = Object.getOwnPropertyDescriptor(f, prop); | 53 var f_desc = Object.getOwnPropertyDescriptor(f, prop); |
| 54 var g_desc = Object.getOwnPropertyDescriptor(g, prop); | 54 var g_desc = Object.getOwnPropertyDescriptor(g, prop); |
| 55 if (prop === "prototype") { | 55 assertEquals(f_desc.configurable, g_desc.configurable, prop); |
| 56 // ES6 draft 03-17-2015 section 25.2.2.2 | 56 assertEquals(f_desc.writable, g_desc.writable, prop); |
| 57 assertFalse(g_desc.writable, prop); | 57 assertEquals(f_desc.enumerable, g_desc.enumerable, prop); |
| 58 assertFalse(g_desc.enumerable, prop); | |
| 59 assertFalse(g_desc.configurable, prop); | |
| 60 } else { | |
| 61 assertEquals(f_desc.configurable, g_desc.configurable, prop); | |
| 62 assertEquals(f_desc.writable, g_desc.writable, prop); | |
| 63 assertEquals(f_desc.enumerable, g_desc.enumerable, prop); | |
| 64 } | |
| 65 } | 58 } |
| 66 } | 59 } |
| 67 TestGeneratorFunctionInstance(); | 60 TestGeneratorFunctionInstance(); |
| 68 | 61 |
| 69 | 62 |
| 70 // Generators have an additional object interposed in the chain between | 63 // Generators have an additional object interposed in the chain between |
| 71 // themselves and Function.prototype. | 64 // themselves and Function.prototype. |
| 72 function TestGeneratorFunctionPrototype() { | 65 function TestGeneratorFunctionPrototype() { |
| 73 // Sanity check. | 66 // Sanity check. |
| 74 assertSame(Object.getPrototypeOf(f), Function.prototype); | 67 assertSame(Object.getPrototypeOf(f), Function.prototype); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 function TestPerGeneratorPrototype() { | 156 function TestPerGeneratorPrototype() { |
| 164 assertTrue((function*(){}).prototype !== (function*(){}).prototype); | 157 assertTrue((function*(){}).prototype !== (function*(){}).prototype); |
| 165 assertTrue((function*(){}).prototype !== g.prototype); | 158 assertTrue((function*(){}).prototype !== g.prototype); |
| 166 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); | 159 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); |
| 167 assertTrue(!(g.prototype instanceof Function)); | 160 assertTrue(!(g.prototype instanceof Function)); |
| 168 assertSame(typeof (g.prototype), "object"); | 161 assertSame(typeof (g.prototype), "object"); |
| 169 | 162 |
| 170 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); | 163 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); |
| 171 } | 164 } |
| 172 TestPerGeneratorPrototype(); | 165 TestPerGeneratorPrototype(); |
| OLD | NEW |