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

Unified Diff: test/checker/checker_test.dart

Issue 957013002: Typecheck map and list literals (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Handle partial type instantiations Created 5 years, 10 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
« lib/src/checker/checker.dart ('K') | « lib/src/checker/checker.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 abf647235613336ee6b2c718119726dcec8810bf..f8cb77a67bc3e2b69042130da1e7846f28b0b411 100644
--- a/test/checker/checker_test.dart
+++ b/test/checker/checker_test.dart
@@ -1447,6 +1447,51 @@ main() {
});
});
+ test('Type checking literals', () {
+ testChecker({
+ '/main.dart': '''
+ test() {
+ num n = 3;
+ int i = 3;
+ String s = "hello";
+ {
+ List<int> l = <int>[i];
+ l = <int>[/*severe:StaticTypeError*/s];
+ l = <int>[/*info:DownCast*/n];
+ l = <int>[i, /*info:DownCast*/n, /*severe:StaticTypeError*/s];
+ }
+ {
+ List l = [i];
+ l = [s];
+ l = [n];
+ l = [i, n, s];
+ }
+ {
+ Map<String, int> m = <String, int>{s: i};
+ m = <String, int>{s: /*severe:StaticTypeError*/s};
+ m = <String, int>{s: /*info:DownCast*/n};
+ m = <String, int>{s: i,
+ s: /*info:DownCast*/n,
+ s: /*severe:StaticTypeError*/s};
+ }
+ // TODO(leafp): We can't currently test for key errors since the
+ // error marker binds to the entire entry.
+ {
+ Map m = {s: i};
+ m = {s: s};
+ m = {s: n};
+ m = {s: i,
+ s: n,
+ s: s};
+ m = {i: s,
+ n: s,
+ s: s};
+ }
+ }
+ '''
+ });
+ });
+
test('redirecting constructor', () {
testChecker({
'/main.dart': '''
« lib/src/checker/checker.dart ('K') | « lib/src/checker/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698