#1087. Constructor tear-off tests fixed, new ones added
diff --git a/LanguageFeatures/Constructor-tear-offs/explicity_instantiated_A01_t01.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t01.dart
similarity index 100%
rename from LanguageFeatures/Constructor-tear-offs/explicity_instantiated_A01_t01.dart
rename to LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t01.dart
diff --git a/LanguageFeatures/Constructor-tear-offs/explicity_instantiated_A01_t02.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t02.dart
similarity index 100%
rename from LanguageFeatures/Constructor-tear-offs/explicity_instantiated_A01_t02.dart
rename to LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t02.dart
diff --git a/LanguageFeatures/Constructor-tear-offs/explicity_instantiated_A01_t03.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t03.dart
similarity index 100%
rename from LanguageFeatures/Constructor-tear-offs/explicity_instantiated_A01_t03.dart
rename to LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t03.dart
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t04.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t04.dart
new file mode 100644
index 0000000..90918af
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t04.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion We will introduce syntax allowing you to explicitly instantiate a
+/// function tear-off and a type literal for a generic class. The former for
+/// consistency with constructor tear-offs, the latter to introduce in-line
+/// types without needing a typedef, like we did for function types. And we do
+/// both now because they share the same grammar productions.
+///
+/// Example:
+///
+/// T id<T>(T value) => value;
+/// var idInt = id<int>; // Explicitly instantiated tear-off, saves on writing function types.
+/// and
+/// Type intList = List<int>; // In-line instantiated type literal.
+///
+/// @description Checks example from the Spec.
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+T id<T>(T value) => value;
+var idInt = id<int>;
+
+main() {
+ dynamic v = 42;
+ var i = idInt(v);
+ Expect.isTrue(i is int);
+ Expect.isFalse(i is double); // to check that i is not dynamic
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/goal_t01_A01.dart b/LanguageFeatures/Constructor-tear-offs/goal_t01_A01.dart
index 4d80a20..2a179b0 100644
--- a/LanguageFeatures/Constructor-tear-offs/goal_t01_A01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/goal_t01_A01.dart
@@ -37,16 +37,15 @@
}
main() {
- Expect.equals(0, C.new());
- Expect.equals(0, (C.new)());
+ Expect.equals(0, C.new().i);
+ Expect.equals(0, (C.new)().i);
- Expect.equals(1, C.constr1(1));
- Expect.equals(1, (C.constr1)(1));
+ Expect.equals(1, C.constr1(42).i);
+ Expect.equals(1, (C.constr1)(42).i);
- Expect.equals(2, C.constr2(1, "123"));
- Expect.equals(2, (C.constr2)(1, "123"));
+ Expect.equals(2, C.constr2(1, "123").i);
+ Expect.equals(2, (C.constr2)(1, "123").i);
- Expect.equals(1, C.constr3());
- Expect.equals(1, (C.constr3)());
+ Expect.equals(3, C.constr3().i);
+ Expect.equals(3, (C.constr3)().i);
}
-
diff --git a/LanguageFeatures/Constructor-tear-offs/goal_t01_A02.dart b/LanguageFeatures/Constructor-tear-offs/goal_t01_A02.dart
index b721181..6b641f3 100644
--- a/LanguageFeatures/Constructor-tear-offs/goal_t01_A02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/goal_t01_A02.dart
@@ -37,39 +37,39 @@
}
main() {
- Expect.equals(0, C.new());
- Expect.equals(0, (C.new)());
- Expect.equals(0, C<dynamic>.new());
- Expect.equals(0, (C<dynamic>.new)());
- Expect.equals(0, (C.new)<dynamic>());
- Expect.equals(0, C<int>.new());
- Expect.equals(0, (C<int>.new)());
- Expect.equals(0, (C.new)<int>());
+ Expect.equals(0, C.new().i);
+ Expect.equals(0, (C.new)().i);
+ Expect.equals(0, C<dynamic>.new().i);
+ Expect.equals(0, (C<dynamic>.new)().i);
+ Expect.equals(0, (C.new)<dynamic>().i);
+ Expect.equals(0, C<int>.new().i);
+ Expect.equals(0, (C<int>.new)().i);
+ Expect.equals(0, (C.new)<int>().i);
- Expect.equals(1, C.constr1(1));
- Expect.equals(1, (C.constr1)(1));
- Expect.equals(1, C<dynamic>.constr1(1));
- Expect.equals(1, (C<dynamic>.constr1)(1));
- Expect.equals(1, (C.constr1)<dynamic>(1));
- Expect.equals(1, C<int>.constr1(1));
- Expect.equals(1, (C<int>.constr1)(1));
- Expect.equals(1, (C.constr1)<int>(1));
+ Expect.equals(1, C.constr1(42).i);
+ Expect.equals(1, (C.constr1)(42).i);
+ Expect.equals(1, C<dynamic>.constr1(42).i);
+ Expect.equals(1, (C<dynamic>.constr1)(42).i);
+ Expect.equals(1, (C.constr1)<dynamic>(42).i);
+ Expect.equals(1, C<int>.constr1(42).i);
+ Expect.equals(1, (C<int>.constr1)(42).i);
+ Expect.equals(1, (C.constr1)<int>(42).i);
- Expect.equals(2, C.constr2(1, ""));
- Expect.equals(2, (C.constr2)(1, ""));
- Expect.equals(2, C<dynamic>.constr1(1, ""));
- Expect.equals(2, (C<dynamic>.constr2)(1, ""));
- Expect.equals(2, (C.constr2)<dynamic>(1, ""));
- Expect.equals(2, C<int>.constr1(1, ""));
- Expect.equals(2, (C<int>.constr2)(1, ""));
- Expect.equals(2, (C.constr2)<int>(1, ""));
+ Expect.equals(2, C.constr2(1, "").i);
+ Expect.equals(2, (C.constr2)(1, "").i);
+ Expect.equals(2, C<dynamic>.constr1(1, "").i);
+ Expect.equals(2, (C<dynamic>.constr2)(1, "").i);
+ Expect.equals(2, (C.constr2)<dynamic>(1, "").i);
+ Expect.equals(2, C<int>.constr1(1, "").i);
+ Expect.equals(2, (C<int>.constr2)(1, "").i);
+ Expect.equals(2, (C.constr2)<int>(1, "").i);
- Expect.equals(3, C.constr3());
- Expect.equals(3, (C.constr3)());
- Expect.equals(3, C<dynamic>.constr3());
- Expect.equals(3, (C<dynamic>.constr3)());
- Expect.equals(3, (C.constr3)<dynamic>());
- Expect.equals(3, C<int>.constr3());
- Expect.equals(3, (C<int>.constr3)());
- Expect.equals(3, (C.constr3)<int>());
+ Expect.equals(3, C.constr3().i);
+ Expect.equals(3, (C.constr3)().i);
+ Expect.equals(3, C<dynamic>.constr3().i);
+ Expect.equals(3, (C<dynamic>.constr3)().i);
+ Expect.equals(3, (C.constr3)<dynamic>().i);
+ Expect.equals(3, C<int>.constr3().i);
+ Expect.equals(3, (C<int>.constr3)().i);
+ Expect.equals(3, (C.constr3)<int>().i);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/goal_t01_A03.dart b/LanguageFeatures/Constructor-tear-offs/goal_t01_A03.dart
index 3cfc1a3..b75102a 100644
--- a/LanguageFeatures/Constructor-tear-offs/goal_t01_A03.dart
+++ b/LanguageFeatures/Constructor-tear-offs/goal_t01_A03.dart
@@ -37,39 +37,39 @@
}
main() {
- Expect.equals(0, C.new());
- Expect.equals(0, (C.new)());
- Expect.equals(0, C<num>.new());
- Expect.equals(0, (C<num>.new)());
- Expect.equals(0, (C.new)<num>());
- Expect.equals(0, C<int>.new());
- Expect.equals(0, (C<int>.new)());
- Expect.equals(0, (C.new)<int>());
+ Expect.equals(0, C.new().i);
+ Expect.equals(0, (C.new)().i);
+ Expect.equals(0, C<num>.new().i);
+ Expect.equals(0, (C<num>.new)().i);
+ Expect.equals(0, (C.new)<num>().i);
+ Expect.equals(0, C<int>.new().i);
+ Expect.equals(0, (C<int>.new)().i);
+ Expect.equals(0, (C.new)<int>().i);
- Expect.equals(1, C.constr1(1));
- Expect.equals(1, (C.constr1)(1));
- Expect.equals(1, C<num>.constr1(1));
- Expect.equals(1, (C<num>.constr1)(1));
- Expect.equals(1, (C.constr1)<num>(1));
- Expect.equals(1, C<int>.constr1(1));
- Expect.equals(1, (C<int>.constr1)(1));
- Expect.equals(1, (C.constr1)<int>(1));
+ Expect.equals(1, C.constr1(42).i);
+ Expect.equals(1, (C.constr1)(42).i);
+ Expect.equals(1, C<num>.constr1(42).i);
+ Expect.equals(1, (C<num>.constr1)(42).i);
+ Expect.equals(1, (C.constr1)<num>(42).i);
+ Expect.equals(1, C<int>.constr1(42).i);
+ Expect.equals(1, (C<int>.constr1)(42).i);
+ Expect.equals(1, (C.constr1)<int>(42).i);
- Expect.equals(2, C.constr2(1, ""));
- Expect.equals(2, (C.constr2)(1, ""));
- Expect.equals(2, C<dynamic>.constr1(1, ""));
- Expect.equals(2, (C<dynamic>.constr2)(1, ""));
- Expect.equals(2, (C.constr2)<dynamic>(1, ""));
- Expect.equals(2, C<int>.constr1(1, ""));
- Expect.equals(2, (C<int>.constr2)(1, ""));
- Expect.equals(2, (C.constr2)<int>(1, ""));
+ Expect.equals(2, C.constr2(1, "").i);
+ Expect.equals(2, (C.constr2)(1, "").i);
+ Expect.equals(2, C<dynamic>.constr1(1, "").i);
+ Expect.equals(2, (C<dynamic>.constr2)(1, "").i);
+ Expect.equals(2, (C.constr2)<dynamic>(1, "").i);
+ Expect.equals(2, C<int>.constr1(1, "").i);
+ Expect.equals(2, (C<int>.constr2)(1, "").i);
+ Expect.equals(2, (C.constr2)<int>(1, "").i);
- Expect.equals(3, C.constr3());
- Expect.equals(3, (C.constr3)());
- Expect.equals(3, C<dynamic>.constr3());
- Expect.equals(3, (C<dynamic>.constr3)());
- Expect.equals(3, (C.constr3)<dynamic>());
- Expect.equals(3, C<int>.constr3());
- Expect.equals(3, (C<int>.constr3)());
- Expect.equals(3, (C.constr3)<int>());
+ Expect.equals(3, C.constr3().i);
+ Expect.equals(3, (C.constr3)().i);
+ Expect.equals(3, C<dynamic>.constr3().i);
+ Expect.equals(3, (C<dynamic>.constr3)().i);
+ Expect.equals(3, (C.constr3)<dynamic>().i);
+ Expect.equals(3, C<int>.constr3().i);
+ Expect.equals(3, (C<int>.constr3)().i);
+ Expect.equals(3, (C.constr3)<int>().i);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t01.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t01.dart
index 6ec6315..9a51b46 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t01.dart
@@ -22,7 +22,7 @@
import "../../Utils/expect.dart";
class C {
- final bool called = false;
+ bool called = false;
C.constr(int i) {
called = true;
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t03.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t03.dart
index 5f11aac..c7bb621 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t03.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t03.dart
@@ -56,9 +56,12 @@
// [cfe] unspecified
C Function(Never) v8 = C.constr;
+// ^
+// [analyzer] unspecified
+// [cfe] unspecified
C Function(Null) v9 = C.constr;
-// ^
+// ^
// [analyzer] unspecified
// [cfe] unspecified
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t06.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t06.dart
index a0bded9..a52cd60 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t06.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t06.dart
@@ -12,6 +12,8 @@
///
/// @description Checks that initializing formals are represented by normal
/// parameters with the same name and type.
+/// @author iarkh@unipro.ru
+/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs
@@ -23,13 +25,16 @@
C.name(this.x, this.y);
}
-dynamic d = 0.5;
-
main() {
+ final dynamic d = 0.5;
var v = C.name;
Expect.isTrue(v is C Function(int x, dynamic y));
- v(42, "I am strong");
+ var x = v(42, "Lily was here");
+ Expect.equals(42, x.x);
+ Expect.equals("Lily was here", x.y);
+ var y = v(1, d);
+ Expect.equals(1, y.x);
+ Expect.equals(d, y.y);
Expect.throws(() { v(d, "test"); });
- Expect.throws(() { v(1, d); });
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t14.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t14.dart
index 3a6b758..bba2429 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t14.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t14.dart
@@ -38,7 +38,7 @@
main() {
var v = C.constr;
- Expect.isTrue(v is C Function(int i, {int? j, String s}));
+ Expect.isTrue(v is C Function(int i, [int? j, String s]));
C c1 = v(1);
c1.check(1, null, "testme");
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t16.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t16.dart
index 9b59bc8..bbbe3ef 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t16.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t16.dart
@@ -28,17 +28,11 @@
jj = j;
ss = s;
}
-
- void check(exp1, exp2, exp3) {
- Expect.equals(exp1, ii);
- Expect.equals(exp2, jj);
- Expect.equals(exp3, ss);
- }
}
-dynamic d = 1.5;
-
main() {
+ final dynamic d = 3.14;
+
var v = C.constr;
Expect.throws(() { v(1, d); });
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t01.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t01.dart
index 4f589a4..b1faecd 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t01.dart
@@ -23,8 +23,5 @@
main() {
var v1 = C.new;
var v2 = C.new;
- var v3 = C.new;
Expect.equals(v1, v2);
- Expect.equals(v1, v3);
- Expect.equals(v2, v3);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t02.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t02.dart
index b9007d4..d5f1d28 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t02.dart
@@ -25,26 +25,17 @@
main() {
var v1 = C.name1;
var v2 = C.name1;
- var v3 = C.name1;
Expect.equals(v1, v2);
- Expect.equals(v1, v3);
- Expect.equals(v2, v3);
var v4 = C.name2;
var v5 = C.name2;
- var v6 = C.name2;
Expect.equals(v4, v5);
- Expect.equals(v4, v6);
- Expect.equals(v5, v6);
var v7 = C.name3;
var v8 = C.name3;
- var v9 = C.name3;
Expect.equals(v7, v8);
- Expect.equals(v7, v9);
- Expect.equals(v8, v9);
Expect.notEquals(v1, v4);
Expect.notEquals(v2, v7);
- Expect.notEquals(v5, v9);
+ Expect.notEquals(v5, v8);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t03.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t03.dart
index 6be5c48..a2a7dd9 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t03.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t03.dart
@@ -26,26 +26,17 @@
main() {
var v1 = C.new;
var v2 = C.new;
- var v3 = C.new;
Expect.equals(v1, v2);
- Expect.equals(v1, v3);
- Expect.equals(v2, v3);
var v4 = C.constr1;
var v5 = C.constr1;
- var v6 = C.constr1;
Expect.equals(v4, v5);
- Expect.equals(v4, v6);
- Expect.equals(v5, v6);
var v7 = C.constr1;
var v8 = C.constr1;
- var v9 = C.constr1;
Expect.equals(v7, v8);
- Expect.equals(v7, v9);
- Expect.equals(v8, v9);
Expect.notEquals(v1, v4);
Expect.notEquals(v2, v7);
- Expect.notEquals(v5, v9);
+ Expect.notEquals(v5, v8);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t04.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t04.dart
index 7597f6f..7cc2355 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t04.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t04.dart
@@ -25,26 +25,17 @@
main() {
var v1 = C.name1;
var v2 = C.name1;
- var v3 = C.name1;
Expect.equals(v1, v2);
- Expect.equals(v1, v3);
- Expect.equals(v2, v3);
var v4 = C.name2;
var v5 = C.name2;
- var v6 = C.name2;
Expect.equals(v4, v5);
- Expect.equals(v4, v6);
- Expect.equals(v5, v6);
var v7 = C.name3;
var v8 = C.name3;
- var v9 = C.name3;
Expect.equals(v7, v8);
- Expect.equals(v7, v9);
- Expect.equals(v8, v9);
Expect.notEquals(v1, v4);
Expect.notEquals(v2, v7);
- Expect.notEquals(v5, v9);
+ Expect.notEquals(v5, v8);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t05.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t05.dart
index c1f5ad1..062d575 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t05.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t05.dart
@@ -25,26 +25,17 @@
main() {
var v1 = C.name1;
var v2 = C.name1;
- var v3 = C.name1;
Expect.equals(v1, v2);
- Expect.equals(v1, v3);
- Expect.equals(v2, v3);
var v4 = C.name2;
var v5 = C.name2;
- var v6 = C.name2;
Expect.equals(v4, v5);
- Expect.equals(v4, v6);
- Expect.equals(v5, v6);
var v7 = C.name3;
var v8 = C.name3;
- var v9 = C.name3;
Expect.equals(v7, v8);
- Expect.equals(v7, v9);
- Expect.equals(v8, v9);
Expect.notEquals(v1, v4);
Expect.notEquals(v2, v7);
- Expect.notEquals(v5, v9);
+ Expect.notEquals(v5, v8);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t06.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t06.dart
index e458102..6fddfb0 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t06.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t06.dart
@@ -26,26 +26,17 @@
main() {
var v1 = C.name1;
var v2 = C.name1;
- var v3 = C.name1;
Expect.equals(v1, v2);
- Expect.equals(v1, v3);
- Expect.equals(v2, v3);
var v4 = C.name2;
var v5 = C.name2;
- var v6 = C.name2;
Expect.equals(v4, v5);
- Expect.equals(v4, v6);
- Expect.equals(v5, v6);
var v7 = C.new;
var v8 = C.new;
- var v9 = C.new;
Expect.equals(v7, v8);
- Expect.equals(v7, v9);
- Expect.equals(v8, v9);
Expect.notEquals(v1, v4);
Expect.notEquals(v2, v7);
- Expect.notEquals(v5, v9);
+ Expect.notEquals(v5, v8);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t07.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t07.dart
index be90b98..6bfe004 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t07.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t07.dart
@@ -26,26 +26,17 @@
main() {
var v1 = C.name1;
var v2 = C.name1;
- var v3 = C.name1;
Expect.equals(v1, v2);
- Expect.equals(v1, v3);
- Expect.equals(v2, v3);
var v4 = C.name2;
var v5 = C.name2;
- var v6 = C.name2;
Expect.equals(v4, v5);
- Expect.equals(v4, v6);
- Expect.equals(v5, v6);
var v7 = C.new;
var v8 = C.new;
- var v9 = C.new;
Expect.equals(v7, v8);
- Expect.equals(v7, v9);
- Expect.equals(v8, v9);
Expect.notEquals(v1, v4);
Expect.notEquals(v2, v7);
- Expect.notEquals(v5, v9);
+ Expect.notEquals(v5, v8);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t08.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t08.dart
new file mode 100644
index 0000000..7f49477
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t08.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of tear-offs of different constructors but with
+/// the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ int? i, j;
+ C.name1(this.i, this.j) {}
+ C.name2(this.i, this.j);
+ C(this.i, this.j) {}
+}
+
+main() {
+ var v1 = C.name1;
+ var v2 = C.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C.name2;
+ var v5 = C.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C.new;
+ var v8 = C.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t09.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t09.dart
new file mode 100644
index 0000000..1c07c91
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t09.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of tear-offs of different constructors but with
+/// the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ C.name1(int i, int j) {}
+ C.name2(int i, int j);
+ C( int i, int j) {}
+}
+
+main() {
+ var v1 = C.name1;
+ var v2 = C.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C.name2;
+ var v5 = C.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C.new;
+ var v8 = C.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t10.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t10.dart
new file mode 100644
index 0000000..8e012cc
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t10.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of tear-offs of different constructors but with
+/// the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ C.name1(int i, [int? j]) {}
+ C.name2(int i, [int? j]);
+ C( int i, [int? j]) {}
+}
+
+main() {
+ var v1 = C.name1;
+ var v2 = C.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C.name2;
+ var v5 = C.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C.new;
+ var v8 = C.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t11.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t11.dart
new file mode 100644
index 0000000..5d40380
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t11.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of tear-offs of different constructors but with
+/// the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ C.name1(int i, [int j = 42]) {}
+ C.name2(int i, [int j = 42]);
+ C( int i, [int j = 42]) {}
+}
+
+main() {
+ var v1 = C.name1;
+ var v2 = C.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C.name2;
+ var v5 = C.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C.new;
+ var v8 = C.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t12.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t12.dart
new file mode 100644
index 0000000..abe71a8
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t12.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of tear-offs of different constructors but with
+/// the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ C.name1(int i, {int j = 42}) {}
+ C.name2(int i, {int j = 42});
+ C( int i, {int j = 42}) {}
+}
+
+main() {
+ var v1 = C.name1;
+ var v2 = C.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C.name2;
+ var v5 = C.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C.new;
+ var v8 = C.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t13.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t13.dart
new file mode 100644
index 0000000..768ed58
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t13.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of tear-offs of different constructors but with
+/// the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ C.name1(int i, {required int j}) {}
+ C.name2(int i, {required int j});
+ C( int i, {required int j}) {}
+}
+
+main() {
+ var v1 = C.name1;
+ var v2 = C.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C.name2;
+ var v5 = C.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C.new;
+ var v8 = C.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t14.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t14.dart
new file mode 100644
index 0000000..083d7db
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t14.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of generic tear-offs of different constructors
+/// but with the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C<T> {
+ T i, j;
+ C.name1(this.i, this.j) {}
+ C.name2(this.i, this.j);
+ C(this.i, this.j) {}
+}
+
+main() {
+ var v1 = C.name1;
+ var v2 = C.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C.name2;
+ var v5 = C.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C.new;
+ var v8 = C.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t15.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t15.dart
new file mode 100644
index 0000000..9da9632
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A07_t15.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion The constant-ness, identity and equality of the torn-off
+/// constructor functions behave exactly the same as if they were tear-offs of
+/// the corresponding static function. This means that a non-generic class
+/// constructor always tears off to the same function value, as does an
+/// uninstantiated tear off of a generic class constructor.
+///
+/// @description Checks equality of generic tear-offs of different constructors
+/// but with the same signature
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C<T> {
+ T i, j;
+ C.name1(this.i, this.j) {}
+ C.name2(this.i, this.j);
+ C(this.i, this.j) {}
+}
+
+main() {
+ var v1 = C<int>.name1;
+ var v2 = C<int>.name1;
+ Expect.equals(v1, v2);
+
+ var v4 = C<int>.name2;
+ var v5 = C<int>.name2;
+ Expect.equals(v4, v5);
+
+ var v7 = C<int>.new;
+ var v8 = C<int>.new;
+ Expect.equals(v7, v8);
+
+ Expect.notEquals(v1, v4);
+ Expect.notEquals(v2, v7);
+ Expect.notEquals(v5, v8);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart
index b7a300e..bc5474d 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t01.dart
@@ -24,12 +24,12 @@
var v1 = MyClass.new;
var v2 = MyClass.constr;
- var c1 = v1();
- var c2 = v1();
+ const c1 = v1(3, 14);
+ const c2 = v1(3, 14);
Expect.identical(c1, c2);
- var c3 = v2();
- var c4 = v2();
+ const c3 = v2();
+ const c4 = v2();
Expect.identical(c3, c4);
Expect.notEquals(c1, c3);
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart
index 2ead742..5beec09 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A08_t02.dart
@@ -20,16 +20,24 @@
}
main() {
- var v1 = MyClass.new;
- var v2 = MyClass.constr;
+ var v1 = MyClass<String>.new;
+ var v2 = MyClass<int>.constr;
+ var v3 = MyClass<int>.new;
+ var v4 = MyClass<String>.constr;
- var c1 = v1();
- var c2 = v1();
+ const c1 = v1(3, 14);
+ const c2 = v1(3, 14);
Expect.identical(c1, c2);
- var c3 = v2();
- var c4 = v2();
+ const c3 = v2();
+ const c4 = v2();
Expect.identical(c3, c4);
Expect.notEquals(c1, c3);
+
+ const c5 = v3(3, 14);
+ Expect.notEquals(c1, c5);
+
+ const c6 = v4();
+ Expect.notEquals(c3, c6);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_t09_A01.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_t09_A01.dart
index c2d2d17..561e80d 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_t09_A01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_t09_A01.dart
@@ -21,7 +21,7 @@
C();
C.constr1(int i) {}
C.constr2(int i, String s, x) {}
- C.constr3({int i=1, required j}) {}
+ C.constr3({int i = 1, required j}) {}
C.constr4(this.i, this.j);
}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_t10_A01.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_t10_A01.dart
index 20b8dd0..485d32c 100644
--- a/LanguageFeatures/Constructor-tear-offs/named_constructor_t10_A01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_t10_A01.dart
@@ -62,5 +62,5 @@
main() {
testList();
- testA();
+ testC();
}