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