blob: 7f89a7148a087b42c8e7f9621f6cd586f4be430d [file] [log] [blame]
// Copyright (c) 2019, 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:analyzer/src/error/codes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(NullAwareBeforeOperatorTest);
});
}
@reflectiveTest
class NullAwareBeforeOperatorTest extends DriverResolutionTest {
test_assignment() async {
await assertNoErrorsInCode(r'''
m(x) {
x?.a = '';
}
''');
}
test_equal_equal() async {
await assertNoErrorsInCode(r'''
m(x) {
x?.a == '';
}
''');
}
test_is() async {
await assertNoErrorsInCode(r'''
m(x) {
x?.a is String;
}
''');
}
test_is_not() async {
await assertNoErrorsInCode(r'''
m(x) {
x?.a is! String;
}
''');
}
test_minus() async {
await assertErrorCodesInCode(r'''
m(x) {
x?.a - '';
}
''', [HintCode.NULL_AWARE_BEFORE_OPERATOR]);
}
test_not_equal() async {
await assertNoErrorsInCode(r'''
m(x) {
x?.a != '';
}
''');
}
test_question_question() async {
await assertNoErrorsInCode(r'''
m(x) {
x?.a ?? true;
}
''');
}
}