Files
sdk/tests/language/field/parameter_test.dart
T
Robert Nystrom 8e9d1445dd Migrate language_2/field to NNBD.
Change-Id: Ic0c7e51d6be12dba4500f0fc41378466c6043245
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142803
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2020-04-08 19:16:25 +00:00

40 lines
1.1 KiB
Dart

// Copyright (c) 2012, 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.
// Dart test program for testing setting/getting of instance fields.
import "package:expect/expect.dart";
class A {
int? x = 4;
A(this.x);
A.named([this.x]);
A.named2([this.x = 2]);
A.named3();
}
class B extends A {
B(x) : super(x + 10);
B.named_() : super.named();
B.named(x) : super.named(x + 10);
B.named2_() : super.named2();
B.named2(x) : super.named2(x + 10);
B.named3() : super.named3();
}
main() {
Expect.equals(0, new A(0).x);
Expect.equals(null, new A.named().x);
Expect.equals(1, new A.named(1).x);
Expect.equals(2, new A.named2().x);
Expect.equals(3, new A.named2(3).x);
Expect.equals(4, new A.named3().x);
Expect.equals(10, new B(0).x);
Expect.equals(null, new B.named_().x);
Expect.equals(11, new B.named(1).x);
Expect.equals(2, new B.named2_().x);
Expect.equals(13, new B.named2(3).x);
Expect.equals(4, new B.named3().x);
}