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

Unified Diff: tests/language/null_is_bottom_type_test.dart

Issue 2595363002: Support for Null as bottom 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/language/null_is_bottom_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/null_is_bottom_type_test.dart
diff --git a/tests/language/null_is_bottom_type_test.dart b/tests/language/null_is_bottom_type_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b12137efebd70f9b90f16bafc3f7ddaae6853824
--- /dev/null
+++ b/tests/language/null_is_bottom_type_test.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that Null is a subtype of any other type.
+
+import 'package:expect/expect.dart';
+
+class A {}
+typedef A ReturnA();
+typedef TakeA(A a);
+typedef Null ReturnNull();
+typedef TakeNull(Null n);
+
+testA(A a) {}
+testListA(List<A> list) {}
+testNull(Null n) {}
+testListNull(List<Null> list) {}
+testReturnA(ReturnA f) {}
+testReturnNull(ReturnNull f) {}
+testTakeA(TakeA f) {}
+testTakeNull(TakeNull f) {}
+
+Null returnNull() => null;
+takeNull(Null n) {}
+A returnA() => null;
+takeA(A a) {}
+
+main() {
+ if (false) test(); // Perform static checks only.
+}
+
+test() {
+ Null n;
+ List<Null> listNull;
+ A a = new A();
+ List<A> listA;
+
+ testA(n); /// 01: ok
+ testA(a); /// 02: ok
+ testListA(listNull); /// 03: ok
+ testListA(listA); /// 04: ok
+
+ testNull(n); /// 05: ok
+ testNull(a); /// 06: ok
+ testListNull(listNull); /// 07: ok
+ testListNull(listA); /// 08: ok
+
+ testReturnA(returnA); /// 09: ok
+ testReturnA(returnNull); /// 10: ok
+
+ testReturnNull(returnA); /// 11: ok
+ testReturnNull(returnNull); /// 12: ok
+
+ testTakeA(takeA); /// 13: ok
+ testTakeA(takeNull); /// 14: ok
+
+ testTakeNull(takeA); /// 15: ok
+ testTakeNull(takeNull); /// 16: ok
+}
« no previous file with comments | « tests/language/null_is_bottom_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698