| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library test; | 5 library test; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
| 9 | 9 |
| 10 typedef int _F(int); | 10 typedef int _F(int); |
| 11 | 11 |
| 12 class _C<_T> { | 12 class _C<_T> { |
| 13 get g {} | 13 get g {} |
| 14 set s(x) {} | 14 set s(x) {} |
| 15 m(_p) {} | 15 m(_p) {} |
| 16 get _g {} | 16 get _g {} |
| 17 set _s(x) {} | 17 set _s(x) {} |
| 18 _m() {} | 18 _m() {} |
| 19 } | 19 } |
| 20 | 20 |
| 21 main() { | 21 main() { |
| 22 // Test private symbols are distinct across libraries, and the same within a | 22 // Test private symbols are distinct across libraries, and the same within a |
| 23 // library when created multiple ways. Test the string can be properly | 23 // library when created multiple ways. Test the string can be properly |
| 24 // extracted. | 24 // extracted. |
| 25 LibraryMirror libcore = currentMirrorSystem().findLibrary(#dart.core).single; | 25 LibraryMirror libcore = currentMirrorSystem().findLibrary(#dart.core); |
| 26 LibraryMirror libmath = currentMirrorSystem().findLibrary(#dart.math).single; | 26 LibraryMirror libmath = currentMirrorSystem().findLibrary(#dart.math); |
| 27 LibraryMirror libtest = currentMirrorSystem().findLibrary(#test).single; | 27 LibraryMirror libtest = currentMirrorSystem().findLibrary(#test); |
| 28 | 28 |
| 29 Symbol corefoo = MirrorSystem.getSymbol('foo', libcore); | 29 Symbol corefoo = MirrorSystem.getSymbol('foo', libcore); |
| 30 Symbol mathfoo = MirrorSystem.getSymbol('foo', libmath); | 30 Symbol mathfoo = MirrorSystem.getSymbol('foo', libmath); |
| 31 Symbol testfoo = MirrorSystem.getSymbol('foo', libtest); | 31 Symbol testfoo = MirrorSystem.getSymbol('foo', libtest); |
| 32 | 32 |
| 33 Expect.equals(corefoo, mathfoo); | 33 Expect.equals(corefoo, mathfoo); |
| 34 Expect.equals(mathfoo, testfoo); | 34 Expect.equals(mathfoo, testfoo); |
| 35 Expect.equals(testfoo, corefoo); | 35 Expect.equals(testfoo, corefoo); |
| 36 | 36 |
| 37 Expect.equals('foo', MirrorSystem.getName(corefoo)); | 37 Expect.equals('foo', MirrorSystem.getName(corefoo)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 Expect.throws(() => MirrorSystem.getSymbol('_private'), | 118 Expect.throws(() => MirrorSystem.getSymbol('_private'), |
| 119 (e) => e is ArgumentError); | 119 (e) => e is ArgumentError); |
| 120 | 120 |
| 121 var notALibraryMirror = 7; | 121 var notALibraryMirror = 7; |
| 122 Expect.throws(() => MirrorSystem.getSymbol('_private', notALibraryMirror), | 122 Expect.throws(() => MirrorSystem.getSymbol('_private', notALibraryMirror), |
| 123 (e) => e is ArgumentError || e is TypeError); | 123 (e) => e is ArgumentError || e is TypeError); |
| 124 | 124 |
| 125 Expect.throws(() => MirrorSystem.getSymbol('public', notALibraryMirror), | 125 Expect.throws(() => MirrorSystem.getSymbol('public', notALibraryMirror), |
| 126 (e) => e is ArgumentError || e is TypeError); | 126 (e) => e is ArgumentError || e is TypeError); |
| 127 } | 127 } |
| OLD | NEW |