Skip to content

Commit

Permalink
add test related to #264 and #228
Browse files Browse the repository at this point in the history
R=vsm@google.com

Review URL: https://codereview.chromium.org/1252773002 .
  • Loading branch information
John Messerly committed Jul 23, 2015
1 parent 3996aaf commit 8f6761d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pkg/dev_compiler/lib/src/dart_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ final Map<String, String> mockSdkSources = {
''',
'dart:async': '''
class Future<T> {
Future(computation()) {}
Future.value(T t) {}
Future then(callback) {}
}
class Stream<T> {}
Expand All @@ -164,4 +166,10 @@ final Map<String, String> mockSdkSources = {
library dart.html;
class HtmlElement {}
''',
'dart:math': '''
library dart.math;
class Random {
bool nextBool() {}
}
''',
};
11 changes: 8 additions & 3 deletions pkg/dev_compiler/test/checker/checker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2675,18 +2675,19 @@ void main() {
test('async', () => testChecker({
'/main.dart': '''
import 'dart:async';
import 'dart:math' show Random;
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));
Future<int> foo4() async => (/*severe:StaticTypeError*/new Future<int>.value(/*info:DynamicCast*/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)); }
Future<int> bar4() async { return (/*severe:StaticTypeError*/new Future<int>.value(/*info:DynamicCast*/x)); }
int y;
Future<int> z;
Expand All @@ -2700,7 +2701,11 @@ void main() {
Future<bool> get issue_264 async {
await 42;
return false;
if (new Random().nextBool()) {
return true;
} else {
return /*severe:StaticTypeError*/new Future<bool>.value(false);
}
}
'''
}));
Expand Down

0 comments on commit 8f6761d

Please sign in to comment.