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

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

Issue 1396993002: housecleaning: remove nonnullableTypes (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 2 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:test/test.dart'; 8 import 'package:test/test.dart';
9 9
10 import '../testing.dart'; 10 import '../testing.dart';
(...skipping 12 matching lines...) Expand all
23 // If inferred type is `int`, error is also reported 23 // If inferred type is `int`, error is also reported
24 testChecker('infer type on var 2', { 24 testChecker('infer type on var 2', {
25 '/main.dart': ''' 25 '/main.dart': '''
26 test2() { 26 test2() {
27 var x = 3; 27 var x = 3;
28 x = /*severe:StaticTypeError*/"hi"; 28 x = /*severe:StaticTypeError*/"hi";
29 } 29 }
30 ''' 30 '''
31 }); 31 });
32 32
33 testChecker('Error when declared type is `int` and assigned null.', {
34 '/main.dart': '''
35 test1() {
36 int x = 3;
37 x = /*severe:StaticTypeError*/null;
38 }
39 '''
40 }, nonnullableTypes: <String>[
41 'int',
42 'double'
43 ]);
44
45 testChecker('Error when inferred type is `int` and assigned null.', {
46 '/main.dart': '''
47 test1() {
48 var x = 3;
49 x = /*severe:StaticTypeError*/null;
50 }
51 '''
52 }, nonnullableTypes: <String>[
53 'int',
54 'double'
55 ]);
56
57 testChecker('No error when declared type is `num` and assigned null.', { 33 testChecker('No error when declared type is `num` and assigned null.', {
58 '/main.dart': ''' 34 '/main.dart': '''
59 test1() { 35 test1() {
60 num x = 3; 36 num x = 3;
61 x = null; 37 x = null;
62 } 38 }
63 ''' 39 '''
64 }); 40 });
65 41
66 testChecker('do not infer type on dynamic', { 42 testChecker('do not infer type on dynamic', {
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 main() { 1340 main() {
1365 Iterable<Future<int>> list = <int>[1, 2, 3].map(make); 1341 Iterable<Future<int>> list = <int>[1, 2, 3].map(make);
1366 Future<List<int>> results = Future.wait(list); 1342 Future<List<int>> results = Future.wait(list);
1367 Future<String> results2 = results.then((List<int> list) 1343 Future<String> results2 = results.then((List<int> list)
1368 => list.fold('', (String x, int y) => x + y.toString())); 1344 => list.fold('', (String x, int y) => x + y.toString()));
1369 } 1345 }
1370 ''' 1346 '''
1371 }); 1347 });
1372 }); 1348 });
1373 } 1349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698