Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: test/mjsunit/indexed-accessors.js

Issue 7064027: Change calls to undefined property setters to not throw (fixes issue 1355). (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/getter-in-prototype.js ('k') | test/mjsunit/regress/regress-1355.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 actual[1000000] = -1; 75 actual[1000000] = -1;
76 testArray(); 76 testArray();
77 testArray(); 77 testArray();
78 actual.__defineGetter__('0', function() { return expected[0]; }); 78 actual.__defineGetter__('0', function() { return expected[0]; });
79 expected[0] = 42; 79 expected[0] = 42;
80 testArray(); 80 testArray();
81 expected[0] = 111; 81 expected[0] = 111;
82 testArray(); 82 testArray();
83 83
84 // Using a setter where only a getter is defined throws an exception. 84 // Using a setter where only a getter is defined does not throw an exception,
85 // unless we are in strict mode.
85 var q = {}; 86 var q = {};
86 q.__defineGetter__('0', function() { return 42; }); 87 q.__defineGetter__('0', function() { return 42; });
87 assertThrows('q[0] = 7'); 88 assertDoesNotThrow('q[0] = 7');
88 89
89 // Using a getter where only a setter is defined returns undefined. 90 // Using a getter where only a setter is defined returns undefined.
90 var q1 = {}; 91 var q1 = {};
91 q1.__defineSetter__('0', function() {q1.b = 17;}); 92 q1.__defineSetter__('0', function() {q1.b = 17;});
92 assertEquals(q1[0], undefined); 93 assertEquals(q1[0], undefined);
93 // Setter works 94 // Setter works
94 q1[0] = 3; 95 q1[0] = 3;
95 assertEquals(q1[0], undefined); 96 assertEquals(q1[0], undefined);
96 assertEquals(q1.b, 17); 97 assertEquals(q1.b, 17);
97 98
98 // Complex case of using an undefined getter. 99 // Complex case of using an undefined getter.
99 // From http://code.google.com/p/v8/issues/detail?id=298 100 // From http://code.google.com/p/v8/issues/detail?id=298
100 // Reported by nth10sd. 101 // Reported by nth10sd.
101 102
102 a = function() {}; 103 a = function() {};
103 __defineSetter__("0", function() {}); 104 __defineSetter__("0", function() {});
104 if (a |= '') {}; 105 if (a |= '') {};
105 assertThrows('this[a].__parent__'); 106 assertThrows('this[a].__parent__');
106 assertEquals(a, 0); 107 assertEquals(a, 0);
107 assertEquals(this[a], undefined); 108 assertEquals(this[a], undefined);
OLDNEW
« no previous file with comments | « test/mjsunit/getter-in-prototype.js ('k') | test/mjsunit/regress/regress-1355.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698