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 3// found in the LICENSE file. 4 5(function TestConstants() { 6 var o = { 7 p: 1, 8 p: 2, 9 }; 10 assertEquals(2, o.p); 11})(); 12 13 14(function TestMaterialized() { 15 var o = { 16 p: [1], 17 p: [2], 18 }; 19 assertEquals(2, o.p[0]); 20})(); 21 22 23(function TestMaterialize2() { 24 var o = { 25 p: function() {}, 26 p: 2, 27 }; 28 assertEquals(2, o.p); 29})(); 30 31 32 33(function TestComputed() { 34 var o = { 35 p: (function() { return 1; })(), 36 p: (function() { return 2; })(), 37 }; 38 assertEquals(2, o.p); 39})(); 40 41 42(function TestComputed2() { 43 var o = { 44 p: (function() { return 1; })(), 45 p: 2, 46 }; 47 assertEquals(2, o.p); 48})(); 49 50 51 52(function TestGetter() { 53 var o = { 54 get p() { return 1; }, 55 get p() { return 2; }, 56 }; 57 assertEquals(2, o.p); 58})(); 59 60 61(function TestGetterSetter() { 62 var o = { 63 get p() { return 1; }, 64 set p(_) {}, 65 }; 66 assertEquals(1, o.p); 67 68 o = { 69 set p(_) {}, 70 get p() { return 2; }, 71 }; 72 assertEquals(2, o.p); 73})(); 74 75 76(function TestCombined() { 77 var o = { 78 get p() { return 1; }, 79 p: 2, 80 }; 81 assertEquals(2, o.p); 82 83 o = { 84 get p() { return 1; }, 85 p: 2, 86 get p() { return 3; }, 87 }; 88 assertEquals(3, o.p); 89 90 o = { 91 get p() { return 1; }, 92 p: 2, 93 set p(_) {}, 94 }; 95 assertEquals(undefined, o.p); 96})(); 97