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 /// General type checking tests | 5 /// General type checking tests |
6 library dev_compiler.test.checker_test; | 6 library dev_compiler.test.checker_test; |
7 | 7 |
8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
9 | 9 |
10 import 'package:dev_compiler/src/testing.dart'; | 10 import 'package:dev_compiler/src/testing.dart'; |
11 import '../test_util.dart' show testDirectory; | |
11 | 12 |
12 void main() { | 13 void main() { |
13 test('ternary operator', () { | 14 test('ternary operator', () { |
14 testChecker({ | 15 testChecker({ |
15 '/main.dart': ''' | 16 '/main.dart': ''' |
16 abstract class Comparable<T> { | 17 abstract class Comparable<T> { |
17 int compareTo(T other); | 18 int compareTo(T other); |
18 static int compare(Comparable a, Comparable b) => a.compareTo(b); | 19 static int compare(Comparable a, Comparable b) => a.compareTo(b); |
19 } | 20 } |
20 typedef int Comparator<T>(T a, T b); | 21 typedef int Comparator<T>(T a, T b); |
(...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2888 | 2889 |
2889 typedef I2D(int x); | 2890 typedef I2D(int x); |
2890 typedef D2D(x); | 2891 typedef D2D(x); |
2891 typedef II2D(int x, int y); | 2892 typedef II2D(int x, int y); |
2892 typedef DI2D(x, int y); | 2893 typedef DI2D(x, int y); |
2893 typedef ID2D(int x, y); | 2894 typedef ID2D(int x, y); |
2894 typedef DD2D(x, y); | 2895 typedef DD2D(x, y); |
2895 | 2896 |
2896 int foo(int x) => x; | 2897 int foo(int x) => x; |
2897 int bar(int x, int y) => x + y; | 2898 int bar(int x, int y) => x + y; |
2898 | 2899 |
2899 void main() { | 2900 void main() { |
2900 bool b; | 2901 bool b; |
2901 b = /*severe:InvalidRuntimeCheckError*/foo is I2I; | 2902 b = /*severe:InvalidRuntimeCheckError*/foo is I2I; |
2902 b = /*severe:InvalidRuntimeCheckError*/foo is D2I; | 2903 b = /*severe:InvalidRuntimeCheckError*/foo is D2I; |
2903 b = /*severe:InvalidRuntimeCheckError*/foo is I2D; | 2904 b = /*severe:InvalidRuntimeCheckError*/foo is I2D; |
2904 b = foo is D2D; | 2905 b = foo is D2D; |
2905 | 2906 |
2906 b = /*severe:InvalidRuntimeCheckError*/bar is II2I; | 2907 b = /*severe:InvalidRuntimeCheckError*/bar is II2I; |
2907 b = /*severe:InvalidRuntimeCheckError*/bar is DI2I; | 2908 b = /*severe:InvalidRuntimeCheckError*/bar is DI2I; |
2908 b = /*severe:InvalidRuntimeCheckError*/bar is ID2I; | 2909 b = /*severe:InvalidRuntimeCheckError*/bar is ID2I; |
(...skipping 15 matching lines...) Expand all Loading... | |
2924 f = bar as ID2I; | 2925 f = bar as ID2I; |
2925 f = bar as II2D; | 2926 f = bar as II2D; |
2926 f = bar as DD2I; | 2927 f = bar as DD2I; |
2927 f = bar as DI2D; | 2928 f = bar as DI2D; |
2928 f = bar as ID2D; | 2929 f = bar as ID2D; |
2929 f = bar as DD2D; | 2930 f = bar as DD2D; |
2930 } | 2931 } |
2931 ''' | 2932 ''' |
2932 }); | 2933 }); |
2933 }); | 2934 }); |
2935 | |
2936 test('custom URL mappings', () => testChecker({ | |
2937 '/main.dart': ''' | |
2938 import 'dart:foobar' show Baz; | |
2939 main() { | |
2940 print(Baz.quux); | |
2941 }''' | |
2942 }, | |
2943 customUrlMappings: { | |
vsm
2015/06/03 15:37:47
indent seems a little weird here.
Jennifer Messerly
2015/06/03 16:24:11
that's what dart_style does. I think Bob is on it
| |
2944 'dart:foobar': '$testDirectory/checker/dart_foobar.dart' | |
2945 })); | |
2934 } | 2946 } |
OLD | NEW |