Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// 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.

/// @assertion The semantics of the declaring constructor is found in the
/// following steps, where `D` is the class, extension type, or enum declaration
/// in the program that includes a declaring constructor `k`, and `D2` is the
/// result of the derivation of the semantics of `D`. The derivation step will
/// delete elements that amount to the declaring constructor. Semantically, it
/// will add a new constructor `k2`, and it will add zero or more instance
/// variable declarations.
/// @assertion The semantics of the primary constructor is found in the
/// following steps, where `D` is the class, mixin class, extension type, or
/// enum declaration in the program that includes a primary constructor `k`, and
/// `D2` is the result of the derivation of the semantics of `D`. The derivation
/// step will delete elements that amount to the primary constructor.
/// Semantically, it will add a new constructor `k2`, and it will add zero or
/// more instance variable declarations.
/// ...
/// The formal parameter list `L2` of `k2` is identical to `L`, except that each
/// formal parameter is processed as follows.
Expand All @@ -27,62 +27,29 @@

import '../../Utils/expect.dart';

String log;

class C1(this.v1, var String v2, final bool v3) {
class C(this.v1, var String v2, final bool v3) {
int v1;
}

class C2 {
String v2;
this(final int v1, String v2, var bool v3) : this.v2 = v2;
}

extension type ET1(int v1);
extension type ET(int v1);

extension type ET2 {
this(int v1, final String v2, bool v3) {
log = "v1=$v1;v3=$v3";
}
}

enum E1(final int v1, this.v2, final bool v3) {
enum E(final int v1, this.v2, final bool v3) {
e0(1, "two", true);
final String v2;
}

enum E2 {
e0(1, "two", false);
final String v2;
const this(final int v1, String v2, final bool v3) : this.v2 = v2;
}

main() {
Expect.isTrue(C1.new is C1 Function(int, String, bool));
var c1 = C1(1, "two", true);
Expect.equals(1, c1.v1);
Expect.equals("two", c1.v2);
Expect.isTrue(c1.v3);

Expect.isTrue(C2.new is C2 Function(int, String, bool));
var c2 = C2(1, "two", false);
Expect.equals(1, c2.v1);
Expect.equals("two", c2.v2);
Expect.isFalse(c2.v3);

Expect.isTrue(ET1.new is ET1 Function(int));
var et1 = ET1(1);
Expect.equals(1, et1.v1);

Expect.isTrue(ET2.new is ET2 Function(int, String, bool));
var et2 = ET2(1, "two", true);
Expect.equals("two", et2.v2);
Expect.equals("v1=1;v3=true", log);

Expect.equals(1, E1.e0.v1);
Expect.equals("two", E1.e0.v2);
Expect.isTrue(E1.e0.v3);
Expect.equals(1, E2.e0.v1);
Expect.equals("two", E2.e0.v2);
Expect.isTrue(E2.e0.v3);
Expect.isTrue(C.new is C Function(int, String, bool));
var c = C(1, "two", true);
Expect.equals(1, c.v1);
Expect.equals("two", c.v2);
Expect.isTrue(c.v3);

Expect.isTrue(ET.new is ET Function(int));
var et = ET(1);
Expect.equals(1, et.v1);

Expect.equals(1, E.e0.v1);
Expect.equals("two", E.e0.v2);
Expect.isTrue(E.e0.v3);
}
112 changes: 33 additions & 79 deletions LanguageFeatures/Primary-constructors/static_processing_A17_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// 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.

/// @assertion The semantics of the declaring constructor is found in the
/// following steps, where `D` is the class, extension type, or enum declaration
/// in the program that includes a declaring constructor `k`, and `D2` is the
/// result of the derivation of the semantics of `D`. The derivation step will
/// delete elements that amount to the declaring constructor. Semantically, it
/// will add a new constructor `k2`, and it will add zero or more instance
/// variable declarations.
/// @assertion The semantics of the primary constructor is found in the
/// following steps, where `D` is the class, mixin class, extension type, or
/// enum declaration in the program that includes a primary constructor `k`, and
/// `D2` is the result of the derivation of the semantics of `D`. The derivation
/// step will delete elements that amount to the primary constructor.
/// Semantically, it will add a new constructor `k2`, and it will add zero or
/// more instance variable declarations.
/// ...
/// The formal parameter list `L2` of `k2` is identical to `L`, except that each
/// formal parameter is processed as follows.
Expand All @@ -28,85 +28,39 @@

import '../../Utils/expect.dart';

String log = "";

class C1([this.v1 = 1, var String v2 = "two", final bool v3 = true]) {
class C([this.v1 = 1, var String v2 = "two", final bool v3 = true]) {
int v1;
}

class C2 {
String v2;
this([final int v1 = 1, String v2 = "2", var bool v3 = true]) : this.v2 = v2;
}

extension type ET1([int v1 = 0]);

extension type ET2 {
this([int v1 = 1, final String v2 = "two", bool v3 = true]) {
log = "v1=$v1;v3=$v3";
}
}

enum E1([final int v1 = 1, this.v2 = "two", final bool v3 = true]) {
e0, e1(42, "2", false);
final String v2;
}
extension type ET([int v1 = 0]);

enum E2 {
enum E([final int v1 = 1, this.v2 = "two", final bool v3 = true]) {
e0, e1(42, "2", false);
final String v2;
const this([final int v1 = 1, String v2 = "two", final bool v3 = true])
: this.v2 = v2;
}

main() {
Expect.isTrue(C1.new is C1 Function([int, String, bool]));
var c1 = C1(42, "2", false);
Expect.equals(42, c1.v1);
Expect.equals("2", c1.v2);
Expect.isFalse(c1.v3);

c1 = C1();
Expect.equals(1, c1.v1);
Expect.equals("two", c1.v2);
Expect.isTrue(c1.v3);

Expect.isTrue(C2.new is C2 Function([int, String, bool]));
var c2 = C2(42, "two", false);
Expect.equals(42, c2.v1);
Expect.equals("two", c2.v2);
Expect.isFalse(c2.v3);

c2 = C2();
Expect.equals(1, c2.v1);
Expect.equals("2", c2.v2);
Expect.isTrue(c2.v3);

Expect.isTrue(ET1.new is ET1 Function([int]));
var et1 = ET1(42);
Expect.equals(42, et1.v1);
et1 = ET1();
Expect.equals(1, et1.v1);

Expect.isTrue(ET2.new is ET2 Function([int, String, bool]));
var et2 = ET2(42, "2", false);
Expect.equals("2", et2.v2);
Expect.equals("v1=42;v3=false", log);
et2 = ET2();
Expect.equals("two", et2.v2);
Expect.equals("v1=1;v3=true", log);

Expect.equals(1, E1.e0.v1);
Expect.equals("two", E1.e0.v2);
Expect.isTrue(E1.e0.v3);
Expect.equals(42, E1.e1.v1);
Expect.equals("2", E1.e1.v2);
Expect.isFalse(E1.e1.v3);

Expect.equals(1, E2.e0.v1);
Expect.equals("two", E2.e0.v2);
Expect.isTrue(E2.e0.v3);
Expect.equals(42, E2.e1.v1);
Expect.equals("2", E2.e1.v2);
Expect.isFalse(E2.e1.v3);
Expect.isTrue(C.new is C Function([int, String, bool]));
var c = C(42, "2", false);
Expect.equals(42, c.v1);
Expect.equals("2", c.v2);
Expect.isFalse(c.v3);

c = C();
Expect.equals(1, c.v1);
Expect.equals("two", c.v2);
Expect.isTrue(c.v3);

Expect.isTrue(ET.new is ET Function([int]));
var et = ET(42);
Expect.equals(42, et.v1);
et = ET();
Expect.equals(0, et.v1);

Expect.equals(1, E.e0.v1);
Expect.equals("two", E.e0.v2);
Expect.isTrue(E.e0.v3);
Expect.equals(42, E.e1.v1);
Expect.equals("2", E.e1.v2);
Expect.isFalse(E.e1.v3);
}
112 changes: 33 additions & 79 deletions LanguageFeatures/Primary-constructors/static_processing_A17_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// 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.

/// @assertion The semantics of the declaring constructor is found in the
/// following steps, where `D` is the class, extension type, or enum declaration
/// in the program that includes a declaring constructor `k`, and `D2` is the
/// result of the derivation of the semantics of `D`. The derivation step will
/// delete elements that amount to the declaring constructor. Semantically, it
/// will add a new constructor `k2`, and it will add zero or more instance
/// variable declarations.
/// @assertion The semantics of the primary constructor is found in the
/// following steps, where `D` is the class, mixin class, extension type, or
/// enum declaration in the program that includes a primary constructor `k`, and
/// `D2` is the result of the derivation of the semantics of `D`. The derivation
/// step will delete elements that amount to the primary constructor.
/// Semantically, it will add a new constructor `k2`, and it will add zero or
/// more instance variable declarations.
/// ...
/// The formal parameter list `L2` of `k2` is identical to `L`, except that each
/// formal parameter is processed as follows.
Expand All @@ -27,85 +27,39 @@

import '../../Utils/expect.dart';

String log = "";

class C1({this.v1 = 1, var String v2 = "two", final bool v3 = true}) {
class C({this.v1 = 1, var String v2 = "two", final bool v3 = true}) {
int v1;
}

class C2 {
String v2;
this({final int v1 = 1, String v2 = "2", var bool v3 = true}) : this.v2 = v2;
}

extension type ET1({int v1 = 0});

extension type ET2 {
this({int v1 = 1, final String v2 = "two", bool v3 = true}) {
log = "v1=$v1;v3=$v3";
}
}

enum E1({final int v1 = 1, this.v2 = "two", final bool v3 = true}) {
e0, e1(v1: 42, v2: "2", v3: false);
final String v2;
}
extension type ET({int v1 = 0});

enum E2 {
enum E({final int v1 = 1, this.v2 = "two", final bool v3 = true}) {
e0, e1(v1: 42, v2: "2", v3: false);
final String v2;
const this({final int v1 = 1, String v2 = "two", final bool v3 = true})
: this.v2 = v2;
}

main() {
Expect.isTrue(C1.new is C1 Function({int v1, String v2, bool v3}));
var c1 = C1(v1: 42, v2: "2", v3: false);
Expect.equals(42, c1.v1);
Expect.equals("2", c1.v2);
Expect.isFalse(c1.v3);

c1 = C1();
Expect.equals(1, c1.v1);
Expect.equals("two", c1.v2);
Expect.isTrue(c1.v3);

Expect.isTrue(C2.new is C2 Function({int v1, String v2, bool v3}));
var c2 = C2(v1: 42, v2: "two", v3: false);
Expect.equals(42, c2.v1);
Expect.equals("two", c2.v2);
Expect.isFalse(c2.v3);

c2 = C2();
Expect.equals(1, c2.v1);
Expect.equals("2", c2.v2);
Expect.isTrue(c2.v3);

Expect.isTrue(ET1.new is ET1 Function({int v1}));
var et1 = ET1(v1: 42);
Expect.equals(42, et1.v1);
et1 = ET1();
Expect.equals(1, et1.v1);

Expect.isTrue(ET2.new is ET2 Function({int v1, String v2, bool v3}));
var et2 = ET2(42, "2", false);
Expect.equals("2", et2.v2);
Expect.equals("v1=42;v3=false", log);
et2 = ET2();
Expect.equals("two", et2.v2);
Expect.equals("v1=1;v3=true", log);

Expect.equals(1, E1.e0.v1);
Expect.equals("two", E1.e0.v2);
Expect.isTrue(E1.e0.v3);
Expect.equals(42, E1.e1.v1);
Expect.equals("2", E1.e1.v2);
Expect.isFalse(E1.e1.v3);

Expect.equals(1, E2.e0.v1);
Expect.equals("two", E2.e0.v2);
Expect.isTrue(E2.e0.v3);
Expect.equals(42, E2.e1.v1);
Expect.equals("2", E2.e1.v2);
Expect.isFalse(E2.e1.v3);
Expect.isTrue(C.new is C Function({int v1, String v2, bool v3}));
var c = C(v1: 42, v2: "2", v3: false);
Expect.equals(42, c.v1);
Expect.equals("2", c.v2);
Expect.isFalse(c.v3);

c = C();
Expect.equals(1, c.v1);
Expect.equals("two", c.v2);
Expect.isTrue(c.v3);

Expect.isTrue(ET.new is ET Function({int v1}));
var et = ET(v1: 42);
Expect.equals(42, et.v1);
et = ET();
Expect.equals(0, et.v1);

Expect.equals(1, E.e0.v1);
Expect.equals("two", E.e0.v2);
Expect.isTrue(E.e0.v3);
Expect.equals(42, E.e1.v1);
Expect.equals("2", E.e1.v2);
Expect.isFalse(E.e1.v3);
}
Loading