| 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 26 matching lines...) Expand all Loading... |
| 37 assertEquals(o.x, o[0]); | 37 assertEquals(o.x, o[0]); |
| 38 assertEquals(o.x, o.__lookupGetter__('0')()); | 38 assertEquals(o.x, o.__lookupGetter__('0')()); |
| 39 o[0] = 21; | 39 o[0] = 21; |
| 40 assertEquals(21, o.x); | 40 assertEquals(21, o.x); |
| 41 o.__lookupSetter__(0)(7); | 41 o.__lookupSetter__(0)(7); |
| 42 assertEquals(7, o.x); | 42 assertEquals(7, o.x); |
| 43 | 43 |
| 44 function Pair(x, y) { | 44 function Pair(x, y) { |
| 45 this.x = x; | 45 this.x = x; |
| 46 this.y = y; | 46 this.y = y; |
| 47 }; | 47 } |
| 48 Pair.prototype.__defineGetter__('0', function() { return this.x; }); | 48 Pair.prototype.__defineGetter__('0', function() { return this.x; }); |
| 49 Pair.prototype.__defineGetter__('1', function() { return this.y; }); | 49 Pair.prototype.__defineGetter__('1', function() { return this.y; }); |
| 50 Pair.prototype.__defineSetter__('0', function(x) { this.x = x; }); | 50 Pair.prototype.__defineSetter__('0', function(x) { this.x = x; }); |
| 51 Pair.prototype.__defineSetter__('1', function(y) { this.y = y; }); | 51 Pair.prototype.__defineSetter__('1', function(y) { this.y = y; }); |
| 52 | 52 |
| 53 var p = new Pair(2, 3); | 53 var p = new Pair(2, 3); |
| 54 assertEquals(2, p[0]); | 54 assertEquals(2, p[0]); |
| 55 assertEquals(3, p[1]); | 55 assertEquals(3, p[1]); |
| 56 p.x = 7; | 56 p.x = 7; |
| 57 p[1] = 8; | 57 p[1] = 8; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 q1[0] = 3; | 95 q1[0] = 3; |
| 96 assertEquals(q1[0], undefined); | 96 assertEquals(q1[0], undefined); |
| 97 assertEquals(q1.b, 17); | 97 assertEquals(q1.b, 17); |
| 98 | 98 |
| 99 // Complex case of using an undefined getter. | 99 // Complex case of using an undefined getter. |
| 100 // From http://code.google.com/p/v8/issues/detail?id=298 | 100 // From http://code.google.com/p/v8/issues/detail?id=298 |
| 101 // Reported by nth10sd. | 101 // Reported by nth10sd. |
| 102 | 102 |
| 103 a = function() {}; | 103 a = function() {}; |
| 104 __defineSetter__("0", function() {}); | 104 __defineSetter__("0", function() {}); |
| 105 if (a |= '') {}; | 105 if (a |= '') {} |
| 106 assertThrows('this[a].__parent__'); | 106 assertThrows('this[a].__parent__'); |
| 107 assertEquals(a, 0); | 107 assertEquals(a, 0); |
| 108 assertEquals(this[a], undefined); | 108 assertEquals(this[a], undefined); |
| OLD | NEW |