blob: 4577db15f8f98681bff7ccf6606a2c2b16ce5fb4 [file] [log] [blame]
// Copyright (c) 2025, 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.
mixin A {
static String get mixinGetter => "A.mixinGetter";
static void set mixinSetter(num value) {
throw "A.mixinSetter=";
}
static String mixinMethod() => "A.mixinMethod";
}
extension E on A {
static String get mixinGetter => "E.mixinGetter";
static String get extensionGetter => "E.extensionGetter";
static void set mixinSetter(num value) {}
static void set extensionSetter(bool value) {}
static String mixinMethod() => "E.mixinMethod";
static String extensionMethod() => "E.extensionMethod";
}
main() {
expectEqual(A.mixinGetter, "A.mixinGetter");
expectEqual(A.extensionGetter, "E.extensionGetter");
expectThrows(() {
A.mixinSetter = 0;
});
expectDoesntThrow(() {
A.extensionSetter = false;
});
expectEqual(A.mixinMethod(), "A.mixinMethod");
expectEqual(A.extensionMethod(), "E.extensionMethod");
}
expectEqual(a, b) {
if (a != b) {
throw "Expected the values to be equal.";
}
}
expectThrows(Function() f) {
bool hasThrown = false;
try {
f();
} on dynamic {
hasThrown = true;
}
if (!hasThrown) {
throw "Expected the function to throw an exception.";
}
}
expectDoesntThrow(Function() f) {
bool hasThrown = true;
try {
f();
hasThrown = false;
} on dynamic {}
if (hasThrown) {
throw "Expected the function not to throw exceptions.";
}
}