OLD | NEW |
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 Loading... |
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 Loading... |
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()); |
OLD | NEW |