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

Side by Side Diff: tests/lib_strong/async/future_or_non_strong_test.dart

Issue 2802973005: Migrate async tests to strong (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2016, 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 // In non strong-mode, `FutureOr` should just behave like dynamic.
6
7 import 'dart:async';
8 import 'package:expect/expect.dart';
9
10
11 typedef void FunTakes<T>(T x);
12 typedef T FunReturns<T>();
13
14 main() {
15 Expect.isTrue(499 is FutureOr);
16 Expect.isTrue(499 is FutureOr<String>);
17 Expect.isTrue(499 is FutureOr<int>);
18
19 Expect.isTrue(new Future.value(499) is FutureOr);
20 Expect.isTrue(new Future.value(499) is FutureOr<int>);
21 Expect.isTrue(new Future.value(499) is FutureOr<String>);
22
23
24 void foo(FutureOr x) {}
25
26 Expect.isTrue(foo is FunTakes<dynamic>);
27 Expect.isTrue(foo is FunTakes<Object>);
28 Expect.isTrue(foo is FunTakes<int>);
29 Expect.isTrue(foo is FunTakes<String>);
30 Expect.isTrue(foo is FunTakes<Future<int>>);
31 Expect.isTrue(foo is FunTakes<Future<String>>);
32 Expect.isTrue(foo is FunTakes<FutureOr<Object>>);
33 Expect.isTrue(foo is FunTakes<FutureOr<int>>);
34 Expect.isTrue(foo is FunTakes<FutureOr<String>>);
35 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<Object>>>);
36 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<int>>>);
37 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<String>>>);
38
39
40 FutureOr bar() => 499;
41
42 Expect.isTrue(bar is FunReturns<dynamic>);
43 Expect.isTrue(bar is FunReturns<Object>);
44 Expect.isTrue(bar is FunReturns<int>);
45 Expect.isTrue(bar is FunReturns<String>);
46 Expect.isTrue(bar is FunReturns<Future<int>>);
47 Expect.isTrue(bar is FunReturns<Future<String>>);
48 Expect.isTrue(bar is FunReturns<FutureOr<Object>>);
49 Expect.isTrue(bar is FunReturns<FutureOr<int>>);
50 Expect.isTrue(bar is FunReturns<FutureOr<String>>);
51 Expect.isTrue(bar is FunReturns<FutureOr<FutureOr<Object>>>);
52 Expect.isTrue(bar is FunReturns<FutureOr<FutureOr<int>>>);
53 Expect.isTrue(bar is FunReturns<FutureOr<FutureOr<String>>>);
54
55
56 void foo2(FutureOr<String> x) {}
57
58 Expect.isTrue(foo2 is FunTakes<dynamic>);
59 Expect.isTrue(foo2 is FunTakes<Object>);
60 Expect.isTrue(foo2 is FunTakes<int>);
61 Expect.isTrue(foo2 is FunTakes<String>);
62 Expect.isTrue(foo2 is FunTakes<Future<int>>);
63 Expect.isTrue(foo2 is FunTakes<Future<String>>);
64 Expect.isTrue(foo2 is FunTakes<FutureOr<Object>>);
65 Expect.isTrue(foo2 is FunTakes<FutureOr<int>>);
66 Expect.isTrue(foo2 is FunTakes<FutureOr<String>>);
67 Expect.isTrue(foo2 is FunTakes<FutureOr<FutureOr<Object>>>);
68 Expect.isTrue(foo2 is FunTakes<FutureOr<FutureOr<int>>>);
69 Expect.isTrue(foo2 is FunTakes<FutureOr<FutureOr<String>>>);
70
71
72 FutureOr<int> bar2() => 499;
73
74 Expect.isTrue(bar2 is FunReturns<dynamic>);
75 Expect.isTrue(bar2 is FunReturns<Object>);
76 Expect.isTrue(bar2 is FunReturns<int>);
77 Expect.isTrue(bar2 is FunReturns<String>);
78 Expect.isTrue(bar2 is FunReturns<Future<int>>);
79 Expect.isTrue(bar2 is FunReturns<Future<String>>);
80 Expect.isTrue(bar2 is FunReturns<FutureOr<Object>>);
81 Expect.isTrue(bar2 is FunReturns<FutureOr<int>>);
82 Expect.isTrue(bar2 is FunReturns<FutureOr<String>>);
83 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<Object>>>);
84 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<int>>>);
85 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<String>>>);
86
87
88 void foo3(String x) {}
89
90 Expect.isTrue(foo3 is FunTakes<dynamic>);
91 Expect.isTrue(foo3 is FunTakes<Object>);
92 Expect.isFalse(foo3 is FunTakes<int>);
93 Expect.isTrue(foo3 is FunTakes<String>);
94 Expect.isFalse(foo3 is FunTakes<Future<int>>);
95 Expect.isFalse(foo3 is FunTakes<Future<String>>);
96 Expect.isTrue(foo3 is FunTakes<FutureOr<Object>>);
97 Expect.isTrue(foo3 is FunTakes<FutureOr<int>>);
98 Expect.isTrue(foo3 is FunTakes<FutureOr<String>>);
99 Expect.isTrue(foo3 is FunTakes<FutureOr<FutureOr<Object>>>);
100 Expect.isTrue(foo3 is FunTakes<FutureOr<FutureOr<int>>>);
101 Expect.isTrue(foo3 is FunTakes<FutureOr<FutureOr<String>>>);
102
103
104 int bar3() => 499;
105
106 Expect.isTrue(bar3 is FunReturns<dynamic>);
107 Expect.isTrue(bar3 is FunReturns<Object>);
108 Expect.isTrue(bar3 is FunReturns<int>);
109 Expect.isFalse(bar3 is FunReturns<String>);
110 Expect.isFalse(bar3 is FunReturns<Future<int>>);
111 Expect.isFalse(bar3 is FunReturns<Future<String>>);
112 Expect.isTrue(bar3 is FunReturns<FutureOr<Object>>);
113 Expect.isTrue(bar3 is FunReturns<FutureOr<int>>);
114 Expect.isTrue(bar3 is FunReturns<FutureOr<String>>);
115 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<Object>>>);
116 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<int>>>);
117 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<String>>>);
118 }
OLDNEW
« no previous file with comments | « tests/lib_strong/async/future_or_bad_type_test.dart ('k') | tests/lib_strong/async/future_or_only_in_async_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698