| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 assertEquals("undefined", typeof(c[pos - 1])); | 60 assertEquals("undefined", typeof(c[pos - 1])); |
| 61 assertEquals("foo", c[pos]); | 61 assertEquals("foo", c[pos]); |
| 62 assertEquals("bar", c[pos + 1]); | 62 assertEquals("bar", c[pos + 1]); |
| 63 | 63 |
| 64 // When we take the number off the prototype it disappears from a, but | 64 // When we take the number off the prototype it disappears from a, but |
| 65 // the concat put it in c itself. | 65 // the concat put it in c itself. |
| 66 Array.prototype["123"] = undefined; | 66 Array.prototype["123"] = undefined; |
| 67 assertEquals("undefined", typeof(a[123])); | 67 assertEquals("undefined", typeof(a[123])); |
| 68 assertEquals("baz", c[123]); | 68 assertEquals("baz", c[123]); |
| 69 | 69 |
| 70 // If the element of prototype is shadowed, the element on the instance |
| 71 // should be copied, but not the one on the prototype. |
| 72 Array.prototype[123] = 'baz'; |
| 73 a[123] = 'xyz'; |
| 74 assertEquals('xyz', a[123]); |
| 75 c = a.concat(b); |
| 76 assertEquals('xyz', c[123]); |
| 77 |
| 70 // Non-numeric properties on the prototype or the array shouldn't get | 78 // Non-numeric properties on the prototype or the array shouldn't get |
| 71 // copied. | 79 // copied. |
| 72 Array.prototype.moe = 'joe'; | 80 Array.prototype.moe = 'joe'; |
| 73 a.ben = 'jerry'; | 81 a.ben = 'jerry'; |
| 74 assertEquals(a["moe"], 'joe'); | 82 assertEquals(a["moe"], 'joe'); |
| 75 assertEquals(a["ben"], 'jerry'); | 83 assertEquals(a["ben"], 'jerry'); |
| 76 c = a.concat(b); | 84 c = a.concat(b); |
| 77 // ben was not copied | 85 // ben was not copied |
| 78 assertEquals("undefined", typeof(c.ben)); | 86 assertEquals("undefined", typeof(c.ben)); |
| 79 // moe was not copied, but we can see it through the prototype | 87 // moe was not copied, but we can see it through the prototype |
| (...skipping 12 matching lines...) Expand all Loading... |
| 92 assertEquals("undefined", typeof(c[0xffffffff])); | 100 assertEquals("undefined", typeof(c[0xffffffff])); |
| 93 assertEquals(c.length, a.length + 1); | 101 assertEquals(c.length, a.length + 1); |
| 94 | 102 |
| 95 } | 103 } |
| 96 | 104 |
| 97 a = []; | 105 a = []; |
| 98 c = a.concat('Hello'); | 106 c = a.concat('Hello'); |
| 99 assertEquals(1, c.length); | 107 assertEquals(1, c.length); |
| 100 assertEquals("Hello", c[0]); | 108 assertEquals("Hello", c[0]); |
| 101 assertEquals("Hello", c.toString()); | 109 assertEquals("Hello", c.toString()); |
| OLD | NEW |