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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override |
5 | 5 |
6 library inbound_references_test; | 6 library inbound_references_test; |
7 | 7 |
8 import 'package:observatory/service_io.dart'; | 8 import 'package:observatory/service_io.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'test_helper.dart'; | 10 import 'test_helper.dart'; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 copyingBlock = genCopyingBlock(); | 46 copyingBlock = genCopyingBlock(); |
47 fullBlock = genFullBlock(); | 47 fullBlock = genFullBlock(); |
48 fullBlockWithChain = genFullBlockWithChain(); | 48 fullBlockWithChain = genFullBlockWithChain(); |
49 } | 49 } |
50 | 50 |
51 var tests = [ | 51 var tests = [ |
52 | 52 |
53 (Isolate isolate) => | 53 (Isolate isolate) => |
54 isolate.rootLibrary.load().then((Library lib) { | 54 isolate.rootLibrary.load().then((Library lib) { |
55 Field field = lib.variables.singleWhere((v) => v.name == 'cleanBlock'); | 55 Field field = lib.variables.singleWhere((v) => v.name == 'cleanBlock'); |
56 return field.value.load().then((Instance block) { | 56 return field.load().then((_) { |
57 expect(block.isClosure, isTrue); | 57 return field.staticValue.load().then((Instance block) { |
58 expect(block.context.isContext, isTrue); | 58 expect(block.isClosure, isTrue); |
59 expect(block.context.length, equals(0)); | 59 expect(block.context.isContext, isTrue); |
60 return block.context.load().then((Context ctxt) { | 60 expect(block.context.length, equals(0)); |
61 expect(ctxt.parentContext.isNull, isTrue); | 61 return block.context.load().then((Context ctxt) { |
| 62 expect(ctxt.parentContext.isNull, isTrue); |
| 63 }); |
62 }); | 64 }); |
63 }); | 65 }); |
64 }), | 66 }), |
65 | 67 |
66 (Isolate isolate) => | 68 (Isolate isolate) => |
67 isolate.rootLibrary.load().then((Library lib) { | 69 isolate.rootLibrary.load().then((Library lib) { |
68 Field field = lib.variables.singleWhere((v) => v.name == 'copyingBlock'); | 70 Field field = lib.variables.singleWhere((v) => v.name == 'copyingBlock'); |
69 return field.value.load().then((Instance block) { | 71 return field.load().then((_) { |
70 expect(block.isClosure, isTrue); | 72 return field.staticValue.load().then((Instance block) { |
71 expect(block.context.isContext, isTrue); | 73 expect(block.isClosure, isTrue); |
72 expect(block.context.length, equals(1)); | 74 expect(block.context.isContext, isTrue); |
73 return block.context.load().then((Context ctxt) { | 75 expect(block.context.length, equals(1)); |
74 expect(ctxt.variables.single['value'].isString, isTrue); | 76 return block.context.load().then((Context ctxt) { |
75 expect(ctxt.variables.single['value'].valueAsString, equals('I could be
copied into the block')); | 77 expect(ctxt.variables.single['value'].isString, isTrue); |
76 expect(ctxt.parentContext.isContext, isTrue); | 78 expect(ctxt.variables.single['value'].valueAsString, equals('I could b
e copied into the block')); |
77 expect(ctxt.parentContext.length, equals(0)); | 79 expect(ctxt.parentContext.isContext, isTrue); |
78 return ctxt.parentContext.load().then((Context outerCtxt) { | 80 expect(ctxt.parentContext.length, equals(0)); |
79 expect(outerCtxt.parentContext.isNull, isTrue); | 81 return ctxt.parentContext.load().then((Context outerCtxt) { |
| 82 expect(outerCtxt.parentContext.isNull, isTrue); |
| 83 }); |
80 }); | 84 }); |
81 }); | 85 }); |
82 }); | 86 }); |
83 }), | 87 }), |
84 | 88 |
85 (Isolate isolate) => | 89 (Isolate isolate) => |
86 isolate.rootLibrary.load().then((Library lib) { | 90 isolate.rootLibrary.load().then((Library lib) { |
87 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlock'); | 91 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlock'); |
88 return field.value.load().then((Instance block) { | 92 return field.load().then((_) { |
89 expect(block.isClosure, isTrue); | 93 return field.staticValue.load().then((Instance block) { |
90 expect(block.context.isContext, isTrue); | 94 expect(block.isClosure, isTrue); |
91 expect(block.context.length, equals(1)); | 95 expect(block.context.isContext, isTrue); |
92 return block.context.load().then((ctxt) { | 96 expect(block.context.length, equals(1)); |
93 expect(ctxt.variables.single['value'].isInt, isTrue); | 97 return block.context.load().then((ctxt) { |
94 expect(ctxt.variables.single['value'].valueAsString, equals('43')); | 98 expect(ctxt.variables.single['value'].isInt, isTrue); |
95 expect(ctxt.parentContext.isContext, isTrue); | 99 expect(ctxt.variables.single['value'].valueAsString, equals('43')); |
96 expect(ctxt.parentContext.length, equals(0)); | 100 expect(ctxt.parentContext.isContext, isTrue); |
97 return ctxt.parentContext.load().then((Context outerCtxt) { | 101 expect(ctxt.parentContext.length, equals(0)); |
98 expect(outerCtxt.parentContext.isNull, isTrue); | 102 return ctxt.parentContext.load().then((Context outerCtxt) { |
| 103 expect(outerCtxt.parentContext.isNull, isTrue); |
| 104 }); |
99 }); | 105 }); |
100 }); | 106 }); |
101 }); | 107 }); |
102 }), | 108 }), |
103 | 109 |
104 (Isolate isolate) => | 110 (Isolate isolate) => |
105 isolate.rootLibrary.load().then((Library lib) { | 111 isolate.rootLibrary.load().then((Library lib) { |
106 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlockWithChain
'); | 112 Field field = lib.variables.singleWhere((v) => v.name == 'fullBlockWithChain
'); |
107 return field.value.load().then((Instance block) { | 113 return field.load().then((_) { |
108 expect(block.isClosure, isTrue); | 114 return field.staticValue.load().then((Instance block) { |
109 expect(block.context.isContext, isTrue); | 115 expect(block.isClosure, isTrue); |
110 expect(block.context.length, equals(1)); | 116 expect(block.context.isContext, isTrue); |
111 return block.context.load().then((Context ctxt) { | 117 expect(block.context.length, equals(1)); |
112 expect(ctxt.variables.single['value'].isInt, isTrue); | 118 return block.context.load().then((Context ctxt) { |
113 expect(ctxt.variables.single['value'].valueAsString, equals('4201')); | 119 expect(ctxt.variables.single['value'].isInt, isTrue); |
114 expect(ctxt.parentContext.isContext, isTrue); | 120 expect(ctxt.variables.single['value'].valueAsString, equals('4201')); |
115 expect(ctxt.parentContext.length, equals(1)); | 121 expect(ctxt.parentContext.isContext, isTrue); |
116 return ctxt.parentContext.load().then((Context outerCtxt) { | 122 expect(ctxt.parentContext.length, equals(1)); |
117 expect(outerCtxt.variables.single['value'].isInt, isTrue); | 123 return ctxt.parentContext.load().then((Context outerCtxt) { |
118 expect(outerCtxt.variables.single['value'].valueAsString, equals('421'
)); | 124 expect(outerCtxt.variables.single['value'].isInt, isTrue); |
119 expect(outerCtxt.parentContext.isContext, isTrue); | 125 expect(outerCtxt.variables.single['value'].valueAsString, equals('42
1')); |
120 expect(outerCtxt.parentContext.length, equals(0)); | 126 expect(outerCtxt.parentContext.isContext, isTrue); |
121 return outerCtxt.parentContext.load().then((Context outerCtxt2) { | 127 expect(outerCtxt.parentContext.length, equals(0)); |
122 expect(outerCtxt2.parentContext.isNull, isTrue); | 128 return outerCtxt.parentContext.load().then((Context outerCtxt2) { |
| 129 expect(outerCtxt2.parentContext.isNull, isTrue); |
| 130 }); |
123 }); | 131 }); |
124 }); | 132 }); |
125 }); | 133 }); |
126 }); | 134 }); |
127 }), | 135 }), |
128 | 136 |
129 ]; | 137 ]; |
130 | 138 |
131 main(args) => runIsolateTests(args, tests, testeeBefore: script); | 139 main(args) => runIsolateTests(args, tests, testeeBefore: script); |
OLD | NEW |