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

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

Issue 1137543005: Type check binary expressions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase and remove assert Created 5 years, 7 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
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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 testChecker({ 662 testChecker({
663 '/main.dart': ''' 663 '/main.dart': '''
664 class A { 664 class A {
665 int x = 2; 665 int x = 2;
666 } 666 }
667 667
668 test() { 668 test() {
669 dynamic a = new A(); 669 dynamic a = new A();
670 A b = /*info:DynamicCast*/a; 670 A b = /*info:DynamicCast*/a;
671 print(/*info:DynamicInvoke*/a.x); 671 print(/*info:DynamicInvoke*/a.x);
672 print((/*info:DynamicInvoke*/a.x) + 2); 672 print(/*info:DynamicInvoke*/(/*info:DynamicInvoke*/a.x) + 2);
673 } 673 }
674 ''' 674 '''
675 }); 675 });
676 }); 676 });
677 677
678 test('propagate inference transitively ', () { 678 test('propagate inference transitively ', () {
679 testChecker({ 679 testChecker({
680 '/main.dart': ''' 680 '/main.dart': '''
681 class A { 681 class A {
682 int x = 2; 682 int x = 2;
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 } 1225 }
1226 void main() { 1226 void main() {
1227 { // Variables, nested literals 1227 { // Variables, nested literals
1228 var x = "hello"; 1228 var x = "hello";
1229 var y = 3; 1229 var y = 3;
1230 void f(List<Map<int, String>> l) {}; 1230 void f(List<Map<int, String>> l) {};
1231 f(/*info:InferredTypeLiteral*/[{y: x}]); 1231 f(/*info:InferredTypeLiteral*/[{y: x}]);
1232 } 1232 }
1233 { 1233 {
1234 int f(int x) {}; 1234 int f(int x) {};
1235 A<int> = new A(f); 1235 A<int> a = /*info:InferredTypeAllocation*/new A(f);
1236 } 1236 }
1237 } 1237 }
1238 ''' 1238 '''
1239 }, inferDownwards: true); 1239 }, inferDownwards: true);
1240 }); 1240 });
1241 1241
1242 test('downwards inference on instance creations', () { 1242 test('downwards inference on instance creations', () {
1243 String mk(String info) => ''' 1243 String mk(String info) => '''
1244 class A<S, T> { 1244 class A<S, T> {
1245 S x; 1245 S x;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 } 1500 }
1501 { 1501 {
1502 Function2<int, List<String>> l0 = (int x) => null; 1502 Function2<int, List<String>> l0 = (int x) => null;
1503 Function2<int, List<String>> l1 = /*info:InferredTypeClosure*/(int x) => ["hello"]; 1503 Function2<int, List<String>> l1 = /*info:InferredTypeClosure*/(int x) => ["hello"];
1504 Function2<int, List<String>> l2 = /*severe:StaticTypeError*/(String x) => ["hello"]; 1504 Function2<int, List<String>> l2 = /*severe:StaticTypeError*/(String x) => ["hello"];
1505 Function2<int, List<String>> l3 = /*warning:UninferredClosure should b e severe:StaticTypeError*/(int x) => [3]; 1505 Function2<int, List<String>> l3 = /*warning:UninferredClosure should b e severe:StaticTypeError*/(int x) => [3];
1506 Function2<int, List<String>> l4 = /*warning:UninferredClosure should b e severe:StaticTypeError*/(int x) {return [3]}; 1506 Function2<int, List<String>> l4 = /*warning:UninferredClosure should b e severe:StaticTypeError*/(int x) {return [3]};
1507 } 1507 }
1508 { 1508 {
1509 Function2<int, int> l0 = /*info:InferredTypeClosure*/(x) => x; 1509 Function2<int, int> l0 = /*info:InferredTypeClosure*/(x) => x;
1510 Function2<int, int> l1 = /*info:InferredTypeClosure*/(x) => x+1; 1510 Function2<int, int> l1 = /*info:InferredTypeClosure*/(x) => /*info:Dyn amicInvoke should be pass*/x+1;
1511 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;
1512 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);
1513 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);
1514 } 1514 }
1515 } 1515 }
1516 ''' 1516 '''
1517 }, inferDownwards: true, wrapClosures: false); 1517 }, inferDownwards: true, wrapClosures: false);
1518 }); 1518 });
1519 } 1519 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698