blob: 8acf4e905947afe9dc37ba45b4c49ea90c6920f8 [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:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(ConstEvalTypeBoolNumStringTest);
});
}
@reflectiveTest
class ConstEvalTypeBoolNumStringTest extends PubPackageResolutionTest {
test_equal() async {
await assertErrorsInCode(
r'''
class A {
const A();
}
const num a = 0;
const b = a == const A();
''',
IsEnabledByDefault.constant_update_2018
? []
: [
error(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING, 53,
14),
]);
}
test_notEqual() async {
await assertErrorsInCode(r'''
class A {
const A();
}
const num a = 0;
const _ = a != const A();
''', [
error(HintCode.UNUSED_ELEMENT, 49, 1),
error(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING, 53, 14),
]);
}
}