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