Index: tests/lib/async/stream_typecheck_test.dart |
diff --git a/tests/lib/async/stream_typecheck_test.dart b/tests/lib/async/stream_typecheck_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1a7da091c2edc6dceff0ff272361d4c3d902919d |
--- /dev/null |
+++ b/tests/lib/async/stream_typecheck_test.dart |
@@ -0,0 +1,30 @@ |
+import "package:expect/expect.dart"; |
+import 'dart:async'; |
+ |
+ |
+test_stream() { |
+ Stream<int> numbers = new Stream<int>.fromIterable([1,2,3,4,5]); |
+ |
+ Expect.equals(numbers is Stream<int>, true, "Stream should be Stream<int>"); |
+ Expect.equals(numbers is Stream<String>, false, "Stream<int> should not be Stream<String>"); |
+ |
+ Expect.equals(numbers is Stream<int>, true, "Stream<int> should be Stream<int>"); |
+ Expect.equals(numbers is Stream<String>, false, "Stream<int> should not be Stream<String>"); |
+} |
+ |
+test_stream_from_controller() { |
+ StreamController<int> sc = new StreamController<int>(); |
+ Stream numbers = new Stream.fromIterable([1,2,3,4,5]); |
+ sc.addStream(numbers).then((_) => sc.close()); |
+ |
+ Expect.equals(sc.stream is Stream<int>, true, "Stream should not be Stream<String>"); |
+ Expect.equals(sc.stream is Stream<String>, false, "Stream<int> should not be Stream<String>"); |
+ |
+ Expect.equals(sc.stream.take(1) is Stream<int>, true, "Stream should not be Stream<String>"); |
+ Expect.equals(sc.stream.take(1) is Stream<String>, false, "Stream<int> should not be Stream<String>"); |
+} |
+ |
+main() { |
+ test_stream(); |
+ test_stream_from_controller(); |
+} |