Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: test/checker/checker_test.dart

Issue 1121993004: Inference through conditional expressions (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/checker/rules.dart ('k') | test/dart_codegen/expect/async/stream_controller.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'package:dev_compiler/src/testing.dart'; 10 import 'package:dev_compiler/src/testing.dart';
11 11
12 import '../test_util.dart'; 12 import '../test_util.dart';
13 13
14 void main() { 14 void main() {
15 configureTest(); 15 configureTest();
16 16
17 test('ternary operator', () {
18 testChecker({
19 '/main.dart': '''
20 abstract class Comparable<T> {
21 int compareTo(T other);
22 static int compare(Comparable a, Comparable b) => a.compareTo(b);
23 }
24 typedef int Comparator<T>(T a, T b);
25
26 typedef bool _Predicate<T>(T value);
27
28 class SplayTreeMap<K, V> {
29 Comparator<K> _comparator;
30 _Predicate _validKey;
31
32 // Initializing _comparator needs a cast, since K may not always be
33 // Comparable.
34 // Initializing _validKey shouldn't need a cast. Currently
35 // it requires inference to work because of dartbug.com/23381
36 SplayTreeMap([int compare(K key1, K key2),
37 bool isValidKey(potentialKey)]) {
38 : _comparator = /*warning:DownCastComposite*/(compare == null) ? Com parable.compare : compare,
39 _validKey = /*info:InferredType should be pass*/(isValidKey != nul l) ? isValidKey : ((v) => true);
40 }
41 }
42 void main() {
43 }
44 '''
45 });
46 });
47
17 test('dynamic invocation', () { 48 test('dynamic invocation', () {
18 testChecker({ 49 testChecker({
19 '/main.dart': ''' 50 '/main.dart': '''
20 51
21 class A { 52 class A {
22 dynamic call(dynamic x) => x; 53 dynamic call(dynamic x) => x;
23 } 54 }
24 class B extends A { 55 class B extends A {
25 int call(int x) => x; 56 int call(int x) => x;
26 double col(double x) => x; 57 double col(double x) => x;
(...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 f = bar as II2D; 2913 f = bar as II2D;
2883 f = bar as DD2I; 2914 f = bar as DD2I;
2884 f = bar as DI2D; 2915 f = bar as DI2D;
2885 f = bar as ID2D; 2916 f = bar as ID2D;
2886 f = bar as DD2D; 2917 f = bar as DD2D;
2887 } 2918 }
2888 ''' 2919 '''
2889 }); 2920 });
2890 }); 2921 });
2891 } 2922 }
OLDNEW
« no previous file with comments | « lib/src/checker/rules.dart ('k') | test/dart_codegen/expect/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698