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

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

Issue 18445: Changes to the mirror handling... (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/mjsunit/mirror-number.js ('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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } else { 128 } else {
129 assertTrue(typeof(fromJSON.properties[i].attributes) === 'undefined', 'Unexpected serialized attributes'); 129 assertTrue(typeof(fromJSON.properties[i].attributes) === 'undefined', 'Unexpected serialized attributes');
130 } 130 }
131 131
132 // Lookup the serialized object from the handle reference. 132 // Lookup the serialized object from the handle reference.
133 var o = refs.lookup(fromJSON.properties[i].ref); 133 var o = refs.lookup(fromJSON.properties[i].ref);
134 assertTrue(o != void 0, 'Referenced object is not serialized'); 134 assertTrue(o != void 0, 'Referenced object is not serialized');
135 135
136 assertEquals(properties[i].value().type(), o.type, 'Unexpected serialize d property type for ' + name); 136 assertEquals(properties[i].value().type(), o.type, 'Unexpected serialize d property type for ' + name);
137 if (properties[i].value().isPrimitive()) { 137 if (properties[i].value().isPrimitive()) {
138 assertEquals(properties[i].value().value(), o.value, 'Unexpected seria lized property value for ' + name); 138 // Special check for NaN as NaN == NaN is false.
139 if (properties[i].value().isNumber() && isNaN(properties[i].value().va lue())) {
Mads Ager (chromium) 2009/01/21 09:18:34 A couple of long lines here.
Søren Thygesen Gjesse 2009/01/21 09:31:40 I know, it is in a mjsunit test, which have a lot
140 assertEquals('NaN', o.value, 'Unexpected serialized property value f or ' + name);
141 } else {
142 assertEquals(properties[i].value().value(), o.value, 'Unexpected ser ialized property value for ' + name);
143 }
139 } else if (properties[i].value().isFunction()) { 144 } else if (properties[i].value().isFunction()) {
140 assertEquals(properties[i].value().source(), o.source, 'Unexpected ser ialized property value for ' + name); 145 assertEquals(properties[i].value().source(), o.source, 'Unexpected ser ialized property value for ' + name);
141 } 146 }
142 found = true; 147 found = true;
143 } 148 }
144 } 149 }
145 assertTrue(found, '"' + name + '" not found (' + json + ')'); 150 assertTrue(found, '"' + name + '" not found (' + json + ')');
146 } 151 }
147 } 152 }
148 153
149 154
150 function Point(x,y) { 155 function Point(x,y) {
151 this.x_ = x; 156 this.x_ = x;
152 this.y_ = y; 157 this.y_ = y;
153 } 158 }
154 159
155 160
156 // Test a number of different objects. 161 // Test a number of different objects.
157 testObjectMirror({}, 'Object', 'Object'); 162 testObjectMirror({}, 'Object', 'Object');
158 testObjectMirror({'a':1,'b':2}, 'Object', 'Object'); 163 testObjectMirror({'a':1,'b':2}, 'Object', 'Object');
159 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object'); 164 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object');
160 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point'); 165 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point');
161 testObjectMirror(this, 'global', '', true); // Global object has special proper ties 166 testObjectMirror(this, 'global', '', true); // Global object has special proper ties
167 testObjectMirror(this.__proto__, 'Object', '');
162 testObjectMirror([], 'Array', 'Array'); 168 testObjectMirror([], 'Array', 'Array');
163 testObjectMirror([1,2], 'Array', 'Array'); 169 testObjectMirror([1,2], 'Array', 'Array');
164 170
165 // Test circular references. 171 // Test circular references.
166 o = {}; 172 o = {};
167 o.o = o; 173 o.o = o;
168 testObjectMirror(o, 'Object', 'Object'); 174 testObjectMirror(o, 'Object', 'Object');
169 175
170 // Test that non enumerable properties are part of the mirror 176 // Test that non enumerable properties are part of the mirror
171 global_mirror = debug.MakeMirror(this); 177 global_mirror = debug.MakeMirror(this);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 218
213 // Test objects with native accessors. 219 // Test objects with native accessors.
214 mirror = debug.MakeMirror(new String('abc')); 220 mirror = debug.MakeMirror(new String('abc'));
215 assertTrue(mirror instanceof debug.ObjectMirror); 221 assertTrue(mirror instanceof debug.ObjectMirror);
216 assertFalse(mirror.property('length').hasGetter()); 222 assertFalse(mirror.property('length').hasGetter());
217 assertFalse(mirror.property('length').hasSetter()); 223 assertFalse(mirror.property('length').hasSetter());
218 assertTrue(mirror.property('length').isNative()); 224 assertTrue(mirror.property('length').isNative());
219 assertEquals('a', mirror.property(0).value().value()); 225 assertEquals('a', mirror.property(0).value().value());
220 assertEquals('b', mirror.property(1).value().value()); 226 assertEquals('b', mirror.property(1).value().value());
221 assertEquals('c', mirror.property(2).value().value()); 227 assertEquals('c', mirror.property(2).value().value());
OLDNEW
« no previous file with comments | « test/mjsunit/mirror-number.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698