| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // See inspector.txt for expected behavior. | 5 // See inspector.txt for expected behavior. |
| 6 | 6 |
| 7 library manual_inspector_test; | 7 library manual_inspector_test; |
| 8 | 8 |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:mirrors'; | 10 import 'dart:mirrors'; |
| 11 import 'dart:developer'; | 11 import 'dart:developer'; |
| 12 import 'dart:typed_data'; | 12 import 'dart:typed_data'; |
| 13 | 13 |
| 14 part 'inspector_part.dart'; | 14 part 'inspector_part.dart'; |
| 15 | 15 |
| 16 var libraryField; | 16 var libraryField; |
| 17 var node; | 17 var node; |
| 18 var uninitialized = new Object(); | 18 var uninitialized = new Object(); |
| 19 | 19 |
| 20 extractPrivateField(obj, name) { | 20 extractPrivateField(obj, name) { |
| 21 return reflect(obj) | 21 return reflect(obj).getField(MirrorSystem.getSymbol(name, reflect(obj).type.ow
ner)).reflectee; |
| 22 .getField(MirrorSystem.getSymbol(name, reflect(obj).type.owner)) | |
| 23 .reflectee; | |
| 24 } | 22 } |
| 25 | 23 |
| 26 class A<T> {} | 24 class A <T> {} |
| 27 | 25 class B <S extends num> {} |
| 28 class B<S extends num> {} | |
| 29 | 26 |
| 30 class S {} | 27 class S {} |
| 31 | |
| 32 class M {} | 28 class M {} |
| 33 | |
| 34 class MA extends S with M {} | 29 class MA extends S with M {} |
| 35 | 30 |
| 36 class Node { | 31 class Node { |
| 37 static var classField; | 32 static var classField; |
| 38 | 33 |
| 39 var nullable; | 34 var nullable; |
| 40 var mixedType; | 35 var mixedType; |
| 41 var array; | 36 var array; |
| 42 var bigint; | 37 var bigint; |
| 43 var blockClean; | 38 var blockClean; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return block; | 101 return block; |
| 107 } | 102 } |
| 108 | 103 |
| 109 genFullBlockWithChain() { | 104 genFullBlockWithChain() { |
| 110 var x = 0; | 105 var x = 0; |
| 111 outer() { | 106 outer() { |
| 112 var y = 0; | 107 var y = 0; |
| 113 block() => x++ + y++; | 108 block() => x++ + y++; |
| 114 return block; | 109 return block; |
| 115 } | 110 } |
| 116 | |
| 117 return outer; | 111 return outer; |
| 118 } | 112 } |
| 119 | 113 |
| 120 f(int x) { | 114 f(int x) { |
| 121 ++x; | 115 ++x; |
| 122 return x; | 116 return x; |
| 123 } | 117 } |
| 124 | 118 |
| 125 static staticMain() { | 119 static staticMain() { |
| 126 node.main(); | 120 node.main(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 140 | 134 |
| 141 array = new List(3); | 135 array = new List(3); |
| 142 array[0] = 1; | 136 array[0] = 1; |
| 143 array[1] = 2; | 137 array[1] = 2; |
| 144 array[2] = 3; | 138 array[2] = 3; |
| 145 bigint = 1 << 65; | 139 bigint = 1 << 65; |
| 146 blockClean = genCleanBlock(); | 140 blockClean = genCleanBlock(); |
| 147 blockCopying = genCopyingBlock(); | 141 blockCopying = genCopyingBlock(); |
| 148 blockFull = genFullBlock(); | 142 blockFull = genFullBlock(); |
| 149 blockFullWithChain = genFullBlockWithChain(); | 143 blockFullWithChain = genFullBlockWithChain(); |
| 150 boundedType = extractPrivateField( | 144 boundedType = extractPrivateField(reflect(new B<int>()).type.typeVariables.s
ingle, '_reflectee'); |
| 151 reflect(new B<int>()).type.typeVariables.single, '_reflectee'); | |
| 152 counter = new Counter("CounterName", "Counter description"); | 145 counter = new Counter("CounterName", "Counter description"); |
| 153 expando = new Expando("expando-name"); | 146 expando = new Expando("expando-name"); |
| 154 expando[array] = 'The weakly associated value'; | 147 expando[array] = 'The weakly associated value'; |
| 155 float32x4 = new Float32x4(0.0, -1.0, 3.14, 2e28); | 148 float32x4 = new Float32x4(0.0, -1.0, 3.14, 2e28); |
| 156 float64 = 3.14; | 149 float64 = 3.14; |
| 157 float64x2 = new Float64x2(0.0, 3.14); | 150 float64x2 = new Float64x2(0.0, 3.14); |
| 158 gauge = new Gauge("GaugeName", "Gauge description", 0.0, 100.0); | 151 gauge = new Gauge("GaugeName", "Gauge description", 0.0, 100.0); |
| 159 growableList = new List(); | 152 growableList = new List(); |
| 160 int32x4 = new Int32x4(0, 1, 10, 11); | 153 int32x4 = new Int32x4(0,1,10,11); |
| 161 map = { | 154 map = { "x-key": "x-value", "y-key": "y-value", "removed-key": "removed-valu
e" }; |
| 162 "x-key": "x-value", | |
| 163 "y-key": "y-value", | |
| 164 "removed-key": "removed-value" | |
| 165 }; | |
| 166 map.remove("removed-key"); | 155 map.remove("removed-key"); |
| 167 mint = 1 << 32; | 156 mint = 1 << 32; |
| 168 mirrorClass = reflectClass(Object); | 157 mirrorClass = reflectClass(Object); |
| 169 mirrorClosure = reflect(blockFull); | 158 mirrorClosure = reflect(blockFull); |
| 170 mirrorInstance = reflect("a reflectee"); | 159 mirrorInstance = reflect("a reflectee"); |
| 171 mirrorReference = extractPrivateField(mirrorClass, '_reflectee'); | 160 mirrorReference = extractPrivateField(mirrorClass, '_reflectee'); |
| 172 portReceive = new RawReceivePort(); | 161 portReceive = new RawReceivePort(); |
| 173 portSend = portReceive.sendPort; | 162 portSend = portReceive.sendPort; |
| 174 regex = new RegExp("a*b+c"); | 163 regex = new RegExp("a*b+c"); |
| 175 smi = 7; | 164 smi = 7; |
| 176 stacktrace = genStackTrace(); | 165 stacktrace = genStackTrace(); |
| 177 string = "Hello $smi ${smi.runtimeType}"; | 166 string = "Hello $smi ${smi.runtimeType}"; |
| 178 stringLatin1 = "blåbærgrød"; | 167 stringLatin1 = "blåbærgrød"; |
| 179 stringSnowflake = "❄"; | 168 stringSnowflake = "❄"; |
| 180 stringUnicode = "Îñţérñåţîöñåļîžåţîờñ"; | 169 stringUnicode = "Îñţérñåţîöñåļîžåţîờñ"; |
| 181 stringHebrew = "שלום רב שובך צפורה נחמדת"; // An example of Right-to-Left. | 170 stringHebrew = "שלום רב שובך צפורה נחמדת"; // An example of Right-to-Left. |
| 182 stringTrebleClef = "𝄞"; // An example of a surrogate pair. | 171 stringTrebleClef = "𝄞"; // An example of a surrogate pair. |
| 183 theFalse = false; | 172 theFalse = false; |
| 184 theNull = null; | 173 theNull = null; |
| 185 theTrue = true; | 174 theTrue = true; |
| 186 type = String; | 175 type = String; |
| 187 typeParameter = | 176 typeParameter = extractPrivateField(reflectClass(A).typeVariables.single, '_
reflectee'); |
| 188 extractPrivateField(reflectClass(A).typeVariables.single, '_reflectee'); | |
| 189 typedData = extractPrivateField(new ByteData(64), '_typedData'); | 177 typedData = extractPrivateField(new ByteData(64), '_typedData'); |
| 190 userTag = new UserTag("Example tag name"); | 178 userTag = new UserTag("Example tag name"); |
| 191 weakProperty = | 179 weakProperty = extractPrivateField(expando, '_data').firstWhere((e) => e !=
null); |
| 192 extractPrivateField(expando, '_data').firstWhere((e) => e != null); | |
| 193 | 180 |
| 194 Isolate.spawn(secondMain, "Hello2").then((otherIsolate) { | 181 Isolate.spawn(secondMain, "Hello2").then((otherIsolate) { |
| 195 isolate = otherIsolate; | 182 isolate = otherIsolate; |
| 196 portSend = otherIsolate.controlPort; | 183 portSend = otherIsolate.controlPort; |
| 197 capability = otherIsolate.terminateCapability; | 184 capability = otherIsolate.terminateCapability; |
| 198 }); | 185 }); |
| 199 Isolate.spawn(secondMain, "Hello3").then((otherIsolate) { | 186 Isolate.spawn(secondMain, "Hello3").then((otherIsolate) { |
| 200 isolate = otherIsolate; | 187 isolate = otherIsolate; |
| 201 portSend = otherIsolate.controlPort; | 188 portSend = otherIsolate.controlPort; |
| 202 capability = otherIsolate.terminateCapability; | 189 capability = otherIsolate.terminateCapability; |
| 203 }); | 190 }); |
| 204 | 191 |
| 205 print("Finished main"); | 192 print("Finished main"); |
| 206 busy(); | 193 busy(); |
| 207 } | 194 } |
| 208 | 195 |
| 209 busy() { | 196 busy() { |
| 210 var localVar = 0; | 197 var localVar = 0; |
| 211 while (true) { | 198 while (true) { |
| 212 localVar = (localVar + 1) & 0xFFFF; | 199 localVar = (localVar + 1) & 0xFFFF; |
| 213 } | 200 } |
| 214 } | 201 } |
| 215 } | 202 } |
| 216 | 203 |
| 217 secondMain(msg) { | 204 secondMain(msg) { |
| 218 print("Hello from second isolate"); | 205 print("Hello from second isolate"); |
| 219 } | 206 } |
| 220 | 207 |
| 221 var typed; | 208 var typed; |
| 222 | |
| 223 class Typed { | 209 class Typed { |
| 224 var float32List = new Float32List(16); | 210 var float32List = new Float32List(16); |
| 225 var float64List = new Float64List(16); | 211 var float64List = new Float64List(16); |
| 226 | 212 |
| 227 var int32x4 = new Int32x4(1, 2, 3, 4); | 213 var int32x4 = new Int32x4(1, 2, 3, 4); |
| 228 var float32x4 = new Float32x4.zero(); | 214 var float32x4 = new Float32x4.zero(); |
| 229 var float64x2 = new Float64x2.zero(); | 215 var float64x2 = new Float64x2.zero(); |
| 230 var int32x4List = new Int32x4List(16); | 216 var int32x4List = new Int32x4List(16); |
| 231 var float32x4List = new Float32x4List(16); | 217 var float32x4List = new Float32x4List(16); |
| 232 var float64x2List = new Float64x2List(16); | 218 var float64x2List = new Float64x2List(16); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 263 typed = new Typed(); | 249 typed = new Typed(); |
| 264 node = new Node(); | 250 node = new Node(); |
| 265 Node.staticMain(); | 251 Node.staticMain(); |
| 266 } | 252 } |
| 267 | 253 |
| 268 class C { | 254 class C { |
| 269 static doPrint() { | 255 static doPrint() { |
| 270 print("Original"); | 256 print("Original"); |
| 271 } | 257 } |
| 272 } | 258 } |
| OLD | NEW |