Chromium Code Reviews| 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() { ctr5++; return 3; } |
|
Rico
2011/12/08 10:24:37
individual lines for body
| |
| 67 function getterGet() { ctr5++; return function() { return ctr6++; }; }; | 67 function getterGet() { ctr5++; return function() { return ctr6++; }; } |
|
Rico
2011/12/08 10:24:37
individual lines for body
| |
| 68 | 68 |
| 69 // Simple object with prototype, no properties added. | 69 // Simple object with prototype, no properties added. |
| 70 Object.create(protoFoo).foo(); | 70 Object.create(protoFoo).foo(); |
| 71 assertEquals(1, ctr); | 71 assertEquals(1, ctr); |
| 72 | 72 |
| 73 // Simple object with object with prototype, no properties added. | 73 // Simple object with object with prototype, no properties added. |
| 74 Object.create(Object.create(protoFoo)).foo(); | 74 Object.create(Object.create(protoFoo)).foo(); |
| 75 assertEquals(2, ctr); | 75 assertEquals(2, ctr); |
| 76 | 76 |
| 77 // Add a property foo that returns a function. | 77 // 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); | 170 assertEquals(6, ctr7); |
| 171 } | 171 } |
| 172 | 172 |
| 173 var magicWritableProps = { | 173 var magicWritableProps = { |
| 174 foo: Object.create(null, { value: { value: 4 }, | 174 foo: Object.create(null, { value: { value: 4 }, |
| 175 writable: { get: function() { | 175 writable: { get: function() { |
| 176 ctr6++; | 176 ctr6++; |
| 177 return false; | 177 return false; |
| 178 }}})}; | 178 }}})}; |
| 179 | 179 |
| 180 var fooNotWritable = Object.create(null, magicWritableProps) | 180 var fooNotWritable = Object.create(null, magicWritableProps); |
| 181 assertEquals(1002, ctr6); | 181 assertEquals(1002, ctr6); |
| 182 assertEquals(4, fooNotWritable.foo); | 182 assertEquals(4, fooNotWritable.foo); |
| 183 fooNotWritable.foo = 5; | 183 fooNotWritable.foo = 5; |
| 184 assertEquals(4, fooNotWritable.foo); | 184 assertEquals(4, fooNotWritable.foo); |
| 185 | 185 |
| 186 | 186 |
| 187 // Test enumerable flag. | 187 // Test enumerable flag. |
| 188 | 188 |
| 189 var fooNotEnumerable = | 189 var fooNotEnumerable = |
| 190 Object.create({fizz: 14}, {foo: {value: 3, enumerable: false}, | 190 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); | 241 assertTrue("baz" in sonOfTricky); |
| 242 assertFalse("fizz" in sonOfTricky); | 242 assertFalse("fizz" in sonOfTricky); |
| 243 assertTrue("buzz" in sonOfTricky); | 243 assertTrue("buzz" in sonOfTricky); |
| 244 | 244 |
| 245 var sum = 0; | 245 var sum = 0; |
| 246 for (x in sonOfTricky) { | 246 for (x in sonOfTricky) { |
| 247 assertTrue(x === 'buzz'); | 247 assertTrue(x === 'buzz'); |
| 248 sum += sonOfTricky[x]; | 248 sum += sonOfTricky[x]; |
| 249 } | 249 } |
| 250 assertEquals(16, sum); | 250 assertEquals(16, sum); |
| OLD | NEW |