OLD | NEW |
| (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 typedef void FunTakes<T>(T x); | |
11 typedef T FunReturns<T>(); | |
12 | |
13 main() { | |
14 Expect.isTrue(499 is FutureOr); | |
15 Expect.isTrue(499 is FutureOr<String>); | |
16 Expect.isTrue(499 is FutureOr<int>); | |
17 | |
18 Expect.isTrue(new Future.value(499) is FutureOr); | |
19 Expect.isTrue(new Future.value(499) is FutureOr<int>); | |
20 Expect.isTrue(new Future.value(499) is FutureOr<String>); | |
21 | |
22 void foo(FutureOr x) {} | |
23 | |
24 Expect.isTrue(foo is FunTakes<dynamic>); | |
25 Expect.isTrue(foo is FunTakes<Object>); | |
26 Expect.isTrue(foo is FunTakes<int>); | |
27 Expect.isTrue(foo is FunTakes<String>); | |
28 Expect.isTrue(foo is FunTakes<Future<int>>); | |
29 Expect.isTrue(foo is FunTakes<Future<String>>); | |
30 Expect.isTrue(foo is FunTakes<FutureOr<Object>>); | |
31 Expect.isTrue(foo is FunTakes<FutureOr<int>>); | |
32 Expect.isTrue(foo is FunTakes<FutureOr<String>>); | |
33 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<Object>>>); | |
34 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<int>>>); | |
35 Expect.isTrue(foo is FunTakes<FutureOr<FutureOr<String>>>); | |
36 | |
37 FutureOr bar() => 499; | |
38 | |
39 Expect.isTrue(bar is FunReturns<dynamic>); | |
40 Expect.isTrue(bar is FunReturns<Object>); | |
41 Expect.isTrue(bar is FunReturns<int>); | |
42 Expect.isTrue(bar is FunReturns<String>); | |
43 Expect.isTrue(bar is FunReturns<Future<int>>); | |
44 Expect.isTrue(bar is FunReturns<Future<String>>); | |
45 Expect.isTrue(bar is FunReturns<FutureOr<Object>>); | |
46 Expect.isTrue(bar is FunReturns<FutureOr<int>>); | |
47 Expect.isTrue(bar is FunReturns<FutureOr<String>>); | |
48 Expect.isTrue(bar is FunReturns<FutureOr<FutureOr<Object>>>); | |
49 Expect.isTrue(bar is FunReturns<FutureOr<FutureOr<int>>>); | |
50 Expect.isTrue(bar is FunReturns<FutureOr<FutureOr<String>>>); | |
51 | |
52 void foo2(FutureOr<String> x) {} | |
53 | |
54 Expect.isTrue(foo2 is FunTakes<dynamic>); | |
55 Expect.isTrue(foo2 is FunTakes<Object>); | |
56 Expect.isTrue(foo2 is FunTakes<int>); | |
57 Expect.isTrue(foo2 is FunTakes<String>); | |
58 Expect.isTrue(foo2 is FunTakes<Future<int>>); | |
59 Expect.isTrue(foo2 is FunTakes<Future<String>>); | |
60 Expect.isTrue(foo2 is FunTakes<FutureOr<Object>>); | |
61 Expect.isTrue(foo2 is FunTakes<FutureOr<int>>); | |
62 Expect.isTrue(foo2 is FunTakes<FutureOr<String>>); | |
63 Expect.isTrue(foo2 is FunTakes<FutureOr<FutureOr<Object>>>); | |
64 Expect.isTrue(foo2 is FunTakes<FutureOr<FutureOr<int>>>); | |
65 Expect.isTrue(foo2 is FunTakes<FutureOr<FutureOr<String>>>); | |
66 | |
67 FutureOr<int> bar2() => 499; | |
68 | |
69 Expect.isTrue(bar2 is FunReturns<dynamic>); | |
70 Expect.isTrue(bar2 is FunReturns<Object>); | |
71 Expect.isTrue(bar2 is FunReturns<int>); | |
72 Expect.isTrue(bar2 is FunReturns<String>); | |
73 Expect.isTrue(bar2 is FunReturns<Future<int>>); | |
74 Expect.isTrue(bar2 is FunReturns<Future<String>>); | |
75 Expect.isTrue(bar2 is FunReturns<FutureOr<Object>>); | |
76 Expect.isTrue(bar2 is FunReturns<FutureOr<int>>); | |
77 Expect.isTrue(bar2 is FunReturns<FutureOr<String>>); | |
78 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<Object>>>); | |
79 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<int>>>); | |
80 Expect.isTrue(bar2 is FunReturns<FutureOr<FutureOr<String>>>); | |
81 | |
82 void foo3(String x) {} | |
83 | |
84 Expect.isTrue(foo3 is FunTakes<dynamic>); | |
85 Expect.isTrue(foo3 is FunTakes<Object>); | |
86 Expect.isFalse(foo3 is FunTakes<int>); | |
87 Expect.isTrue(foo3 is FunTakes<String>); | |
88 Expect.isFalse(foo3 is FunTakes<Future<int>>); | |
89 Expect.isFalse(foo3 is FunTakes<Future<String>>); | |
90 Expect.isTrue(foo3 is FunTakes<FutureOr<Object>>); | |
91 Expect.isTrue(foo3 is FunTakes<FutureOr<int>>); | |
92 Expect.isTrue(foo3 is FunTakes<FutureOr<String>>); | |
93 Expect.isTrue(foo3 is FunTakes<FutureOr<FutureOr<Object>>>); | |
94 Expect.isTrue(foo3 is FunTakes<FutureOr<FutureOr<int>>>); | |
95 Expect.isTrue(foo3 is FunTakes<FutureOr<FutureOr<String>>>); | |
96 | |
97 int bar3() => 499; | |
98 | |
99 Expect.isTrue(bar3 is FunReturns<dynamic>); | |
100 Expect.isTrue(bar3 is FunReturns<Object>); | |
101 Expect.isTrue(bar3 is FunReturns<int>); | |
102 Expect.isFalse(bar3 is FunReturns<String>); | |
103 Expect.isFalse(bar3 is FunReturns<Future<int>>); | |
104 Expect.isFalse(bar3 is FunReturns<Future<String>>); | |
105 Expect.isTrue(bar3 is FunReturns<FutureOr<Object>>); | |
106 Expect.isTrue(bar3 is FunReturns<FutureOr<int>>); | |
107 Expect.isTrue(bar3 is FunReturns<FutureOr<String>>); | |
108 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<Object>>>); | |
109 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<int>>>); | |
110 Expect.isTrue(bar3 is FunReturns<FutureOr<FutureOr<String>>>); | |
111 } | |
OLD | NEW |