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

Side by Side Diff: test/mjsunit/mirror-object.js

Issue 17377: Refactored the mirror representation of properties. Removed the AssessorMirro... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 11 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/cctest/test-debug.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 assertEquals(properties[i].propertyType(), fromJSON.properties[i].prop ertyType); 100 assertEquals(properties[i].propertyType(), fromJSON.properties[i].prop ertyType);
101 } else { 101 } else {
102 assertTrue(typeof(fromJSON.properties[i].propertyType) === 'undefined' ); 102 assertTrue(typeof(fromJSON.properties[i].propertyType) === 'undefined' );
103 } 103 }
104 // If there are no attributes nothing is serialized. 104 // If there are no attributes nothing is serialized.
105 if (properties[i].attributes() != debug.PropertyAttribute.None) { 105 if (properties[i].attributes() != debug.PropertyAttribute.None) {
106 assertEquals(properties[i].attributes(), fromJSON.properties[i].attrib utes); 106 assertEquals(properties[i].attributes(), fromJSON.properties[i].attrib utes);
107 } else { 107 } else {
108 assertTrue(typeof(fromJSON.properties[i].attributes) === 'undefined'); 108 assertTrue(typeof(fromJSON.properties[i].attributes) === 'undefined');
109 } 109 }
110 if (!properties[i].value() instanceof debug.AccessorMirror && 110 if (!properties[i].value().isPrimitive()) {
111 properties[i].value().isPrimitive()) {
112 // NaN is not equal to NaN. 111 // NaN is not equal to NaN.
113 if (isNaN(properties[i].value().value())) { 112 if (isNaN(properties[i].value().value())) {
114 assertTrue(isNaN(fromJSON.properties[i].value.value)); 113 assertTrue(isNaN(fromJSON.properties[i].value.value));
115 } else { 114 } else {
116 assertEquals(properties[i].value().value(), fromJSON.properties[i].v alue.value); 115 assertEquals(properties[i].value().value(), fromJSON.properties[i].v alue.value);
117 } 116 }
118 } 117 }
119 found = true; 118 found = true;
120 } 119 }
121 } 120 }
(...skipping 28 matching lines...) Expand all
150 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes()); 149 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes());
151 150
152 math_mirror = global_mirror.property("Math").value(); 151 math_mirror = global_mirror.property("Math").value();
153 assertEquals('property', math_mirror.property("E").type()); 152 assertEquals('property', math_mirror.property("E").type());
154 assertFalse(math_mirror.property("E").isEnum(), "Math.E is enumerable"); 153 assertFalse(math_mirror.property("E").isEnum(), "Math.E is enumerable");
155 assertTrue(math_mirror.property("E").isReadOnly()); 154 assertTrue(math_mirror.property("E").isReadOnly());
156 assertFalse(math_mirror.property("E").canDelete()); 155 assertFalse(math_mirror.property("E").canDelete());
157 156
158 // Test objects with JavaScript accessors. 157 // Test objects with JavaScript accessors.
159 o = {} 158 o = {}
160 o.__defineGetter__('a', function(){throw 'a';}) 159 o.__defineGetter__('a', function(){return 'a';});
161 o.__defineSetter__('b', function(){throw 'b';}) 160 o.__defineSetter__('b', function(){});
162 o.__defineGetter__('c', function(){throw 'c';}) 161 o.__defineGetter__('c', function(){throw 'c';});
163 o.__defineSetter__('c', function(){throw 'c';}) 162 o.__defineSetter__('c', function(){throw 'c';});
164 testObjectMirror(o, 'Object', 'Object'); 163 testObjectMirror(o, 'Object', 'Object');
165 mirror = debug.MakeMirror(o); 164 mirror = debug.MakeMirror(o);
166 // a has getter but no setter. 165 // a has getter but no setter.
167 assertTrue(mirror.property('a').value() instanceof debug.AccessorMirror); 166 assertTrue(mirror.property('a').hasGetter());
167 assertFalse(mirror.property('a').hasSetter());
168 assertEquals(debug.PropertyType.Callbacks, mirror.property('a').propertyType()); 168 assertEquals(debug.PropertyType.Callbacks, mirror.property('a').propertyType());
169 assertEquals('function', mirror.property('a').getter().type());
170 assertEquals('undefined', mirror.property('a').setter().type());
171 assertEquals('function (){return \'a\';}', mirror.property('a').getter().source( ));
172 assertEquals('a', mirror.property('a').value().value());
173 assertFalse(mirror.property('a').isException());
169 // b has setter but no getter. 174 // b has setter but no getter.
170 assertTrue(mirror.property('b').value() instanceof debug.AccessorMirror); 175 assertFalse(mirror.property('b').hasGetter());
176 assertTrue(mirror.property('b').hasSetter());
171 assertEquals(debug.PropertyType.Callbacks, mirror.property('b').propertyType()); 177 assertEquals(debug.PropertyType.Callbacks, mirror.property('b').propertyType());
172 // c has both getter and setter. 178 assertEquals('undefined', mirror.property('b').getter().type());
173 assertTrue(mirror.property('c').value() instanceof debug.AccessorMirror); 179 assertEquals('function', mirror.property('b').setter().type());
180 assertEquals('function (){}', mirror.property('b').setter().source());
181 assertFalse(mirror.property('b').isException());
182 // c has both getter and setter. The getter throws an exception.
183 assertTrue(mirror.property('c').hasGetter());
184 assertTrue(mirror.property('c').hasSetter());
174 assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType()); 185 assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType());
186 assertEquals('function', mirror.property('c').getter().type());
187 assertEquals('function', mirror.property('c').setter().type());
188 assertEquals('function (){throw \'c\';}', mirror.property('c').getter().source() );
189 assertEquals('function (){throw \'c\';}', mirror.property('c').setter().source() );
190 assertEquals('c', mirror.property('c').value().value());
191 assertTrue(mirror.property('c').isException());
175 192
176 // Test objects with native accessors. 193 // Test objects with native accessors.
177 mirror = debug.MakeMirror(new String('abc')); 194 mirror = debug.MakeMirror(new String('abc'));
178 assertTrue(mirror instanceof debug.ObjectMirror); 195 assertTrue(mirror instanceof debug.ObjectMirror);
179 assertTrue(mirror.property('length').value() instanceof debug.AccessorMirror); 196 assertFalse(mirror.property('length').hasGetter());
180 assertTrue(mirror.property('length').value().isNative()); 197 assertFalse(mirror.property('length').hasSetter());
198 assertTrue(mirror.property('length').isNative());
181 assertEquals('a', mirror.property(0).value().value()); 199 assertEquals('a', mirror.property(0).value().value());
182 assertEquals('b', mirror.property(1).value().value()); 200 assertEquals('b', mirror.property(1).value().value());
183 assertEquals('c', mirror.property(2).value().value()); 201 assertEquals('c', mirror.property(2).value().value());
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698