Chromium Code Reviews

Unified Diff: test/checker/checker_test.dart

Issue 1190413005: Fixes #151 (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« lib/src/checker/checker.dart ('K') | « lib/src/checker/rules.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/checker/checker_test.dart
diff --git a/test/checker/checker_test.dart b/test/checker/checker_test.dart
index 182e682cc03431e74821bfdcdd384b7405a1b680..619b3fe4be126b2e0d43e4415d67a1404e84226d 100644
--- a/test/checker/checker_test.dart
+++ b/test/checker/checker_test.dart
@@ -2669,4 +2669,50 @@ void main() {
customUrlMappings: {
'dart:foobar': '$testDirectory/checker/dart_foobar.dart'
}));
+
+ group('function modifiers', () {
+ test('async', () => testChecker({
+ '/main.dart': '''
+ import 'dart:async';
+
+ dynamic x;
+
+ foo1() async => x;
+ Future foo2() async => x;
+ Future<int> foo3() async => (/*info:DynamicCast*/x);
+ Future<int> foo4() async => (/*severe:StaticTypeError*/new Future<int>(x));
+
+ bar1() async { return x; }
+ Future bar2() async { return x; }
+ Future<int> bar3() async { return (/*info:DynamicCast*/x); }
+ Future<int> bar4() async { return (/*severe:StaticTypeError*/new Future<int>(x)); }
+ '''
+ }));
+
+ test('async*', () => testChecker({
+ '/main.dart': '''
+ import 'dart:async';
+
+ dynamic x;
+
+ bar1() async* { yield x; }
+ Stream bar2() async* { yield x; }
+ Stream<int> bar3() async* { yield (/*info:DynamicCast*/x); }
+ Stream<int> bar4() async* { yield (/*severe:StaticTypeError*/new Stream<int>()); }
Leaf 2015/06/19 22:15:27 Maybe test yield* as well?
+ '''
+ }));
+
+ test('sync*', () => testChecker({
+ '/main.dart': '''
+ import 'dart:async';
+
+ dynamic x;
+
+ bar1() sync* { yield x; }
+ Iterable bar2() sync* { yield x; }
+ Iterable<int> bar3() sync* { yield (/*info:DynamicCast*/x); }
+ Iterable<int> bar4() sync* { yield (/*severe:StaticTypeError*/new Iterable<int>()); }
+ '''
+ }));
+ });
}
« lib/src/checker/checker.dart ('K') | « lib/src/checker/rules.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine