| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 var ctr5 = 0; | 56 var ctr5 = 0; |
| 57 var ctr6 = 1000; | 57 var ctr6 = 1000; |
| 58 | 58 |
| 59 var protoFoo = { foo: function() { ctr++; }}; | 59 var protoFoo = { foo: function() { ctr++; }}; |
| 60 var fooValue = { foo: { writable: true, value: function() { ctr2++; }}}; | 60 var fooValue = { foo: { writable: true, value: function() { ctr2++; }}}; |
| 61 var fooGetter = { foo: { get: function() { return ctr3++; }}}; | 61 var fooGetter = { foo: { get: function() { return ctr3++; }}}; |
| 62 var fooSetter = { foo: { set: function() { return ctr4++; }}}; | 62 var fooSetter = { foo: { set: function() { return ctr4++; }}}; |
| 63 var fooAmbiguous = { foo: { get: function() { return ctr3++; }, | 63 var fooAmbiguous = { foo: { get: function() { return ctr3++; }, |
| 64 value: 3 }}; | 64 value: 3 }}; |
| 65 | 65 |
| 66 function valueGet() { ctr5++; return 3 }; | 66 function valueGet() { |
| 67 function getterGet() { ctr5++; return function() { return ctr6++; }; }; | 67 ctr5++; |
| 68 return 3; |
| 69 } |
| 70 function getterGet() { |
| 71 ctr5++; |
| 72 return function() { return ctr6++; }; |
| 73 } |
| 68 | 74 |
| 69 // Simple object with prototype, no properties added. | 75 // Simple object with prototype, no properties added. |
| 70 Object.create(protoFoo).foo(); | 76 Object.create(protoFoo).foo(); |
| 71 assertEquals(1, ctr); | 77 assertEquals(1, ctr); |
| 72 | 78 |
| 73 // Simple object with object with prototype, no properties added. | 79 // Simple object with object with prototype, no properties added. |
| 74 Object.create(Object.create(protoFoo)).foo(); | 80 Object.create(Object.create(protoFoo)).foo(); |
| 75 assertEquals(2, ctr); | 81 assertEquals(2, ctr); |
| 76 | 82 |
| 77 // Add a property foo that returns a function. | 83 // Add a property foo that returns a function. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 assertEquals(6, ctr7); | 176 assertEquals(6, ctr7); |
| 171 } | 177 } |
| 172 | 178 |
| 173 var magicWritableProps = { | 179 var magicWritableProps = { |
| 174 foo: Object.create(null, { value: { value: 4 }, | 180 foo: Object.create(null, { value: { value: 4 }, |
| 175 writable: { get: function() { | 181 writable: { get: function() { |
| 176 ctr6++; | 182 ctr6++; |
| 177 return false; | 183 return false; |
| 178 }}})}; | 184 }}})}; |
| 179 | 185 |
| 180 var fooNotWritable = Object.create(null, magicWritableProps) | 186 var fooNotWritable = Object.create(null, magicWritableProps); |
| 181 assertEquals(1002, ctr6); | 187 assertEquals(1002, ctr6); |
| 182 assertEquals(4, fooNotWritable.foo); | 188 assertEquals(4, fooNotWritable.foo); |
| 183 fooNotWritable.foo = 5; | 189 fooNotWritable.foo = 5; |
| 184 assertEquals(4, fooNotWritable.foo); | 190 assertEquals(4, fooNotWritable.foo); |
| 185 | 191 |
| 186 | 192 |
| 187 // Test enumerable flag. | 193 // Test enumerable flag. |
| 188 | 194 |
| 189 var fooNotEnumerable = | 195 var fooNotEnumerable = |
| 190 Object.create({fizz: 14}, {foo: {value: 3, enumerable: false}, | 196 Object.create({fizz: 14}, {foo: {value: 3, enumerable: false}, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 assertTrue("baz" in sonOfTricky); | 247 assertTrue("baz" in sonOfTricky); |
| 242 assertFalse("fizz" in sonOfTricky); | 248 assertFalse("fizz" in sonOfTricky); |
| 243 assertTrue("buzz" in sonOfTricky); | 249 assertTrue("buzz" in sonOfTricky); |
| 244 | 250 |
| 245 var sum = 0; | 251 var sum = 0; |
| 246 for (x in sonOfTricky) { | 252 for (x in sonOfTricky) { |
| 247 assertTrue(x === 'buzz'); | 253 assertTrue(x === 'buzz'); |
| 248 sum += sonOfTricky[x]; | 254 sum += sonOfTricky[x]; |
| 249 } | 255 } |
| 250 assertEquals(16, sum); | 256 assertEquals(16, sum); |
| OLD | NEW |