| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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-object-literals --allow-natives-syntax | 5 // Flags: --harmony-object-literals --allow-natives-syntax |
| 6 | 6 |
| 7 | 7 |
| 8 (function TestBasics() { | 8 (function TestBasics() { |
| 9 var object = { | 9 var object = { |
| 10 method() { | 10 method() { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 }; | 97 }; |
| 98 var f = object.method; | 98 var f = object.method; |
| 99 assertFalse(f.hasOwnProperty('prototype')); | 99 assertFalse(f.hasOwnProperty('prototype')); |
| 100 assertEquals(undefined, f.prototype); | 100 assertEquals(undefined, f.prototype); |
| 101 | 101 |
| 102 f.prototype = 42; | 102 f.prototype = 42; |
| 103 assertEquals(42, f.prototype); | 103 assertEquals(42, f.prototype); |
| 104 })(); | 104 })(); |
| 105 | 105 |
| 106 | 106 |
| 107 (function TestNoRestrictedPropertiesStrict() { |
| 108 var obj = { |
| 109 method() { "use strict"; } |
| 110 }; |
| 111 assertEquals(false, obj.method.hasOwnProperty("arguments")); |
| 112 assertEquals(null, obj.method.arguments); |
| 113 |
| 114 assertEquals(false, obj.method.hasOwnProperty("caller")); |
| 115 assertEquals(null, obj.method.caller); |
| 116 })(); |
| 117 |
| 118 |
| 119 (function TestNoRestrictedPropertiesSloppy() { |
| 120 var obj = { |
| 121 method() {} |
| 122 }; |
| 123 assertEquals(false, obj.method.hasOwnProperty("arguments")); |
| 124 assertEquals(null, obj.method.arguments); |
| 125 |
| 126 assertEquals(false, obj.method.hasOwnProperty("caller")); |
| 127 assertEquals(null, obj.method.caller); |
| 128 })(); |
| 129 |
| 130 |
| 107 (function TestToString() { | 131 (function TestToString() { |
| 108 var object = { | 132 var object = { |
| 109 method() { 42; } | 133 method() { 42; } |
| 110 }; | 134 }; |
| 111 assertEquals('method() { 42; }', object.method.toString()); | 135 assertEquals('method() { 42; }', object.method.toString()); |
| 112 })(); | 136 })(); |
| 113 | 137 |
| 114 | 138 |
| 115 (function TestOptimized() { | 139 (function TestOptimized() { |
| 116 var object = { | 140 var object = { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 var p = {}; | 287 var p = {}; |
| 264 var object = { | 288 var object = { |
| 265 __proto__() { | 289 __proto__() { |
| 266 return 1; | 290 return 1; |
| 267 }, | 291 }, |
| 268 __proto__: p | 292 __proto__: p |
| 269 }; | 293 }; |
| 270 assertEquals(p, Object.getPrototypeOf(object)); | 294 assertEquals(p, Object.getPrototypeOf(object)); |
| 271 assertEquals(1, object.__proto__()); | 295 assertEquals(1, object.__proto__()); |
| 272 })(); | 296 })(); |
| OLD | NEW |