2edcad4892
Cleaned up and formatted the tests, regenerated some errors where they were "unspecified", and removed the experiment flag enabling in each test. Bug: https://github.com/dart-lang/sdk/issues/61687 Change-Id: Ic5b652af660cbc4f71731b1547c7a58c7726faca Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503500 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Kallen Tu <kallentu@google.com>
47 lines
1.1 KiB
Dart
47 lines
1.1 KiB
Dart
// 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.
|
|
|
|
// Tests declaring constructors with various clauses.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
// Generics
|
|
class GenericsHeader<T>(final T x);
|
|
|
|
// Extends
|
|
class Base {}
|
|
|
|
class ExtendsHeader(final int x) extends Base;
|
|
|
|
// Implements
|
|
abstract class Interface {
|
|
int method();
|
|
}
|
|
|
|
class ImplementsHeader(final int x) implements Interface {
|
|
@override
|
|
int method() => x + 1;
|
|
}
|
|
|
|
// With
|
|
mixin Mixin {}
|
|
|
|
class WithHeader(final int x) with Mixin;
|
|
|
|
// Combination
|
|
class AllHeader<T>(final T x) extends Base with Mixin implements Interface {
|
|
@override
|
|
int method() => 1;
|
|
}
|
|
|
|
void main() {
|
|
Expect.equals(1, GenericsHeader<int>(1).x);
|
|
Expect.equals(1, ExtendsHeader(1).x);
|
|
Expect.equals(2, ImplementsHeader(1).method());
|
|
Expect.equals(1, ImplementsHeader(1).x);
|
|
Expect.equals(1, WithHeader(1).x);
|
|
Expect.equals(1, AllHeader<int>(1).method());
|
|
Expect.equals(1, AllHeader<int>(1).x);
|
|
}
|