| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // Check the mirror properties. | 57 // Check the mirror properties. |
| 58 assertTrue(mirror.isArray(), 'Unexpected mirror'); | 58 assertTrue(mirror.isArray(), 'Unexpected mirror'); |
| 59 assertEquals('object', mirror.type(), 'Unexpected mirror type'); | 59 assertEquals('object', mirror.type(), 'Unexpected mirror type'); |
| 60 assertFalse(mirror.isPrimitive(), 'Unexpected primitive mirror'); | 60 assertFalse(mirror.isPrimitive(), 'Unexpected primitive mirror'); |
| 61 assertEquals('Array', mirror.className(), 'Unexpected mirror class name'); | 61 assertEquals('Array', mirror.className(), 'Unexpected mirror class name'); |
| 62 assertTrue(mirror.constructorFunction() instanceof debug.ObjectMirror, 'Unexpe
cted mirror hierachy'); | 62 assertTrue(mirror.constructorFunction() instanceof debug.ObjectMirror, 'Unexpe
cted mirror hierachy'); |
| 63 assertEquals('Array', mirror.constructorFunction().name(), 'Unexpected constru
ctor function name'); | 63 assertEquals('Array', mirror.constructorFunction().name(), 'Unexpected constru
ctor function name'); |
| 64 assertTrue(mirror.protoObject() instanceof debug.Mirror, 'Unexpected mirror hi
erachy'); | 64 assertTrue(mirror.protoObject() instanceof debug.Mirror, 'Unexpected mirror hi
erachy'); |
| 65 assertTrue(mirror.prototypeObject() instanceof debug.Mirror, 'Unexpected mirro
r hierachy'); | 65 assertTrue(mirror.prototypeObject() instanceof debug.Mirror, 'Unexpected mirro
r hierachy'); |
| 66 assertEquals(mirror.length(), a.length, "Length mismatch"); | 66 assertEquals(mirror.length(), a.length, "Length mismatch"); |
| 67 | 67 |
| 68 var indexedProperties = mirror.indexedPropertiesFromRange(); | 68 var indexedProperties = mirror.indexedPropertiesFromRange(); |
| 69 assertEquals(indexedProperties.length, a.length); | 69 assertEquals(indexedProperties.length, a.length); |
| 70 for (var i = 0; i < indexedProperties.length; i++) { | 70 for (var i = 0; i < indexedProperties.length; i++) { |
| 71 assertTrue(indexedProperties[i] instanceof debug.Mirror, 'Unexpected mirror
hierachy'); | 71 assertTrue(indexedProperties[i] instanceof debug.Mirror, 'Unexpected mirror
hierachy'); |
| 72 assertTrue(indexedProperties[i] instanceof debug.PropertyMirror, 'Unexpected
mirror hierachy'); | 72 assertTrue(indexedProperties[i] instanceof debug.PropertyMirror, 'Unexpected
mirror hierachy'); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Parse JSON representation and check. | 75 // Parse JSON representation and check. |
| 76 var fromJSON = eval('(' + json + ')'); | 76 var fromJSON = eval('(' + json + ')'); |
| 77 assertEquals('object', fromJSON.type, 'Unexpected mirror type in JSON'); | 77 assertEquals('object', fromJSON.type, 'Unexpected mirror type in JSON'); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 assertTrue(length_found, 'Property length not found'); | 105 assertTrue(length_found, 'Property length not found'); |
| 106 | 106 |
| 107 // Check that the serialization contains all names properties. | 107 // Check that the serialization contains all names properties. |
| 108 if (names) { | 108 if (names) { |
| 109 for (var i = 0; i < names.length; i++) { | 109 for (var i = 0; i < names.length; i++) { |
| 110 var found = false; | 110 var found = false; |
| 111 for (var j = 0; j < fromJSON.properties.length; j++) { | 111 for (var j = 0; j < fromJSON.properties.length; j++) { |
| 112 if (names[i] == fromJSON.properties[j].name) { | 112 if (names[i] == fromJSON.properties[j].name) { |
| 113 found = true; | 113 found = true; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 assertTrue(found, names[i]) | 116 assertTrue(found, names[i]) |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 // Test a number of different arrays. | 122 // Test a number of different arrays. |
| 123 testArrayMirror([]); | 123 testArrayMirror([]); |
| 124 testArrayMirror([1]); | 124 testArrayMirror([1]); |
| 125 testArrayMirror([1,2]); | 125 testArrayMirror([1,2]); |
| 126 testArrayMirror(["a", function(){}, [1,2], 2, /[ab]/]); | 126 testArrayMirror(["a", function(){}, [1,2], 2, /[ab]/]); |
| 127 | 127 |
| 128 a=[1]; | 128 a=[1]; |
| 129 a[100]=7; | 129 a[100]=7; |
| 130 testArrayMirror(a); | 130 testArrayMirror(a); |
| 131 | 131 |
| 132 a=[1,2,3]; | 132 a=[1,2,3]; |
| 133 a.x=2.2; | 133 a.x=2.2; |
| 134 a.y=function(){return null;} | 134 a.y=function(){return null;} |
| 135 testArrayMirror(a, ['x','y']); | 135 testArrayMirror(a, ['x','y']); |
| 136 | 136 |
| 137 var a = []; a.push(a); | 137 var a = []; a.push(a); |
| 138 testArrayMirror(a); | 138 testArrayMirror(a); |
| OLD | NEW |