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

Side by Side Diff: tests/language/null_is_bottom_test.dart

Issue 2587343006: Runtime support for Null as any in dart2js (Closed)
Patch Set: Update tests. Created 3 years, 12 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 | « tests/language/language.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Test that Null is a subtype of any other type.
6
7 import 'package:expect/expect.dart';
8
9 class A {}
10 typedef A ReturnA();
11 typedef TakeA(A a);
12 typedef Null ReturnNull();
13 typedef TakeNull(Null n);
14
15 @NoInline()
16 testA(A testAsListA) {}
17
18 @NoInline()
19 testListA(List<A> list) {}
20
21 @NoInline()
22 testIsListA(var a) => a is List<A>;
23
24 @NoInline()
25 testAsListA(var a) => a as List<A>;
26
27 @NoInline()
28 testNull(Null n) {}
29
30 @NoInline()
31 testListNull(List<Null> list) {}
32
33 @NoInline()
34 testIsListNull(var a) => a is List<Null>;
35
36 @NoInline()
37 testAsListNull(var a) => a as List<Null>;
38
39 @NoInline()
40 testReturnA(ReturnA f) {}
41
42 @NoInline()
43 testIsReturnA(var f) => f is ReturnA;
44
45 @NoInline()
46 testAsReturnA(var f) => f as ReturnA;
47
48 @NoInline()
49 testReturnNull(ReturnNull f) {}
50
51 @NoInline()
52 testIsReturnNull(var f) => f is ReturnNull;
53
54 @NoInline()
55 testAsReturnNull(var f) => f as ReturnNull;
56
57 @NoInline()
58 testTakeA(TakeA f) {}
59
60 @NoInline()
61 testIsTakeA(var f) => f is TakeA;
62
63 @NoInline()
64 testAsTakeA(var f) => f as TakeA;
65
66 @NoInline()
67 testTakeNull(TakeNull f) {}
68
69 @NoInline()
70 testIsTakeNull(var f) => f is TakeNull;
71
72 @NoInline()
73 testAsTakeNull(var f) => f as TakeNull;
74
75 Null returnNullFunc() => null;
76 takeNullFunc(Null n) {}
77 A returnAFunc() => null;
78 takeAFunc(A a) {}
79
80 main() {
81 var n = null;
82 var listNull = new List<Null>();
83 var a = new A();
84 var listA = new List<A>();
85
86 testA(null); /// 01: ok
87 testA(a); /// 02: ok
88 testListA(listNull); /// 03: ok
89 testListA(listA); /// 04: ok
90 Expect.isTrue(testIsListA(listNull)); /// 05: ok
91 Expect.isTrue(testIsListA(listA)); /// 06: ok
92 testAsListA(listNull); /// 07: ok
93 testAsListA(listA); /// 08: ok
94
95 testNull(n); /// 09: ok
96 testNull(a); /// 10: dynamic type error
97 testListNull(listNull); /// 11: ok
98 testListNull(listA); /// 12: dynamic type error
99 Expect.isTrue(testIsListNull(listNull)); /// 13: ok
100 Expect.isFalse(testIsListNull(listA)); /// 14: ok
101 testAsListNull(listNull); /// 15: ok
102 Expect.throws(() => testAsListNull(listA), (e) => e is CastError); /// 16: ok
103
104 var returnNull = returnNullFunc;
105 var takeNull = takeNullFunc;
106 var returnA = returnAFunc;
107 var takeA = takeAFunc;
108
109 testReturnA(returnA); /// 17: ok
110 testReturnA(returnNull); /// 18: ok
111 Expect.isTrue(testIsReturnA(returnA)); /// 19: ok
112 Expect.isTrue(testIsReturnA(returnNull)); /// 20: ok
113 testAsReturnA(returnA); /// 21: ok
114 testAsReturnA(returnNull); /// 22: ok
115
116 // This is not valid in strong-mode: ()->A <: ()->Null
117 testReturnNull(returnA); /// 23: ok
118 testReturnNull(returnNull); /// 24: ok
119 // This is not valid in strong-mode: ()->A <: ()->Null
120 Expect.isTrue(testIsReturnNull(returnA)); /// 25: ok
121 Expect.isTrue(testIsReturnNull(returnNull)); /// 26: ok
122 // This is not valid in strong-mode: ()->A <: ()->Null
123 testAsReturnNull(returnA); /// 27: ok
124 testAsReturnNull(returnNull); /// 28: ok
125
126 testTakeA(takeA); /// 29: ok
127 // This is not valid in strong-mode: (Null)-> <: (A)->
128 testTakeA(takeNull); /// 30: ok
129 Expect.isTrue(testIsTakeA(takeA)); /// 31: ok
130 // This is not valid in strong-mode: (Null)-> <: (A)->
131 Expect.isTrue(testIsTakeA(takeNull)); /// 32: ok
132 testAsTakeA(takeA); /// 33: ok
133 // This is not valid in strong-mode: (Null)-> <: (A)->
134 testAsTakeA(takeNull); /// 34: ok
135
136 testTakeNull(takeA); /// 35: ok
137 testTakeNull(takeNull); /// 36: ok
138 Expect.isTrue(testIsTakeNull(takeA)); /// 37: ok
139 Expect.isTrue(testIsTakeNull(takeNull)); /// 38: ok
140 testAsTakeNull(takeA); /// 39: ok
141 testAsTakeNull(takeNull); /// 40: ok
142 }
OLDNEW
« no previous file with comments | « tests/language/language.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698