Files
sdk/tests/language_2/mixin/deduplication_test.dart
T
Robert Nystrom fc1b1ecc71 Move files under language_2 into subdirectories.
Change-Id: Idbcc965a27e9ffeedf5e0a1068b019de4193070f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127745
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2019-12-11 19:18:00 +00:00

47 lines
825 B
Dart

// Copyright (c) 2018, 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.
// Test mixin de-duplication with new mixin syntax.
import 'package:expect/expect.dart';
class A {
int foo() => 1;
}
class B {
int bar() => 2;
}
abstract class C implements A, B {
}
mixin M1 on A, B {
int sum() => foo() + bar();
}
mixin M2 on A, B, M1 {
int sumX2() => sum()*2;
}
class X extends C with M1, M2 {
int foo() => 4;
int bar() => 5;
}
class Y extends C with M1, M2 {
int foo() => 7;
int bar() => 10;
}
X x = new X();
Y y = new Y();
void main() {
Expect.equals(9, x.sum());
Expect.equals(18, x.sumX2());
Expect.equals(17, y.sum());
Expect.equals(34, y.sumX2());
}