| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 | 8 |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
| 11 | 11 |
| 12 import 'package:polymer/src/mirror_loader.dart'; | 12 import 'package:polymer/src/mirror_loader.dart'; |
| 13 import 'mirror_loader_1.dart' as m1; | 13 import 'mirror_loader_1.dart' as m1; |
| 14 import 'mirror_loader_2.dart' as m2; | 14 import 'mirror_loader_2.dart' as m2; |
| 15 import 'mirror_loader_3.dart' as m3; | 15 import 'mirror_loader_3.dart' as m3; |
| 16 import 'mirror_loader_4.dart' as m4; | 16 import 'mirror_loader_4.dart' as m4; |
| 17 | 17 |
| 18 main() { | 18 main() { |
| 19 useHtmlConfiguration(); | 19 useHtmlConfiguration(); |
| 20 | 20 |
| 21 // Prevent unused import messages. |
| 22 m1.XA; |
| 23 m2.XA; |
| 24 m3.XB; |
| 25 m4.XA; |
| 26 |
| 21 test('registered correctly', () { | 27 test('registered correctly', () { |
| 22 expect(_discover(#mirror_loader_test1).length, 1); | 28 expect(_discover(#mirror_loader_test1).length, 1); |
| 23 expect(_discover(#mirror_loader_test2).length, 1); | 29 expect(_discover(#mirror_loader_test2).length, 1); |
| 24 }); | 30 }); |
| 25 | 31 |
| 26 test('parameterized custom tags are not registered', () { | 32 test('parameterized custom tags are not registered', () { |
| 27 runZoned(() { | 33 runZoned(() { |
| 28 expect(_discover(#mirror_loader_test3).length, 0); | 34 expect(_discover(#mirror_loader_test3).length, 0); |
| 29 }, onError: (e) { | 35 }, onError: (e) { |
| 30 expect(e is UnsupportedError, isTrue); | 36 expect(e is UnsupportedError, isTrue); |
| 31 expect('$e', contains( | 37 expect('$e', contains( |
| 32 'Custom element classes cannot have type-parameters: XB')); | 38 'Custom element classes cannot have type-parameters: XB')); |
| 33 }); | 39 }); |
| 34 }); | 40 }); |
| 35 | 41 |
| 36 test('registers correct types even when errors are found', () { | 42 test('registers correct types even when errors are found', () { |
| 37 runZoned(() { | 43 runZoned(() { |
| 38 expect(_discover(#mirror_loader_test4).length, 1); | 44 expect(_discover(#mirror_loader_test4).length, 1); |
| 39 }, onError: (e) { | 45 }, onError: (e) { |
| 40 expect(e is UnsupportedError, isTrue); | 46 expect(e is UnsupportedError, isTrue); |
| 41 expect('$e', contains( | 47 expect('$e', contains( |
| 42 'Custom element classes cannot have type-parameters: XB')); | 48 'Custom element classes cannot have type-parameters: XB')); |
| 43 }); | 49 }); |
| 44 }); | 50 }); |
| 45 } | 51 } |
| 46 | 52 |
| 47 final mirrors = currentMirrorSystem(); | 53 final mirrors = currentMirrorSystem(); |
| 48 _discover(Symbol name) => | 54 _discover(Symbol name) => |
| 49 discoverInitializers([mirrors.findLibrary(name).uri.toString()]); | 55 discoverInitializers([mirrors.findLibrary(name).uri.toString()]); |
| OLD | NEW |