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

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

Issue 16539: Factored the generation of JSON serialization from beeing part of the mirror ... (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-function.js ('k') | test/mjsunit/mirror-script.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 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // NaN is not equal to NaN. 112 // NaN is not equal to NaN.
113 if (isNaN(properties[i].value().value())) { 113 if (isNaN(properties[i].value().value())) {
114 assertTrue(isNaN(fromJSON.properties[i].value.value)); 114 assertTrue(isNaN(fromJSON.properties[i].value.value));
115 } else { 115 } else {
116 assertEquals(properties[i].value().value(), fromJSON.properties[i].v alue.value); 116 assertEquals(properties[i].value().value(), fromJSON.properties[i].v alue.value);
117 } 117 }
118 } 118 }
119 found = true; 119 found = true;
120 } 120 }
121 } 121 }
122 assertTrue(found, '"' + name + '" not found'); 122 assertTrue(found, '"' + name + '" not found (' + json + ')');
123 } 123 }
124 } 124 }
125 125
126 126
127 function Point(x,y) { 127 function Point(x,y) {
128 this.x_ = x; 128 this.x_ = x;
129 this.y_ = y; 129 this.y_ = y;
130 } 130 }
131 131
132 132
133 // Test a number of different objects. 133 // Test a number of different objects.
134 testObjectMirror({}, 'Object', 'Object'); 134 testObjectMirror({}, 'Object', 'Object');
135 testObjectMirror({'a':1,'b':2}, 'Object', 'Object'); 135 testObjectMirror({'a':1,'b':2}, 'Object', 'Object');
136 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object'); 136 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object');
137 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point'); 137 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point');
138 testObjectMirror(this, 'global', undefined, true); // Global object has special properties 138 testObjectMirror(this, 'global', undefined, true); // Global object has special properties
139 testObjectMirror([], 'Array', 'Array'); 139 testObjectMirror([], 'Array', 'Array');
140 testObjectMirror([1,2], 'Array', 'Array'); 140 testObjectMirror([1,2], 'Array', 'Array');
141 141
142 // Test circular references.
143 o = {};
144 o.o = o;
145 testObjectMirror(o, 'Object', 'Object');
146
142 // Test that non enumerable properties are part of the mirror 147 // Test that non enumerable properties are part of the mirror
143 global_mirror = debug.MakeMirror(this); 148 global_mirror = debug.MakeMirror(this);
144 assertEquals('property', global_mirror.property("Math").type()); 149 assertEquals('property', global_mirror.property("Math").type());
145 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes()); 150 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes());
146 151
147 math_mirror = global_mirror.property("Math").value(); 152 math_mirror = global_mirror.property("Math").value();
148 assertEquals('property', math_mirror.property("E").type()); 153 assertEquals('property', math_mirror.property("E").type());
149 assertFalse(math_mirror.property("E").isEnum(), "Math.E is enumerable"); 154 assertFalse(math_mirror.property("E").isEnum(), "Math.E is enumerable");
150 assertTrue(math_mirror.property("E").isReadOnly()); 155 assertTrue(math_mirror.property("E").isReadOnly());
151 assertFalse(math_mirror.property("E").canDelete()); 156 assertFalse(math_mirror.property("E").canDelete());
(...skipping 17 matching lines...) Expand all
169 assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType()); 174 assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType());
170 175
171 // Test objects with native accessors. 176 // Test objects with native accessors.
172 mirror = debug.MakeMirror(new String('abc')); 177 mirror = debug.MakeMirror(new String('abc'));
173 assertTrue(mirror instanceof debug.ObjectMirror); 178 assertTrue(mirror instanceof debug.ObjectMirror);
174 assertTrue(mirror.property('length').value() instanceof debug.AccessorMirror); 179 assertTrue(mirror.property('length').value() instanceof debug.AccessorMirror);
175 assertTrue(mirror.property('length').value().isNative()); 180 assertTrue(mirror.property('length').value().isNative());
176 assertEquals('a', mirror.property(0).value().value()); 181 assertEquals('a', mirror.property(0).value().value());
177 assertEquals('b', mirror.property(1).value().value()); 182 assertEquals('b', mirror.property(1).value().value());
178 assertEquals('c', mirror.property(2).value().value()); 183 assertEquals('c', mirror.property(2).value().value());
OLDNEW
« no previous file with comments | « test/mjsunit/mirror-function.js ('k') | test/mjsunit/mirror-script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698