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

Unified Diff: tests/lib/async/stream_typecheck_test.dart

Issue 1238143003: Added type variable to generic in Stream#take() so that subsequent type checks will work correctly. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+}
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698