Chromium Code Reviews| 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/config.dart'; |
| 10 import 'package:dev_compiler/runtime/dart_runtime.dart'; | 10 import 'package:dev_compiler/runtime/dart_runtime.dart'; |
| 11 | 11 |
| 12 final bool intIsNonNullable = TypeOptions.NONNULLABLE_TYPES.contains('int'); | 12 final bool intIsNonNullable = TypeOptions.NONNULLABLE_TYPES.contains('int'); |
| 13 final bool doubleIsNonNullable = TypeOptions.NONNULLABLE_TYPES.contains('double' ); | 13 final bool doubleIsNonNullable = |
|
Jennifer Messerly
2015/05/15 18:12:13
formatted this file by accident. Seems worth keepi
| |
| 14 TypeOptions.NONNULLABLE_TYPES.contains('double'); | |
| 14 | 15 |
| 15 class A { | 16 class A { |
| 16 int x; | 17 int x; |
| 17 } | 18 } |
| 18 | 19 |
| 19 class B extends A { | 20 class B extends A { |
| 20 int y; | 21 int y; |
| 21 } | 22 } |
| 22 | 23 |
| 23 class C extends B { | 24 class C extends B { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 50 class Bar { | 51 class Bar { |
| 51 B call(B b, String s) => null; | 52 B call(B b, String s) => null; |
| 52 } | 53 } |
| 53 | 54 |
| 54 class Baz { | 55 class Baz { |
| 55 Foo call = (B b, String s) => null; | 56 Foo call = (B b, String s) => null; |
| 56 } | 57 } |
| 57 | 58 |
| 58 class Checker<T> { | 59 class Checker<T> { |
| 59 void isGround(bool expected) => expect(isGroundType(T), equals(expected)); | 60 void isGround(bool expected) => expect(isGroundType(T), equals(expected)); |
| 60 void isGroundList(bool expected) => expect(isGroundType(new List<T>().runtimeT ype), equals(expected)); | 61 void isGroundList(bool expected) => |
| 62 expect(isGroundType(new List<T>().runtimeType), equals(expected)); | |
| 61 void check(x, bool expected) => checkType(x, T, expected); | 63 void check(x, bool expected) => checkType(x, T, expected); |
| 62 void checkList(x, bool expected) => checkType(x, type((List<T> _) {}), expecte d); | 64 void checkList(x, bool expected) => |
| 65 checkType(x, type((List<T> _) {}), expected); | |
| 63 } | 66 } |
| 64 | 67 |
| 65 bool dartIs(expr, Type type) { | 68 bool dartIs(expr, Type type) { |
| 66 var exprMirror = reflectType(expr.runtimeType); | 69 var exprMirror = reflectType(expr.runtimeType); |
| 67 var typeMirror = reflectType(type); | 70 var typeMirror = reflectType(type); |
| 68 return exprMirror.isSubtypeOf(typeMirror); | 71 return exprMirror.isSubtypeOf(typeMirror); |
| 69 } | 72 } |
| 70 | 73 |
| 71 void checkType(x, Type type, [bool expectedTrue = true]) { | 74 void checkType(x, Type type, [bool expectedTrue = true]) { |
| 72 var isGround = isGroundType(type); | 75 var isGround = isGroundType(type); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 | 326 |
| 324 var objectChecker = new Checker<Object>(); | 327 var objectChecker = new Checker<Object>(); |
| 325 objectChecker.isGround(true); | 328 objectChecker.isGround(true); |
| 326 objectChecker.isGroundList(true); | 329 objectChecker.isGroundList(true); |
| 327 | 330 |
| 328 objectChecker.check(5, true); | 331 objectChecker.check(5, true); |
| 329 objectChecker.check("hello", true); | 332 objectChecker.check("hello", true); |
| 330 objectChecker.check(null, true); | 333 objectChecker.check(null, true); |
| 331 }); | 334 }); |
| 332 } | 335 } |
| OLD | NEW |