OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // See inspector.txt for expected behavior. | |
6 | |
7 library manual_inspector_test; | |
8 | |
9 import 'dart:isolate'; | |
10 import 'dart:mirrors'; | |
11 import 'dart:profiler'; | |
12 import 'dart:typed_data'; | |
13 | |
14 class A <T> {} | |
15 class B <S extends num> {} | |
16 | |
17 var array; | |
18 var bigint; | |
19 var blockClean; | |
20 var blockCopying; | |
21 var blockFull; | |
22 var blockFullWithChain; | |
23 var boundedType; | |
24 var capability; | |
25 var counter; | |
26 var expando; | |
27 var float32x4; | |
28 var float64; | |
29 var float64x2; | |
30 var gauge; | |
31 var growableList; | |
32 var int32x4; | |
33 var isolate; | |
34 var map; | |
35 var mint; | |
36 var mirrorClass; | |
37 var mirrorClosure; | |
38 var mirrorInstance; | |
39 var mirrorReference; | |
40 var portReceive; | |
41 var portSend; | |
42 var regex; | |
43 var smi; | |
44 var stacktrace; | |
45 var string; | |
46 var stringEscapedUnicodeEscape; | |
47 var stringHebrew; | |
48 var stringLatin1; | |
49 var stringMalformedLead; | |
50 var stringMalformedTrail; | |
51 var stringNewLinesAndTabs; | |
52 var stringNullInTheMiddle; | |
53 var stringSnowflake; | |
54 var stringTrebleClefs; | |
55 var stringUnicode; | |
56 var theFalse; | |
57 var theNull; | |
58 var theTrue; | |
59 var type; | |
60 var typeParameter; | |
61 var typedData; | |
62 var uninitialized = new Object(); | |
63 var userTag; | |
64 var weakProperty; | |
65 | |
66 extractPrivateField(obj, name) { | |
67 return reflect(obj).getField(MirrorSystem.getSymbol(name, reflect(obj).type.ow
ner)).reflectee; | |
68 } | |
69 | |
70 genStacktrace() { | |
71 try { | |
72 num.parse(','); | |
73 } catch (e, s) { | |
74 return s; | |
75 } | |
76 } | |
77 | |
78 genCleanBlock() { | |
79 block(x) => x; | |
80 return block; | |
81 } | |
82 | |
83 genCopyingBlock() { | |
84 final x = 'I could be copied down'; | |
85 block() => x; | |
86 return block; | |
87 } | |
88 | |
89 genFullBlock() { | |
90 var x = 0; | |
91 block() => x++; | |
92 return block; | |
93 } | |
94 | |
95 genFullBlockWithChain() { | |
96 var x = 0; | |
97 outer() { | |
98 var y = 0; | |
99 block() => x++ + y++; | |
100 return block; | |
101 } | |
102 return outer; | |
103 } | |
104 | |
105 secondMain(msg) { } | |
106 | |
107 main() { | |
108 print("Started main"); | |
109 | |
110 array = new List(1); | |
111 bigint = 1 << 65; | |
112 blockClean = genCleanBlock(); | |
113 blockCopying = genCopyingBlock(); | |
114 blockFull = genFullBlock(); | |
115 blockFullWithChain = genFullBlockWithChain(); | |
116 boundedType = extractPrivateField(reflect(new B<int>()).type.typeVariables.sin
gle, '_reflectee'); | |
117 counter = new Counter("CounterName", "Counter description"); | |
118 expando = new Expando("expando-name"); | |
119 expando[array] = 'The weakly associated value'; | |
120 float32x4 = new Float32x4.zero(); | |
121 float64 = 3.14; | |
122 float64x2 = new Float64x2.zero(); | |
123 gauge = new Gauge("GaugeName", "Gauge description", 0.0, 100.0); | |
124 growableList = new List(); | |
125 int32x4 = new Int32x4(0,0,0,0); | |
126 map = { "x":3, "y":4 }; | |
127 mint = 1 << 32; | |
128 mirrorClass = reflectClass(Object); | |
129 mirrorClosure = reflect(blockFull); | |
130 mirrorInstance = reflect("a reflectee"); | |
131 mirrorReference = extractPrivateField(mirrorClass, '_reflectee'); | |
132 portReceive = new RawReceivePort(); | |
133 regex = new RegExp("a*b+c"); | |
134 smi = 7; | |
135 stacktrace = genStacktrace(); | |
136 string = "Hello"; | |
137 stringEscapedUnicodeEscape = "Should not be A: \\u0041"; | |
138 stringHebrew = "שלום רב שובך צפורה נחמדת"; // Right-to-left text. | |
139 stringLatin1 = "blåbærgrød"; | |
140 stringMalformedLead = "before" + "𝄞"[0] + "after"; | |
141 stringMalformedTrail = "before" + "𝄞"[1] + "after"; | |
142 stringNewLinesAndTabs = "One fish\ttwo fish\nRed fish\tBlue fish\n"; | |
143 stringNullInTheMiddle = "There are four\u0000 words."; | |
144 stringSnowflake = "❄"; | |
145 stringTrebleClefs = "1𝄞2𝄞𝄞3𝄞𝄞𝄞"; // Surrogate pair. | |
146 stringUnicode = "Îñţérñåţîöñåļîžåţîờñ"; | |
147 theFalse = false; | |
148 theNull = null; | |
149 theTrue = true; | |
150 type = String; | |
151 typeParameter = extractPrivateField(reflectClass(A).typeVariables.single, '_re
flectee'); | |
152 typedData = extractPrivateField(new ByteData(64), '_typedData'); | |
153 userTag = new UserTag("Example tag name"); | |
154 weakProperty = extractPrivateField(expando, '_data').firstWhere((e) => e != nu
ll); | |
155 | |
156 Isolate.spawn(secondMain, "Hello").then((otherIsolate) { | |
157 isolate = otherIsolate; | |
158 portSend = otherIsolate.controlPort; | |
159 capability = otherIsolate.terminateCapability; | |
160 }); | |
161 | |
162 print("Finished main"); | |
163 } | |
OLD | NEW |