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

Side by Side Diff: test/checker/inferred_type_test.dart

Issue 1064933006: Enable downward inference on default params (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « test/checker/checker_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Tests for type inference. 5 /// Tests for type inference.
6 library dev_compiler.test.inferred_type_test; 6 library dev_compiler.test.inferred_type_test;
7 7
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'package:dev_compiler/src/testing.dart'; 10 import 'package:dev_compiler/src/testing.dart';
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 } 1335 }
1336 '''; 1336 ''';
1337 testChecker({'/main.dart': mk("info:InferredTypeAllocation")}, 1337 testChecker({'/main.dart': mk("info:InferredTypeAllocation")},
1338 inferDownwards: true); 1338 inferDownwards: true);
1339 testChecker({'/main.dart': mk("severe:StaticTypeError")}, 1339 testChecker({'/main.dart': mk("severe:StaticTypeError")},
1340 inferDownwards: false); 1340 inferDownwards: false);
1341 }); 1341 });
1342 1342
1343 test('downwards inference on list literals', () { 1343 test('downwards inference on list literals', () {
1344 String mk(String info) => ''' 1344 String mk(String info) => '''
1345 void foo([List<String> list1 = /*$info*/const [],
1346 List<String> list2 = /*severe:StaticTypeError*/const [42]]) {
1347 }
1348
1345 void main() { 1349 void main() {
1346 { 1350 {
1347 List<int> l0 = /*$info*/[]; 1351 List<int> l0 = /*$info*/[];
1348 List<int> l1 = /*$info*/[3]; 1352 List<int> l1 = /*$info*/[3];
1349 List<int> l2 = /*severe:StaticTypeError*/["hello"]; 1353 List<int> l2 = /*severe:StaticTypeError*/["hello"];
1350 List<int> l3 = /*severe:StaticTypeError*/["hello", 3]; 1354 List<int> l3 = /*severe:StaticTypeError*/["hello", 3];
1351 } 1355 }
1352 { 1356 {
1353 List<dynamic> l0 = []; 1357 List<dynamic> l0 = [];
1354 List<dynamic> l1 = [3]; 1358 List<dynamic> l1 = [3];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 } 1420 }
1417 '''; 1421 ''';
1418 testChecker({'/main.dart': mk("info:InferredTypeLiteral")}, 1422 testChecker({'/main.dart': mk("info:InferredTypeLiteral")},
1419 inferDownwards: true); 1423 inferDownwards: true);
1420 testChecker({'/main.dart': mk("severe:StaticTypeError")}, 1424 testChecker({'/main.dart': mk("severe:StaticTypeError")},
1421 inferDownwards: false); 1425 inferDownwards: false);
1422 }); 1426 });
1423 1427
1424 test('downwards inference on map literals', () { 1428 test('downwards inference on map literals', () {
1425 String mk(String info) => ''' 1429 String mk(String info) => '''
1430 void foo([Map<int, String> m1 = /*$info*/const {1: "hello"},
1431 Map<int, String> m1 = /*severe:StaticTypeError*/const {"hello": "world"}]) {
1432 }
1426 void main() { 1433 void main() {
1427 { 1434 {
1428 Map<int, String> l0 = /*$info*/{}; 1435 Map<int, String> l0 = /*$info*/{};
1429 Map<int, String> l1 = /*$info*/{3: "hello"}; 1436 Map<int, String> l1 = /*$info*/{3: "hello"};
1430 Map<int, String> l2 = /*severe:StaticTypeError*/{"hello": "hello"}; 1437 Map<int, String> l2 = /*severe:StaticTypeError*/{"hello": "hello"};
1431 Map<int, String> l3 = /*severe:StaticTypeError*/{3: 3}; 1438 Map<int, String> l3 = /*severe:StaticTypeError*/{3: 3};
1432 Map<int, String> l4 = /*severe:StaticTypeError*/{3:"hello", "hello": 3 }; 1439 Map<int, String> l4 = /*severe:StaticTypeError*/{3:"hello", "hello": 3 };
1433 } 1440 }
1434 { 1441 {
1435 Map<dynamic, dynamic> l0 = {}; 1442 Map<dynamic, dynamic> l0 = {};
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 Function2<int, int> l1 = /*info:InferredTypeClosure*/(x) => x+1; 1510 Function2<int, int> l1 = /*info:InferredTypeClosure*/(x) => x+1;
1504 Function2<int, String> l2 = /*info:InferredTypeClosure should be sever e:StaticTypeError*/(x) => x; 1511 Function2<int, String> l2 = /*info:InferredTypeClosure should be sever e:StaticTypeError*/(x) => x;
1505 Function2<int, String> l3 = /*info:InferredTypeClosure should be sever e:StaticTypeError*/(x) => /*info:DynamicInvoke should be pass*/x.substring(3); 1512 Function2<int, String> l3 = /*info:InferredTypeClosure should be sever e:StaticTypeError*/(x) => /*info:DynamicInvoke should be pass*/x.substring(3);
1506 Function2<String, String> l4 = /*info:InferredTypeClosure*/(x) => /*in fo:DynamicInvoke should be pass*/x.substring(3); 1513 Function2<String, String> l4 = /*info:InferredTypeClosure*/(x) => /*in fo:DynamicInvoke should be pass*/x.substring(3);
1507 } 1514 }
1508 } 1515 }
1509 ''' 1516 '''
1510 }, inferDownwards: true, wrapClosures: false); 1517 }, inferDownwards: true, wrapClosures: false);
1511 }); 1518 });
1512 } 1519 }
OLDNEW
« no previous file with comments | « test/checker/checker_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698