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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 o.__defineSetter__('c', function(){throw 'c';}); | 186 o.__defineSetter__('c', function(){throw 'c';}); |
187 testObjectMirror(o, 'Object', 'Object'); | 187 testObjectMirror(o, 'Object', 'Object'); |
188 mirror = debug.MakeMirror(o); | 188 mirror = debug.MakeMirror(o); |
189 // a has getter but no setter. | 189 // a has getter but no setter. |
190 assertTrue(mirror.property('a').hasGetter()); | 190 assertTrue(mirror.property('a').hasGetter()); |
191 assertFalse(mirror.property('a').hasSetter()); | 191 assertFalse(mirror.property('a').hasSetter()); |
192 assertEquals(debug.PropertyType.Callbacks, mirror.property('a').propertyType()); | 192 assertEquals(debug.PropertyType.Callbacks, mirror.property('a').propertyType()); |
193 assertEquals('function', mirror.property('a').getter().type()); | 193 assertEquals('function', mirror.property('a').getter().type()); |
194 assertEquals('undefined', mirror.property('a').setter().type()); | 194 assertEquals('undefined', mirror.property('a').setter().type()); |
195 assertEquals('function (){return \'a\';}', mirror.property('a').getter().source(
)); | 195 assertEquals('function (){return \'a\';}', mirror.property('a').getter().source(
)); |
196 assertEquals('a', mirror.property('a').value().value()); | |
197 assertFalse(mirror.property('a').isException()); | |
198 // b has setter but no getter. | 196 // b has setter but no getter. |
199 assertFalse(mirror.property('b').hasGetter()); | 197 assertFalse(mirror.property('b').hasGetter()); |
200 assertTrue(mirror.property('b').hasSetter()); | 198 assertTrue(mirror.property('b').hasSetter()); |
201 assertEquals(debug.PropertyType.Callbacks, mirror.property('b').propertyType()); | 199 assertEquals(debug.PropertyType.Callbacks, mirror.property('b').propertyType()); |
202 assertEquals('undefined', mirror.property('b').getter().type()); | 200 assertEquals('undefined', mirror.property('b').getter().type()); |
203 assertEquals('function', mirror.property('b').setter().type()); | 201 assertEquals('function', mirror.property('b').setter().type()); |
204 assertEquals('function (){}', mirror.property('b').setter().source()); | 202 assertEquals('function (){}', mirror.property('b').setter().source()); |
205 assertFalse(mirror.property('b').isException()); | 203 assertFalse(mirror.property('b').isException()); |
206 // c has both getter and setter. The getter throws an exception. | 204 // c has both getter and setter. The getter throws an exception. |
207 assertTrue(mirror.property('c').hasGetter()); | 205 assertTrue(mirror.property('c').hasGetter()); |
208 assertTrue(mirror.property('c').hasSetter()); | 206 assertTrue(mirror.property('c').hasSetter()); |
209 assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType()); | 207 assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType()); |
210 assertEquals('function', mirror.property('c').getter().type()); | 208 assertEquals('function', mirror.property('c').getter().type()); |
211 assertEquals('function', mirror.property('c').setter().type()); | 209 assertEquals('function', mirror.property('c').setter().type()); |
212 assertEquals('function (){throw \'c\';}', mirror.property('c').getter().source()
); | 210 assertEquals('function (){throw \'c\';}', mirror.property('c').getter().source()
); |
213 assertEquals('function (){throw \'c\';}', mirror.property('c').setter().source()
); | 211 assertEquals('function (){throw \'c\';}', mirror.property('c').setter().source()
); |
214 assertEquals('c', mirror.property('c').value().value()); | |
215 assertTrue(mirror.property('c').isException()); | |
216 | 212 |
217 // Test objects with native accessors. | 213 // Test objects with native accessors. |
218 mirror = debug.MakeMirror(new String('abc')); | 214 mirror = debug.MakeMirror(new String('abc')); |
219 assertTrue(mirror instanceof debug.ObjectMirror); | 215 assertTrue(mirror instanceof debug.ObjectMirror); |
220 assertFalse(mirror.property('length').hasGetter()); | 216 assertFalse(mirror.property('length').hasGetter()); |
221 assertFalse(mirror.property('length').hasSetter()); | 217 assertFalse(mirror.property('length').hasSetter()); |
222 assertTrue(mirror.property('length').isNative()); | 218 assertTrue(mirror.property('length').isNative()); |
223 assertEquals('a', mirror.property(0).value().value()); | 219 assertEquals('a', mirror.property(0).value().value()); |
224 assertEquals('b', mirror.property(1).value().value()); | 220 assertEquals('b', mirror.property(1).value().value()); |
225 assertEquals('c', mirror.property(2).value().value()); | 221 assertEquals('c', mirror.property(2).value().value()); |
OLD | NEW |