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

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

Issue 2587343006: Runtime support for Null as any in dart2js (Closed)
Patch Set: Created 4 years 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 Null returnNullFunc() => null;
58 takeNullFunc(Null n) {}
59 A returnAFunc() => null;
60 takeAFunc(A a) {}
61
62 main() {
63 var n = null;
64 var listNull = new List<Null>();
65 var a = new A();
66 var listA = new List<A>();
67
68 testA(null); /// 01: ok
69 testA(a); /// 02: ok
70 testListA(listNull); /// 03: ok
71 testListA(listA); /// 04: ok
72 Expect.isTrue(testIsListA(listNull)); /// 05: ok
73 Expect.isTrue(testIsListA(listA)); /// 06: ok
74 testAsListA(listNull); /// 07: ok
75 testAsListA(listA); /// 08: ok
76
77 testNull(n); /// 09: ok
78 testNull(a); /// 10: dynamic type error
79 testListNull(listNull); /// 11: ok
80 testListNull(listA); /// 12: dynamic type error
81 Expect.isTrue(testIsListNull(listNull)); /// 13: ok
82 Expect.isFalse(testIsListNull(listA)); /// 14: ok
83 testAsListNull(listNull); /// 15: ok
84 Expect.throws(() => testAsListNull(listA), (e) => e is CastError); /// 16: ok
85
86 var returnNull = returnNullFunc;
87 var takeNull = takeNullFunc;
88 var returnA = returnAFunc;
89 var takeA = takeAFunc;
90
91 testReturnA(returnA); /// 17: ok
92 testReturnA(returnNull); /// 18: ok
93 testIsReturnA(returnA); /// 19: ok
floitsch 2016/12/21 12:45:05 Needs to be in Expect.isTrue/False. Same for the
Johnni Winther 2016/12/21 13:17:54 Done.
94 testIsReturnA(returnNull); /// 20: ok
95 testAsReturnA(returnA); /// 21: ok
96 testAsReturnA(returnNull); /// 22: ok
97
98 testReturnNull(returnA); /// 23: ok
99 testReturnNull(returnNull); /// 24: ok
100 testIsReturnNull(returnA); /// 25: ok
101 testIsReturnNull(returnNull); /// 26: ok
102 testAsReturnNull(returnA); /// 27: ok
103 testAsReturnNull(returnNull); /// 28: ok
104 }
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