blob: e29f77ddccb06c02e6cab03fe0d2145588138b1d [file] [log] [blame]
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(AwaitExpressionResolutionTest);
defineReflectiveTests(AwaitExpressionResolutionWithNullSafetyTest);
});
}
@reflectiveTest
class AwaitExpressionResolutionTest extends PubPackageResolutionTest
with WithoutNullSafetyMixin {
test_future() async {
await assertNoErrorsInCode(r'''
f(Future<int> a) async {
await a;
}
''');
assertType(findNode.awaitExpression('await a'), 'int');
}
test_futureOr() async {
await assertNoErrorsInCode(r'''
import 'dart:async';
f(FutureOr<int> a) async {
await a;
}
''');
assertType(findNode.awaitExpression('await a'), 'int');
}
}
@reflectiveTest
class AwaitExpressionResolutionWithNullSafetyTest
extends PubPackageResolutionTest with WithNullSafetyMixin {
test_futureOrQ() async {
await assertNoErrorsInCode(r'''
import 'dart:async';
f(FutureOr<int>? a) async {
await a;
}
''');
assertType(findNode.awaitExpression('await a'), 'int?');
}
test_futureQ() async {
await assertNoErrorsInCode(r'''
f(Future<int>? a) async {
await a;
}
''');
assertType(findNode.awaitExpression('await a'), 'int?');
}
}