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

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

Issue 10834428: Revert r12346 (Introduce InternalProperty type and expose internal properties for bound functions) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 | « src/mirror-debugger.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 2012 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
11 // with the distribution. 11 // with the distribution.
(...skipping 30 matching lines...) Expand all
42 42
43 function testObjectMirror(obj, cls_name, ctor_name, hasSpecialProperties) { 43 function testObjectMirror(obj, cls_name, ctor_name, hasSpecialProperties) {
44 // Create mirror and JSON representation. 44 // Create mirror and JSON representation.
45 var mirror = debug.MakeMirror(obj); 45 var mirror = debug.MakeMirror(obj);
46 var serializer = debug.MakeMirrorSerializer(); 46 var serializer = debug.MakeMirrorSerializer();
47 var json = JSON.stringify(serializer.serializeValue(mirror)); 47 var json = JSON.stringify(serializer.serializeValue(mirror));
48 var refs = new MirrorRefCache( 48 var refs = new MirrorRefCache(
49 JSON.stringify(serializer.serializeReferencedObjects())); 49 JSON.stringify(serializer.serializeReferencedObjects()));
50 50
51 // Check the mirror hierachy. 51 // Check the mirror hierachy.
52 assertTrue(mirror instanceof debug.Mirror, 'Unexpected mirror hierarchy'); 52 assertTrue(mirror instanceof debug.Mirror, 'Unexpected mirror hierachy');
53 assertTrue(mirror instanceof debug.ValueMirror, 'Unexpected mirror hierarchy') ; 53 assertTrue(mirror instanceof debug.ValueMirror, 'Unexpected mirror hierachy');
54 assertTrue(mirror instanceof debug.ObjectMirror, 'Unexpected mirror hierarchy' ); 54 assertTrue(mirror instanceof debug.ObjectMirror, 'Unexpected mirror hierachy') ;
55 55
56 // Check the mirror properties. 56 // Check the mirror properties.
57 assertTrue(mirror.isObject(), 'Unexpected mirror'); 57 assertTrue(mirror.isObject(), 'Unexpected mirror');
58 assertEquals('object', mirror.type(), 'Unexpected mirror type'); 58 assertEquals('object', mirror.type(), 'Unexpected mirror type');
59 assertFalse(mirror.isPrimitive(), 'Unexpected primitive mirror'); 59 assertFalse(mirror.isPrimitive(), 'Unexpected primitive mirror');
60 assertEquals(cls_name, mirror.className(), 'Unexpected mirror class name'); 60 assertEquals(cls_name, mirror.className(), 'Unexpected mirror class name');
61 assertTrue(mirror.constructorFunction() instanceof debug.ObjectMirror, 'Unexpe cted mirror hierarchy'); 61 assertTrue(mirror.constructorFunction() instanceof debug.ObjectMirror, 'Unexpe cted mirror hierachy');
62 assertEquals(ctor_name, mirror.constructorFunction().name(), 'Unexpected const ructor function name'); 62 assertEquals(ctor_name, mirror.constructorFunction().name(), 'Unexpected const ructor function name');
63 assertTrue(mirror.protoObject() instanceof debug.Mirror, 'Unexpected mirror hi erarchy'); 63 assertTrue(mirror.protoObject() instanceof debug.Mirror, 'Unexpected mirror hi erachy');
64 assertTrue(mirror.prototypeObject() instanceof debug.Mirror, 'Unexpected mirro r hierarchy'); 64 assertTrue(mirror.prototypeObject() instanceof debug.Mirror, 'Unexpected mirro r hierachy');
65 assertFalse(mirror.hasNamedInterceptor(), 'No named interceptor expected'); 65 assertFalse(mirror.hasNamedInterceptor(), 'No named interceptor expected');
66 assertFalse(mirror.hasIndexedInterceptor(), 'No indexed interceptor expected') ; 66 assertFalse(mirror.hasIndexedInterceptor(), 'No indexed interceptor expected') ;
67 67
68 var names = mirror.propertyNames(); 68 var names = mirror.propertyNames();
69 var properties = mirror.properties(); 69 var properties = mirror.properties();
70 assertEquals(names.length, properties.length); 70 assertEquals(names.length, properties.length);
71 for (var i = 0; i < properties.length; i++) { 71 for (var i = 0; i < properties.length; i++) {
72 assertTrue(properties[i] instanceof debug.Mirror, 'Unexpected mirror hierarc hy'); 72 assertTrue(properties[i] instanceof debug.Mirror, 'Unexpected mirror hierach y');
73 assertTrue(properties[i] instanceof debug.PropertyMirror, 'Unexpected mirror hierarchy'); 73 assertTrue(properties[i] instanceof debug.PropertyMirror, 'Unexpected mirror hierachy');
74 assertEquals('property', properties[i].type(), 'Unexpected mirror type'); 74 assertEquals('property', properties[i].type(), 'Unexpected mirror type');
75 assertEquals(names[i], properties[i].name(), 'Unexpected property name'); 75 assertEquals(names[i], properties[i].name(), 'Unexpected property name');
76 } 76 }
77 77
78 var internalProperties = mirror.internalProperties();
79 for (var i = 0; i < internalProperties.length; i++) {
80 assertTrue(internalProperties[i] instanceof debug.Mirror, 'Unexpected mirror hierarchy');
81 assertTrue(internalProperties[i] instanceof debug.InternalPropertyMirror, 'U nexpected mirror hierarchy');
82 assertEquals('internalProperty', internalProperties[i].type(), 'Unexpected m irror type');
83 }
84
85 for (var p in obj) { 78 for (var p in obj) {
86 var property_mirror = mirror.property(p); 79 var property_mirror = mirror.property(p);
87 assertTrue(property_mirror instanceof debug.PropertyMirror); 80 assertTrue(property_mirror instanceof debug.PropertyMirror);
88 assertEquals(p, property_mirror.name()); 81 assertEquals(p, property_mirror.name());
89 // If the object has some special properties don't test for these. 82 // If the object has some special properties don't test for these.
90 if (!hasSpecialProperties) { 83 if (!hasSpecialProperties) {
91 assertEquals(0, property_mirror.attributes(), property_mirror.name()); 84 assertEquals(0, property_mirror.attributes(), property_mirror.name());
92 assertFalse(property_mirror.isReadOnly()); 85 assertFalse(property_mirror.isReadOnly());
93 assertTrue(property_mirror.isEnum()); 86 assertTrue(property_mirror.isEnum());
94 assertTrue(property_mirror.canDelete()); 87 assertTrue(property_mirror.canDelete());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 165
173 // Test a number of different objects. 166 // Test a number of different objects.
174 testObjectMirror({}, 'Object', 'Object'); 167 testObjectMirror({}, 'Object', 'Object');
175 testObjectMirror({'a':1,'b':2}, 'Object', 'Object'); 168 testObjectMirror({'a':1,'b':2}, 'Object', 'Object');
176 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object'); 169 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object');
177 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point'); 170 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point');
178 testObjectMirror(this, 'global', '', true); // Global object has special proper ties 171 testObjectMirror(this, 'global', '', true); // Global object has special proper ties
179 testObjectMirror(this.__proto__, 'Object', ''); 172 testObjectMirror(this.__proto__, 'Object', '');
180 testObjectMirror([], 'Array', 'Array'); 173 testObjectMirror([], 'Array', 'Array');
181 testObjectMirror([1,2], 'Array', 'Array'); 174 testObjectMirror([1,2], 'Array', 'Array');
182 testObjectMirror(Object(17), 'Number', 'Number');
183 175
184 // Test circular references. 176 // Test circular references.
185 o = {}; 177 o = {};
186 o.o = o; 178 o.o = o;
187 testObjectMirror(o, 'Object', 'Object'); 179 testObjectMirror(o, 'Object', 'Object');
188 180
189 // Test that non enumerable properties are part of the mirror 181 // Test that non enumerable properties are part of the mirror
190 global_mirror = debug.MakeMirror(this); 182 global_mirror = debug.MakeMirror(this);
191 assertEquals('property', global_mirror.property("Math").type()); 183 assertEquals('property', global_mirror.property("Math").type());
192 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes()); 184 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 223
232 // Test objects with native accessors. 224 // Test objects with native accessors.
233 mirror = debug.MakeMirror(new String('abc')); 225 mirror = debug.MakeMirror(new String('abc'));
234 assertTrue(mirror instanceof debug.ObjectMirror); 226 assertTrue(mirror instanceof debug.ObjectMirror);
235 assertFalse(mirror.property('length').hasGetter()); 227 assertFalse(mirror.property('length').hasGetter());
236 assertFalse(mirror.property('length').hasSetter()); 228 assertFalse(mirror.property('length').hasSetter());
237 assertTrue(mirror.property('length').isNative()); 229 assertTrue(mirror.property('length').isNative());
238 assertEquals('a', mirror.property(0).value().value()); 230 assertEquals('a', mirror.property(0).value().value());
239 assertEquals('b', mirror.property(1).value().value()); 231 assertEquals('b', mirror.property(1).value().value());
240 assertEquals('c', mirror.property(2).value().value()); 232 assertEquals('c', mirror.property(2).value().value());
241
242 // Test value wrapper internal properties.
243 mirror = debug.MakeMirror(Object("Capybara"));
244 var ip = mirror.internalProperties();
245 assertEquals(1, ip.length);
246 assertEquals("[[PrimitiveValue]]", ip[0].name());
247 assertEquals("string", ip[0].value().type());
248 assertEquals("Capybara", ip[0].value().value());
249
250 // Test bound function internal properties.
251 mirror = debug.MakeMirror(Number.bind(Array, 2));
252 ip = mirror.internalProperties();
253 assertEquals(3, ip.length);
254 var property_map = {};
255 for (var i = 0; i < ip.length; i++) {
256 property_map[ip[i].name()] = ip[i];
257 }
258 assertTrue("[[BoundThis]]" in property_map);
259 assertEquals("function", property_map["[[BoundThis]]"].value().type());
260 assertEquals(Array, property_map["[[BoundThis]]"].value().value());
261 assertTrue("[[TargetFunction]]" in property_map);
262 assertEquals("function", property_map["[[TargetFunction]]"].value().type());
263 assertEquals(Number, property_map["[[TargetFunction]]"].value().value());
264 assertTrue("[[BoundArgs]]" in property_map);
265 assertEquals("object", property_map["[[BoundArgs]]"].value().type());
266 assertEquals(1, property_map["[[BoundArgs]]"].value().value().length);
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698