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

Side by Side Diff: tests/lib_strong/async/future_or_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 strong mode, `FutureOr` should be equivalent to the union of `Future<T>`
6 // and `T`.
7
8 import 'dart:async';
9 import 'package:expect/expect.dart';
10
11
12 typedef void FunTakes<T>(T x);
13 typedef T FunReturns<T>();
14
15 main() {
16 Expect.isTrue(499 is FutureOr); // Same as `is Object`.
17 Expect.isTrue(499 is FutureOr<int>);
18 Expect.isFalse(499 is FutureOr<String>);
19
20 Expect.isTrue(new Future.value(499) is FutureOr); // Same as `is Object`.
21 Expect.isTrue(new Future.value(499) is FutureOr<int>);
22 Expect.isFalse(new Future.value(499) is FutureOr<String>);
23
24
25 void foo(FutureOr x) {} // Equivalent to `void bar(Object x) {}`.
26
27 // A function that takes Object takes everything.
28 Expect.isTrue(foo is FunTakes<dynamic>);
29 Expect.isTrue(foo is FunTakes<Object>);
30 Expect.isTrue(foo is FunTakes<int>);
31 Expect.isTrue(foo is FunTakes<String>);
32 Expect.isTrue(foo is FunTakes<Future<int>>);
33 Expect.isTrue(foo is FunTakes<Future<String>>);
34 Expect.isTrue(foo is FunTakes<FutureOr<Object>>);
35 Expect.isTrue(foo is FunTakes<FutureOr<int>>);
36 Expect.isTrue(foo is FunTakes<FutureOr<String>>);
37 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<Object>>>);
38 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<int>>>);
39 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<String>>>);
40
41
42 FutureOr bar() => 499; // Equivalent to `Object foo() => 499`.
43
44 Expect.isTrue(bar is FunReturns<dynamic>);
45 Expect.isTrue(bar is FunReturns<Object>);
46 Expect.isFalse(bar is FunReturns<int>);
47 Expect.isFalse(bar is FunReturns<String>);
48 Expect.isFalse(bar is FunReturns<Future<int>>);
49 Expect.isFalse(bar is FunReturns<Future<String>>);
50 Expect.isTrue(bar is FunReturns<FutureOr<Object>>);
51 Expect.isFalse(bar is FunReturns<FutureOr<int>>);
52 Expect.isFalse(bar is FunReturns<FutureOr<String>>);
53 Expect.isTrue(bar is FunReturns<FutureOr<FutureOr<Object>>>);
54 Expect.isFalse(bar is FunReturns<FutureOr<FutureOr<int>>>);
55 Expect.isFalse(bar is FunReturns<FutureOr<FutureOr<String>>>);
56
57
58 void foo2(FutureOr<String> x) {}
59
60 // In is-checks `dynamic` is treat specially (counting as bottom in parameter
61 // positions).
62 Expect.isTrue(foo2 is FunTakes<dynamic>);
63
64 Expect.isFalse(foo2 is FunTakes<Object>);
65 Expect.isFalse(foo2 is FunTakes<int>);
66 Expect.isTrue(foo2 is FunTakes<String>);
67 Expect.isFalse(foo2 is FunTakes<Future<int>>);
68 Expect.isTrue(foo2 is FunTakes<Future<String>>);
69 Expect.isFalse(foo2 is FunTakes<FutureOr<Object>>);
70 Expect.isFalse(foo2 is FunTakes<FutureOr<int>>);
71 Expect.isTrue(foo2 is FunTakes<FutureOr<String>>);
72 Expect.isFalse(foo2 is FunTakes<FutureOr<FutureOr<Object>>>);
73 Expect.isFalse(foo2 is FunTakes<FutureOr<FutureOr<int>>>);
74 Expect.isFalse(foo2 is FunTakes<FutureOr<FutureOr<String>>>);
75
76
77 FutureOr<int> bar2() => 499;
78
79 Expect.isTrue(bar2 is FunReturns<dynamic>);
80 Expect.isTrue(bar2 is FunReturns<Object>);
81 Expect.isFalse(bar2 is FunReturns<int>);
82 Expect.isFalse(bar2 is FunReturns<String>);
83 Expect.isFalse(bar2 is FunReturns<Future<int>>);
84 Expect.isFalse(bar2 is FunReturns<Future<String>>);
85 Expect.isTrue(bar2 is FunReturns<FutureOr<Object>>);
86 Expect.isTrue(bar2 is FunReturns<FutureOr<int>>);
87 Expect.isFalse(bar2 is FunReturns<FutureOr<String>>);
88 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<Object>>>);
89 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<int>>>);
90 Expect.isFalse(bar2 is FunReturns<FutureOr<FutureOr<String>>>);
91
92
93 void foo3(String x) {}
94
95 // In is-checks `dynamic` is treat specially (counting as bottom in parameter
96 // positions).
97 Expect.isTrue(foo3 is FunTakes<dynamic>);
98
99 Expect.isFalse(foo3 is FunTakes<Object>);
100 Expect.isFalse(foo3 is FunTakes<int>);
101 Expect.isTrue(foo3 is FunTakes<String>);
102 Expect.isFalse(foo3 is FunTakes<Future<int>>);
103 Expect.isFalse(foo3 is FunTakes<Future<String>>);
104 Expect.isFalse(foo3 is FunTakes<FutureOr<Object>>);
105 Expect.isFalse(foo3 is FunTakes<FutureOr<int>>);
106 Expect.isFalse(foo3 is FunTakes<FutureOr<String>>);
107 Expect.isFalse(foo3 is FunTakes<FutureOr<FutureOr<Object>>>);
108 Expect.isFalse(foo3 is FunTakes<FutureOr<FutureOr<int>>>);
109 Expect.isFalse(foo3 is FunTakes<FutureOr<FutureOr<String>>>);
110
111
112 int bar3() => 499;
113
114 Expect.isTrue(bar3 is FunReturns<dynamic>);
115 Expect.isTrue(bar3 is FunReturns<Object>);
116 Expect.isTrue(bar3 is FunReturns<int>);
117 Expect.isFalse(bar3 is FunReturns<String>);
118 Expect.isFalse(bar3 is FunReturns<Future<int>>);
119 Expect.isFalse(bar3 is FunReturns<Future<String>>);
120 Expect.isTrue(bar3 is FunReturns<FutureOr<Object>>);
121 Expect.isTrue(bar3 is FunReturns<FutureOr<int>>);
122 Expect.isFalse(bar3 is FunReturns<FutureOr<String>>);
123 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<Object>>>);
124 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<int>>>);
125 Expect.isFalse(bar3 is FunReturns<FutureOr<FutureOr<String>>>);
126 }
OLDNEW
« no previous file with comments | « tests/lib_strong/async/future_or_only_in_async_test.dart ('k') | tests/lib_strong/async/future_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698