| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 'package:dev_compiler/runtime/dart_logging_runtime.dart' as devc; | 5 import 'package:dev_compiler/runtime/dart_logging_runtime.dart' as devc; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 | 7 |
| 8 class A<T> { | 8 class A<T> { |
| 9 T x; | 9 T x; |
| 10 A(this.x); | 10 A(this.x); |
| 11 } | 11 } |
| 12 | 12 |
| 13 class B extends A<String> { | 13 class B extends A<String> { |
| 14 B() : super("B!"); | 14 B() : super("B!"); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void runTest() { | 17 void runTest() { |
| 18 var astring = new A<String>("").runtimeType; | 18 var astring = new A<String>("").runtimeType; |
| 19 var l = [new A<String>("hello"), new A("world"), new B(), 42]; | 19 var l = [new A<String>("hello"), new A("world"), new B(), 42]; |
| 20 for (var item in l) { | 20 for (var item in l) { |
| 21 try { | 21 try { |
| 22 devc.cast(item, astring); | 22 devc.cast(item, dynamic, astring); |
| 23 } catch (e) { | 23 } catch (e) { |
| 24 // Do nothing | 24 // Do nothing |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 final expected = ''' | 29 final expected = ''' |
| 30 Key dart_logging_runtime_test.dart 18:15 in runTest: | 30 Key test/runtime/dart_logging_runtime_test.dart 22:16 in runTest: |
| 31 - success: 2 (0.5) | 31 - static type: A<String> |
| 32 - failure: 1 (0.25) | 32 - runtime types: {A, int} |
| 33 - mismatch: 1 (0.25) | 33 - success: 0 (0.0) |
| 34 - failure: 1 (0.5) |
| 35 - mismatch: 1 (0.5) |
| 34 - error: 0 (0.0) | 36 - error: 0 (0.0) |
| 35 '''; | 37 '''; |
| 36 | 38 |
| 37 void main() { | 39 void main() { |
| 38 test('summary', () { | 40 test('summary', () { |
| 39 runTest(); | 41 runTest(); |
| 40 var output = devc.summary(); | 42 var output = devc.summary(); |
| 41 expect(output, equals(expected)); | 43 expect(output, equals(expected)); |
| 42 }); | 44 }); |
| 43 | 45 |
| 44 test('handler', () { | 46 test('handler', () { |
| 45 int devcFailures = 0; | 47 int devcFailures = 0; |
| 46 int dartFailures = 0; | 48 int dartFailures = 0; |
| 47 devc.castRecordHandler = (String key, devc.CastRecord record) { | 49 devc.castRecordHandler = (String key, devc.CastRecord record) { |
| 48 devcFailures += record.soundCast ? 0 : 1; | 50 devcFailures += record.soundCast ? 0 : 1; |
| 49 dartFailures += record.dartCast ? 0 : 1; | 51 dartFailures += record.dartCast ? 0 : 1; |
| 50 }; | 52 }; |
| 51 runTest(); | 53 runTest(); |
| 52 expect(devcFailures, equals(2)); | 54 expect(devcFailures, equals(2)); |
| 53 expect(dartFailures, equals(1)); | 55 expect(dartFailures, equals(1)); |
| 54 }); | 56 }); |
| 55 } | 57 } |
| OLD | NEW |