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

Unified Diff: pkg/analyzer/test/src/task/strong/non_null_checker_test.dart

Issue 2705323005: Make src/task/strong tests into classes and asynchronous. (Closed)
Patch Set: Created 3 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
Index: pkg/analyzer/test/src/task/strong/non_null_checker_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart b/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart
index 82aef1954eb9775a10f6a52304f722ab2595658b..bce92c3cf22eec369f1989932fcab63a5f6b7955 100644
--- a/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/non_null_checker_test.dart
@@ -24,7 +24,7 @@ String _withError(String file, String error) {
}
@reflectiveTest
-class NonNullCheckerTest {
+class NonNullCheckerTest extends AbstractStrongTest {
// Tests simple usage of ints as iterators for a loop. Not directly related to
// non-nullability, but if it is implemented this should be more efficient,
// since languages.length will not be null-checked on every iteration.
@@ -74,15 +74,7 @@ void main() {
}
''';
- void setUp() {
- doSetUp();
- }
-
- void tearDown() {
- doTearDown();
- }
-
- void test_assign_null_to_nonnullable() {
+ test_assign_null_to_nonnullable() async {
addFile('''
int x = 0;
@@ -91,10 +83,10 @@ main() {
x = /*error:INVALID_ASSIGNMENT*/null;
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_compoundAssignment() {
+ test_compoundAssignment() async {
addFile('''
void main() {
int i = 1;
@@ -103,10 +95,10 @@ void main() {
print(i);
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_forEach() {
+ test_forEach() async {
addFile('''
void main() {
var ints = <num>[1, 2, 3, null];
@@ -115,11 +107,11 @@ void main() {
}
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_forLoop() {
- checkFile('''
+ test_forLoop() async {
+ await checkFile('''
class MyList {
int length;
MyList() {
@@ -139,7 +131,7 @@ main() {
''');
}
- void test_generics() {
+ test_generics() async {
addFile('''
class Foo<T> {
T x;
@@ -171,20 +163,20 @@ void main() {
var g = new Foo<int>(); // Should fail at runtime.
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_initialize_nonnullable_with_null() {
+ test_initialize_nonnullable_with_null() async {
addFile('int x = /*error:INVALID_ASSIGNMENT*/null;');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_initialize_nonnullable_with_valid_value() {
+ test_initialize_nonnullable_with_valid_value() async {
addFile('int x = 0;');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_map() {
+ test_map() async {
addFile('''
class Pair<K, V> {
K first;
@@ -235,11 +227,11 @@ void main() {
int y = legs.get("sheep"); // TODO(stanm): Runtime error here.
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
// Default example from NNBD document.
- void test_method_call() {
+ test_method_call() async {
addFile('''
int s(int x) {
return x + 1;
@@ -250,35 +242,35 @@ void main() {
s(/*error:INVALID_ASSIGNMENT*/null);
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_nonnullable_fields() {
+ test_nonnullable_fields() async {
addFile(defaultNnbdExample);
// `null` can be passed as an argument to `Point` in default mode.
addFile(_withError(defaultNnbdExampleMod1, "error:INVALID_ASSIGNMENT"));
// A nullable expression can be passed as an argument to `Point` in default
// mode.
addFile(_withError(defaultNnbdExampleMod2, "error:INVALID_ASSIGNMENT"));
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_nullable_fields() {
+ test_nullable_fields() async {
addFile(defaultNnbdExample);
// `null` can be passed as an argument to `Point` in default mode.
addFile(defaultNnbdExampleMod1);
// A nullable expression can be passed as an argument to `Point` in default
// mode.
addFile(defaultNnbdExampleMod2);
- check();
+ await check();
}
- void test_nullableTypes() {
+ test_nullableTypes() async {
// By default x can be set to null.
- checkFile('int x = null;');
+ await checkFile('int x = null;');
}
- void test_prefer_final_to_non_nullable_error() {
+ test_prefer_final_to_non_nullable_error() async {
addFile('main() { final int /*error:FINAL_NOT_INITIALIZED*/x; }');
addFile('final int /*error:FINAL_NOT_INITIALIZED*/x;');
addFile('''
@@ -290,10 +282,10 @@ class A {
/*warning:FINAL_NOT_INITIALIZED_CONSTRUCTOR_1*/A();
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_uninitialized_nonnullable_field_declaration() {
+ test_uninitialized_nonnullable_field_declaration() async {
addFile('''
void foo() {}
@@ -306,19 +298,19 @@ class A {
A();
}
''');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_uninitialized_nonnullable_local_variable() {
+ test_uninitialized_nonnullable_local_variable() async {
// Ideally, we will do flow analysis and throw an error only if a variable
// is used before it has been initialized.
addFile('main() { int /*error:NON_NULLABLE_FIELD_NOT_INITIALIZED*/x; }');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
- void test_uninitialized_nonnullable_top_level_variable_declaration() {
+ test_uninitialized_nonnullable_top_level_variable_declaration() async {
// If `int`s are non-nullable, then this code should throw an error.
addFile('int /*error:NON_NULLABLE_FIELD_NOT_INITIALIZED*/x;');
- check(nonnullableTypes: <String>['dart:core,int']);
+ await check(nonnullableTypes: <String>['dart:core,int']);
}
}

Powered by Google App Engine
This is Rietveld 408576698