| 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 // Test code | 5 // Test code |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 import 'package:dev_compiler/config.dart'; |
| 9 import 'package:dev_compiler/runtime/dart_runtime.dart'; | 10 import 'package:dev_compiler/runtime/dart_runtime.dart'; |
| 10 | 11 |
| 12 final bool intIsNonNullable = TypeOptions.NONNULLABLE_TYPES.contains('int'); |
| 13 final bool doubleIsNonNullable = TypeOptions.NONNULLABLE_TYPES.contains('double'
); |
| 14 |
| 11 class A { | 15 class A { |
| 12 int x; | 16 int x; |
| 13 } | 17 } |
| 14 | 18 |
| 15 class B extends A { | 19 class B extends A { |
| 16 int y; | 20 int y; |
| 17 } | 21 } |
| 18 | 22 |
| 19 class C extends B { | 23 class C extends B { |
| 20 int z; | 24 int z; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 88 |
| 85 checkType(5, int); | 89 checkType(5, int); |
| 86 checkType(5, dynamic); | 90 checkType(5, dynamic); |
| 87 checkType(5, Object); | 91 checkType(5, Object); |
| 88 checkType(5, num); | 92 checkType(5, num); |
| 89 | 93 |
| 90 checkType(5, bool, false); | 94 checkType(5, bool, false); |
| 91 checkType(5, String, false); | 95 checkType(5, String, false); |
| 92 | 96 |
| 93 expect(cast(5, int), equals(5)); | 97 expect(cast(5, int), equals(5)); |
| 94 expect(() => cast(null, int), throws); | 98 if (intIsNonNullable) { |
| 99 expect(() => cast(null, int), throws); |
| 100 } else { |
| 101 expect(cast(null, int), equals(null)); |
| 102 } |
| 95 }); | 103 }); |
| 96 | 104 |
| 97 test('dynamic', () { | 105 test('dynamic', () { |
| 98 expect(isGroundType(dynamic), isTrue); | 106 expect(isGroundType(dynamic), isTrue); |
| 99 checkType(new Object(), dynamic); | 107 checkType(new Object(), dynamic); |
| 100 checkType(null, dynamic); | 108 checkType(null, dynamic); |
| 101 | 109 |
| 102 expect(cast(null, dynamic), equals(null)); | 110 expect(cast(null, dynamic), equals(null)); |
| 103 }); | 111 }); |
| 104 | 112 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 test('arity', () { | 266 test('arity', () { |
| 259 checkArity(bar1, 2, 2); | 267 checkArity(bar1, 2, 2); |
| 260 checkArity(bar4, 2, 2); | 268 checkArity(bar4, 2, 2); |
| 261 checkArity(bar6, 3, 3); | 269 checkArity(bar6, 3, 3); |
| 262 checkArity(bar7, 2, 3); | 270 checkArity(bar7, 2, 3); |
| 263 checkArity(bar8, 2, 2); | 271 checkArity(bar8, 2, 2); |
| 264 checkArity(() {}, 0, 0); | 272 checkArity(() {}, 0, 0); |
| 265 checkArity((a, [b]) {}, 1, 2); | 273 checkArity((a, [b]) {}, 1, 2); |
| 266 }); | 274 }); |
| 267 } | 275 } |
| OLD | NEW |