Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // These tests are for an experimental feature that treats Dart primitive types | 5 // These tests are for an experimental feature that treats Dart primitive types |
| 6 // (int, bool, double, etc.) as non-nullable. This file is not evidence for an | 6 // (int, bool, double, etc.) as non-nullable. This file is not evidence for an |
| 7 // intention to officially support non-nullable primitives in Dart (or general | 7 // intention to officially support non-nullable primitives in Dart (or general |
| 8 // NNBD, for that matter) so don't get too crazy about it. | 8 // NNBD, for that matter) so don't get too crazy about it. |
| 9 | 9 |
| 10 library analyzer.test.src.task.non_null_primitives.checker_test; | 10 library analyzer.test.src.task.non_null_primitives.checker_test; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 } | 35 } |
| 36 | 36 |
| 37 main() { | 37 main() { |
| 38 var languages = new MyList(); | 38 var languages = new MyList(); |
| 39 for (int i = 0; i < languages.length; ++i) { | 39 for (int i = 0; i < languages.length; ++i) { |
| 40 print(languages[i]); | 40 print(languages[i]); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 '''); | 43 '''); |
| 44 } | 44 } |
| 45 | |
| 46 void test_nullableTypes() { | |
| 47 // By default x can be set to null. | |
| 48 addFile('''int x = null;'''); | |
| 49 check(); | |
| 50 } | |
| 51 | |
| 52 @failingTest | |
| 53 void test_nonnullableTypes() { | |
| 54 // If `int`s are non-nullable, then this code should throw an error. | |
| 55 addFile('''int x = /*error:INVALID_ASSIGNMENT*/null;'''); | |
| 56 check(nonnullableTypes: <String>['int']); | |
|
Jennifer Messerly
2016/08/02 16:18:51
to build on Brian's comment, consider qualifying i
Brian Wilkerson
2016/08/02 16:25:18
Unless this is intended to be a general purpose me
stanm
2016/08/02 16:56:05
I agree it's a bit of an overkill, but it actually
| |
| 57 } | |
| 45 } | 58 } |
| OLD | NEW |