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 @MirrorsUsed(symbols: 'foo') | 5 @MirrorsUsed(symbols: 'foo') |
6 import 'dart:mirrors'; | 6 import 'dart:mirrors'; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 | 10 |
11 class A { | 11 class A { |
12 noSuchMethod(Invocation invocation) { | 12 noSuchMethod(Invocation invocation) { |
13 return MirrorSystem.getName(invocation.memberName); | 13 return MirrorSystem.getName(invocation.memberName); |
14 } | 14 } |
15 } | 15 } |
16 | 16 |
17 var lines = []; | 17 var lines = []; |
18 capturePrint(Zone self, ZoneDelegate parent, Zone origin, line) { | 18 capturePrint(Zone self, ZoneDelegate parent, Zone origin, line) { |
19 lines.add(line); | 19 lines.add(line); |
20 } | 20 } |
21 | 21 |
22 runTests() { | 22 runTests() { |
23 // "foo" is in MirrorsUsed and should therefore always work. | 23 // "foo" is in MirrorsUsed and should therefore always work. |
24 Expect.equals("foo", new A().foo); | 24 Expect.equals("foo", new A().foo); |
25 Expect.isTrue(lines.isEmpty); | 25 Expect.isTrue(lines.isEmpty); |
26 var barResult = new A().bar; | 26 var barResult = new A().bar; |
27 Expect.equals("bar", barResult); | 27 Expect.equals("bar", barResult); /// minif: ok |
28 | 28 |
29 /// minif: ok | |
30 Expect.isTrue(lines.length == 1); | 29 Expect.isTrue(lines.length == 1); |
31 var line = lines.first; | 30 var line = lines.first; |
32 Expect.isTrue(line.contains("Warning") && | 31 Expect.isTrue(line.contains("Warning") && |
33 line.contains("bar") && | 32 line.contains("bar") && /// minif: continued |
34 | |
35 /// minif: continued | |
36 line.contains("minif")); | 33 line.contains("minif")); |
37 } | 34 } |
38 | 35 |
39 main() { | 36 main() { |
40 runZoned(runTests, | 37 runZoned(runTests, |
41 zoneSpecification: new ZoneSpecification(print: capturePrint)); | 38 zoneSpecification: new ZoneSpecification(print: capturePrint)); |
42 } | 39 } |
OLD | NEW |