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