blob: 0e6375efc6a370306c7b806fb663f81a04c4356b [file]
// Copyright (c) 2023, 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/diagnostic/diagnostic.dart' as diag;
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/context_collection_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(MixinClassDeclarationTest);
});
}
@reflectiveTest
class MixinClassDeclarationTest extends PubPackageResolutionTest {
test_class_extends_class() async {
await assertErrorsInCode(
r'''
class A {}
mixin class B extends A {}
''',
[error(diag.mixinClassDeclarationExtendsNotObject, 33, 1)],
);
}
test_class_extends_Object() async {
await assertNoErrorsInCode(r'''
mixin class A extends Object {}
''');
}
test_class_extends_Object_with() async {
await assertErrorsInCode(
r'''
mixin M {}
mixin class A extends Object with M {}
''',
[error(diag.mixinClassDeclarationWithClause, 40, 6)],
);
}
test_classTypeAlias_with() async {
await assertNoErrorsInCode(r'''
mixin M {}
mixin class A = Object with M;
''');
}
test_classTypeAlias_with2() async {
await assertErrorsInCode(
r'''
mixin M1 {}
mixin M2 {}
mixin class A = Object with M1, M2;
''',
[
error(
diag.mixinModifierMixinApplicationClassWithMultipleMixins,
47,
11,
),
],
);
}
}