Merge remote-tracking branch 'origin/master'
diff --git a/LanguageFeatures/Spread-collections/Ambiguity_A02_t02.dart b/LanguageFeatures/Spread-collections/Ambiguity_A02_t02.dart
index 8f93122..8cc68f7 100644
--- a/LanguageFeatures/Spread-collections/Ambiguity_A02_t02.dart
+++ b/LanguageFeatures/Spread-collections/Ambiguity_A02_t02.dart
@@ -11,10 +11,15 @@
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+import "../../Utils/expect.dart";
+
+Set emptyset = {};
+Map emptymap = {};
+
main() {
Set res1 = {...?null};
- Map res2 = {...?null};
+ Expect.setEquals(emptyset, res1);
- var res3 = {...?null}; //# 01: compile-time error
- dynamic res4 = {...?null}; //# 02: compile-time error
+ Map res2 = {...?null};
+ Expect.mapEquals(emptymap, res2);
}
diff --git a/LanguageFeatures/Spread-collections/Ambiguity_A02_t03.dart b/LanguageFeatures/Spread-collections/Ambiguity_A02_t03.dart
index d663a5c..899ba31 100644
--- a/LanguageFeatures/Spread-collections/Ambiguity_A02_t03.dart
+++ b/LanguageFeatures/Spread-collections/Ambiguity_A02_t03.dart
@@ -6,18 +6,12 @@
/**
* @assertion In cases where the context type is not specific enough to
* disambiguate, we could make it an error instead of defaulting to map.
- * However, that would be inconsistent with how empty collections are handled.
- * Those have to default to map for backwards compatibility.
- * @description Checks that empty collection is a map.
+ * @description Checks that {...?null} collection type is detected correctly
+ * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-import "../../Utils/expect.dart";
-
main() {
- Expect.isTrue({} is Map);
-
- dynamic map = {};
- Expect.isTrue(map is Map);
+ var res = {...?null};
}
diff --git a/LanguageFeatures/Spread-collections/Ambiguity_A02_t04.dart b/LanguageFeatures/Spread-collections/Ambiguity_A02_t04.dart
new file mode 100644
index 0000000..7d6e619
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/Ambiguity_A02_t04.dart
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2019, 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 In cases where the context type is not specific enough to
+ * disambiguate, we could make it an error instead of defaulting to map.
+ * @description Checks that {...?null} collection type is detected correctly
+ * @compile-error
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+main() {
+ dynamic res = {...?null};
+}
diff --git a/LanguageFeatures/Spread-collections/Ambiguity_A02_t05.dart b/LanguageFeatures/Spread-collections/Ambiguity_A02_t05.dart
new file mode 100644
index 0000000..d663a5c
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/Ambiguity_A02_t05.dart
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019, 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 In cases where the context type is not specific enough to
+ * disambiguate, we could make it an error instead of defaulting to map.
+ * However, that would be inconsistent with how empty collections are handled.
+ * Those have to default to map for backwards compatibility.
+ * @description Checks that empty collection is a map.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+import "../../Utils/expect.dart";
+
+main() {
+ Expect.isTrue({} is Map);
+
+ dynamic map = {};
+ Expect.isTrue(map is Map);
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t01.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t01.dart
index cfacbc5..a043bbe 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t01.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t01.dart
@@ -15,32 +15,26 @@
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+import "../../Utils/expect.dart";
+
const l1 = [];
-List l2 = [];
-
-const s1 = {11};
-Set s2 = {};
-
-const m1 = {1: 1};
-Map m2 = {2: 2};
-
-const int i1 = 25;
-int i2 = 25;
-
-const n = null;
+const l2 = [1, 2, 3];
+const Set s1 = {};
+const s2 = {11};
main() {
const List res1 = const [...l1];
- const List res2 = const [...l2]; //# 01: compile-time error
+ Expect.listEquals(l1, res1);
+
+ const List res2 = const [...l2];
+ Expect.listEquals(l2, res2);
const List res3 = const [...s1];
- const List res4 = const [...s2]; //# 02: compile-time error
+ Expect.listEquals([], res3);
- const List res5 = const [...m1]; //# 03: compile-time error
- const List res6 = const [...m2]; //# 04: compile-time error
+ const List res4 = const [...l2];
+ Expect.listEquals(l2, res4);
- const List res7 = const [...i1]; //# 05: compile-time error
- const List res8 = const [...i2]; //# 06: compile-time error
-
- const List res9 = const [...n]; //# 07: compile-time error
+ const List res5 = [...l1, ...l2, ...s1, ...s2];
+ Expect.listEquals([1, 2, 3, 11], res5);
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t02.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t02.dart
index 2ad65da..edcecfb 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t02.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t02.dart
@@ -9,34 +9,30 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant list spread element can be potentially
- * constant list or set.
+ * @description: Checks that constant list spread element cannot be
+ * non-constant, cannot be [null] and cannot be of the type which is not [List]
+ * or [Set]
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-class A {
- const A();
-}
+List l = [];
+Set s = {};
-class B extends A {
- const B();
-}
+const m1 = {1: 1};
+Map m2 = {2: 2};
-class MyClass {
- final String a;
- const MyClass(Object o) : a = o as String;
-}
+const int i1 = 25;
+int i2 = 25;
+const n = null;
main() {
- const List l1 = [...(A() is B ? [12345] : [])];
- const List l2 = [...(A() is A ? [12345] : [0])];
- const List l3 = [...(MyClass("test") is MyClass ? [12345] : [])];
- const List l4 = [...(MyClass(12345) is MyClass ? [12] : [])]; //# 01: compile-time error
-
- const List l5 = [...(A() is B ? {12345} : {1})];
- const List l6 = [...(A() is A ? {12345} : {0})];
- const List l7 = [...(MyClass("test") is MyClass ? {12345} : {1})];
- const List l8 = [...(MyClass(12345) is MyClass ? {12} : {2})]; //# 02: compile-time error
+ const List res1 = const [...l]; //# 01: compile-time error
+ const List res2 = const [...s]; //# 02: compile-time error
+ const List res3 = const [...m1]; //# 03: compile-time error
+ const List res4 = const [...m2]; //# 04: compile-time error
+ const List res5 = const [...i1]; //# 05: compile-time error
+ const List res6 = const [...i2]; //# 06: compile-time error
+ const List res7 = const [...n]; //# 07: compile-time error
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t03.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t03.dart
index d57583e..cc888c4 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t03.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t03.dart
@@ -9,17 +9,44 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant list spread element can be constant list
- * or set.
+ * @description: Checks that constant list spread element can be potentially
+ * constant list or set.
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-main() {
- const List res1 = const [...[1, 2, 3], 4];
- const List res2 = const [5, ...{2, 11}];
+import "../../Utils/expect.dart";
- const List res3 = const [...{1: 2, 3: 4}]; //# 01: compile-time error
- const List res4 = const [...44]; //# 02: compile-time error
- const List res5 = const [...null]; //# 03: compile-time error
+class A {
+ const A();
+}
+
+class B extends A {
+ const B();
+}
+
+class MyClass {
+ final String a;
+ const MyClass(Object o) : a = o as String;
+}
+
+
+main() {
+ const List l1 = [...(A() is B ? [12345] : [])];
+ Expect.listEquals([], l1);
+
+ const List l2 = [...(A() is A ? [12345] : [0])];
+ Expect.listEquals([12345], l2);
+
+ const List l3 = [...(MyClass("test") is MyClass ? [12345] : [])];
+ Expect.listEquals([12345], l3);
+
+ const List l4 = [...(A() is B ? {12345} : {1})];
+ Expect.listEquals([1], l4);
+
+ const List l5 = [...(A() is A ? {12345} : {0})];
+ Expect.listEquals([12345], l5);
+
+ const List l6 = [...(MyClass("test") is MyClass ? {12345} : {1})];
+ Expect.listEquals([12345], l6);
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t04.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t04.dart
index c0361cd..ada84c0 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t04.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t04.dart
@@ -9,38 +9,18 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant set spread element can be constant list or
- * set.
+ * @description: Checks that compile error is thrown if constant list spread
+ * element is not potentially constant list or set.
+ * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-const l1 = [];
-List l2 = [];
-
-const s1 = {11};
-Set s2 = {};
-
-const m1 = {1: 1};
-Map m2 = {2: 2};
-
-const int i1 = 25;
-int i2 = 25;
-
-const n = null;
+class MyClass {
+ final String a;
+ const MyClass(Object o) : a = o as String;
+}
main() {
- const Set res1 = const {...l1};
- const Set res2 = const {...l2}; //# 01: compile-time error
-
- const Set res3 = const {...s1};
- const Set res4 = const {...s2}; //# 02: compile-time error
-
- const Set res5 = const {...m1}; //# 03: compile-time error
- const Set res6 = const {...m2}; //# 04: compile-time error
-
- const Set res7 = const {...i1}; //# 05: compile-time error
- const Set res8 = const {...i2}; //# 06: compile-time error
-
- const Set res9 = const {...n}; //# 07: compile-time error
+ const List aList = [...(MyClass(12345) is MyClass ? [12] : [])];
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t05.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t05.dart
index 8d9055a..f758058 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t05.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t05.dart
@@ -9,8 +9,9 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant set spread element can be potentially
- * constant list or set.
+ * @description: Checks that compile error is thrown if constant list spread
+ * element is not potentially constant list or set.
+ * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
@@ -19,24 +20,6 @@
const A();
}
-class B extends A {
- const B();
-}
-
-class MyClass {
- final String a;
- const MyClass(Object o) : a = o as String;
-}
-
-
main() {
- const Set l1 = {...(A() is B ? [12345] : [])};
- const Set l2 = {...(A() is A ? [12345] : [0])};
- const Set l3 = {...(MyClass("test") is MyClass ? [12345] : [])};
- const Set l4 = {...(MyClass(12345) is MyClass ? [12] : [])}; //# 01: compile-time error
-
- const Set l5 = {...(A() is B ? [12345] : {12, 34})};
- const Set l6 = {...(A() is A ? [12345] : {0})};
- const Set l7 = {...(MyClass("test") is MyClass ? {12345} : {14})};
- const Set l8 = {...(MyClass(12345) is MyClass ? {12} : <int>{})}; //# 02: compile-time error
+ const List aList = [...(A() is A ? 123 : [])];
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t06.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t06.dart
index 7801283..c60480a 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t06.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t06.dart
@@ -9,18 +9,18 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant set spread element can be constant list
+ * @description: Checks that constant list spread element can be constant list
* or set.
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-main() {
- const Set res1 = const {...[1, 2, 3], 4};
- const Set res2 = const {5, ...{2, 11}};
+import "../../Utils/expect.dart";
- const Set res3 = const {...{1: 2, 3: 4}}; //# 01: compile-time error
- const Set res4 = const {...44}; //# 02: compile-time error
- const Set res5 = const {...{}};
- const Set res6 = const {...null}; //# 03: compile-time error
+main() {
+ const List res1 = const [...[1, 2, 3], 4];
+ Expect.listEquals([1, 2, 3, 4], res1);
+
+ const List res2 = const [5, ...{2, 11}];
+ Expect.listEquals([5, 2, 11], res2);
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t07.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t07.dart
index d3822ec..9a8711a 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t07.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t07.dart
@@ -9,37 +9,14 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant map spread element can be constant map
+ * @description: Checks that constant list spread element cannot be [Map], [int]
+ * or [null].
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-const l1 = [];
-List l2 = [];
-
-const s1 = {11};
-Set s2 = {};
-
-const m1 = {1: 1};
-Map m2 = {2: 2};
-
-const int i1 = 25;
-int i2 = 25;
-
-const n = null;
-
main() {
- const Map res1 = const {...l1}; //# 01: compile-time error
- const Map res2 = const {...l2}; //# 02: compile-time error
-
- const Map res3 = const {...s1}; //# 03: compile-time error
- const Map res4 = const {...s2}; //# 04: compile-time error
-
- const Map res5 = const {...m1};
- const Map res6 = const {...m2}; //# 05: compile-time error
-
- const Map res7 = const {...i1}; //# 06: compile-time error
- const Map res8 = const {...i2}; //# 07: compile-time error
-
- const Map res9 = const {...n}; //# 08: compile-time error
+ const List res1 = const [...{1: 2, 3: 4}]; //# 01: compile-time error
+ const List res2 = const [...44]; //# 02: compile-time error
+ const List res3 = const [...null]; //# 03: compile-time error
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t08.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t08.dart
index af8a0b3..23988b0 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t08.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t08.dart
@@ -9,29 +9,33 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant map spread element can be potentially
- * constant map.
+ * @description: Checks that constant set spread element can be constant list or
+ * set.
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-class A {
- const A();
-}
+import "../../Utils/expect.dart";
-class B extends A {
- const B();
-}
+const l1 = [];
+const l2 = [1, 2, 3];
-class MyClass {
- final String a;
- const MyClass(Object o) : a = o as String;
-}
-
+const Set s1 = {};
+const s2 = {4, 5, 6};
main() {
- const Map m1 = {...(A() is B ? {1: 12345} : <Object, Object>{})};
- const Map m2 = {...(A() is A ? {12345: 4} : {0: 1})};
- const Map m3 = {...(MyClass("test") is MyClass ? {"a": "b"} : <int, int>{})};
- const Map m4 = {...(MyClass(12345) is MyClass ? {1: 1} : {2: 2})}; //# 01: compile-time error
+ const Set res1 = const {...l1};
+ Expect.setEquals(s1, res1);
+
+ const Set res2 = const {...l2};
+ Expect.setEquals({1, 2, 3}, res2);
+
+ const Set res3 = const {...s1};
+ Expect.setEquals(s1, res3);
+
+ const Set res4 = const {...s2};
+ Expect.setEquals(s2, res4);
+
+ const Set res5 = const {...l1, ...l2, ...s1, ...s2};
+ Expect.setEquals({1, 2, 3, 4, 5, 6}, res5);
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t09.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t09.dart
index 1c929d9..97c8d9c 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t09.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t09.dart
@@ -9,19 +9,29 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks that constant map spread element can be constant map.
+ * @description: Checks that constant set spread element cannot be non-constant,
+ * cannot be [null] and cannot be of the type which is not [List] or [Set]
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-main() {
- const Map res1 = const {...{1: 1, 2: 2}, 4: 3};
- const Map res2 = const {...<Object, Object>{}};
+List l = [];
+Set s = {11};
- const Map res3 = const {...{1, 3}}; //# 01: compile-time error
- const Map res4 = const {...[]}; //# 02: compile-time error
- const Map res5 = const {...44}; //# 03: compile-time error
- const Map res6 = const {...{}}; //# 04: compile-time error
- const Map res7 = const {...<int>{}}; //# 05: compile-time error
- const Map res8 = const {...null}; //# 06: compile-time error
+const m1 = {1: 1};
+Map m2 = {2: 2};
+
+const int i1 = 25;
+int i2 = 25;
+
+const n = null;
+
+main() {
+ const Set res1 = const {...l}; //# 01: compile-time error
+ const Set res2 = const {...s}; //# 02: compile-time error
+ const Set res3 = const {...m1}; //# 03: compile-time error
+ const Set res4 = const {...m2}; //# 04: compile-time error
+ const Set res5 = const {...i1}; //# 05: compile-time error
+ const Set res6 = const {...i2}; //# 06: compile-time error
+ const Set res7 = const {...n}; //# 07: compile-time error
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t10.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t10.dart
index 45e583a..f82261c 100644
--- a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t10.dart
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t10.dart
@@ -9,44 +9,46 @@
* is constant and it evaluates to a constant List, Set or Map instance
* originally created by a list, set or map literal. It is a potentially
* constant element if the expression is a potentially constant expression.
- * @description: Checks some disambiguilty cases for sets and maps.
+ * @description: Checks that constant set spread element can be potentially
+ * constant list or set.
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
-const l1 = [];
-List l2 = [];
+import "../../Utils/expect.dart";
-const s1 = {11};
-Set s2 = {};
+Set emptyset = {};
-const m1 = {1: 1};
-Map m2 = {2: 2};
+class A {
+ const A();
+}
-const int i1 = 25;
-int i2 = 25;
+class B extends A {
+ const B();
+}
-const n = null;
+class MyClass {
+ final String a;
+ const MyClass(Object o) : a = o as String;
+}
+
main() {
- const res1 = {...l1};
- const res2 = {1, ...l1, 2};
- const res3 = {...l2}; //# 01: compile-time error
+ const Set s1 = {...(A() is B ? [12345] : [])};
+ Expect.setEquals(emptyset, s1);
- const res4 = {...s1};
- const res5 = {1, ...s1, 2};
- const res6 = {...s2}; //# 02: compile-time error
+ const Set s2 = {...(A() is A ? [12345] : [0])};
+ Expect.setEquals({12345}, s2);
- const res7 = {...l1, 123: 2}; //# 03: compile-time error
- const res8 = {14: 3, ...s1}; //# 04: compile-time error
+ const Set s3 = {...(MyClass("test") is MyClass ? [12345] : [])};
+ Expect.setEquals({12345}, s3);
- const res9 = {...m1};
- const res10 = {7: 1, ...m1, 3: 14};
- const res11 = {...m1, 13}; //# 05: compile-time error
- const res12 = {...m2}; //# 06: compile-time error
+ const Set s4 = {...(A() is B ? [12345] : {12, 34})};
+ Expect.setEquals({12, 34}, s4);
- const res13 = {...i1}; //# 07: compile-time error
- const res14 = {...i2}; //# 08: compile-time error
- const res15 = {...n}; //# 09: compile-time error
- const res16 = {...null}; //# 10: compile-time error
+ const Set s5 = {...(A() is A ? [12345] : {0})};
+ Expect.setEquals({12345}, s5);
+
+ const Set s6 = {...(MyClass("test") is MyClass ? {12345} : {14})};
+ Expect.setEquals({12345}, s6);
}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t11.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t11.dart
new file mode 100644
index 0000000..25354bf
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t11.dart
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that compile time error is thrown if constant set spread
+ * element is not a potentially constant list or set.
+ * @compile-error
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+class A {
+ const A();
+}
+
+class B extends A {
+ const B();
+}
+
+class MyClass {
+ final String a;
+ const MyClass(Object o) : a = o as String;
+}
+
+
+main() {
+ const Set l4 = {...(MyClass(12345) is MyClass ? [12] : [])};
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t12.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t12.dart
new file mode 100644
index 0000000..792edc6
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t12.dart
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that compile time error is thrown if constant set spread
+ * element is not a potentially constant list or set.
+ * @compile-error
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+class A {
+ const A();
+}
+
+main() {
+ const Set aSet = {...(A() is A ? 123 : [])};
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t13.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t13.dart
new file mode 100644
index 0000000..a5ad40b
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t13.dart
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant set spread element can be constant list
+ * or set.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+import "../../Utils/expect.dart";
+
+Set emptyset = {};
+
+main() {
+ const Set res1 = const {...[1, 2, 3], 4};
+ Expect.setEquals({1, 2, 3, 4}, res1);
+
+ const Set res2 = const {5, ...{2, 11}};
+ Expect.setEquals({5, 2, 11}, res2);
+
+ const Set res3 = const {...{}};
+ Expect.setEquals(emptyset, res3);
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t14.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t14.dart
new file mode 100644
index 0000000..952db5a
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t14.dart
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant set spread element cannot be [Map], [int]
+ * or [null].
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+main() {
+ const Set res1 = const {...{1: 2, 3: 4}}; //# 01: compile-time error
+ const Set res2 = const {...44}; //# 02: compile-time error
+ const Set res3 = const {...null}; //# 03: compile-time error
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t15.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t15.dart
new file mode 100644
index 0000000..e15fbc6
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t15.dart
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant map spread element can be constant map
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+import "../../Utils/expect.dart";
+
+const Map m1 = {1: 1};
+const Map m2 = {2: 14, 3: 29};
+const Map m3 = {};
+
+
+main() {
+ const Map res1 = const {...m1};
+ Expect.mapEquals(m1, res1);
+
+ const Map res2 = const {...m2};
+ Expect.mapEquals(m2, res2);
+
+ const Map res3 = const {...m3};
+ Expect.mapEquals(m3, res3);
+
+ const Map res4 = const {...m1, ...m2, ...m3};
+ Expect.mapEquals({1: 1, 2: 14, 3: 29}, res4);
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t16.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t16.dart
new file mode 100644
index 0000000..45fac70
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t16.dart
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant map spread element cannot be non-constant,
+ * cannot be [null] and cannot be [List], [Set] or [int].
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+const l1 = [];
+List l2 = [];
+
+const s1 = {11};
+Set s2 = {};
+
+Map m = {2: 2};
+
+const int i1 = 25;
+int i2 = 25;
+
+const n = null;
+
+main() {
+ const Map res1 = const {...l1}; //# 01: compile-time error
+ const Map res2 = const {...l2}; //# 02: compile-time error
+ const Map res3 = const {...s1}; //# 03: compile-time error
+ const Map res4 = const {...s2}; //# 04: compile-time error
+ const Map res5 = const {...m}; //# 05: compile-time error
+ const Map res6 = const {...i1}; //# 06: compile-time error
+ const Map res7 = const {...i2}; //# 07: compile-time error
+ const Map res8 = const {...n}; //# 08: compile-time error
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t17.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t17.dart
new file mode 100644
index 0000000..0e96a49
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t17.dart
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant map spread element can be potentially
+ * constant map.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+import "../../Utils/expect.dart";
+
+class A {
+ const A();
+}
+
+class B extends A {
+ const B();
+}
+
+class MyClass {
+ final String a;
+ const MyClass(Object o) : a = o as String;
+}
+
+main() {
+ const Map m1 = {...(A() is B ? {1: 12345} : <Object, Object>{})};
+ Expect.mapEquals(<Object, Object>{}, m1);
+
+ const Map m2 = {...(A() is A ? {12345: 4} : {0: 1})};
+ Expect.mapEquals({12345: 4}, m2);
+
+ const Map m3 = {...(MyClass("test") is MyClass ? {"a": "b"} : <int, int>{})};
+ Expect.mapEquals({"a": "b"}, m3);
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t18.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t18.dart
new file mode 100644
index 0000000..8c6adad
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t18.dart
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant map spread element can be potentially
+ * constant map.
+ * @compile-error
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+class MyClass {
+ final String a;
+ const MyClass(Object o) : a = o as String;
+}
+
+main() {
+ const Map m = {...(MyClass(12345) is MyClass ? {1: 1} : {2: 2})};
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t19.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t19.dart
new file mode 100644
index 0000000..f084eb5
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t19.dart
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant map spread element can be potentially
+ * constant map.
+ * @compile-error
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+class MyClass {
+ const MyClass();
+}
+
+main() {
+ const Map m = {...(MyClass() is MyClass ? 12345 : {2: 2})};
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t20.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t20.dart
new file mode 100644
index 0000000..713e436
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t20.dart
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant map spread element can be constant map.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+import "../../Utils/expect.dart";
+
+main() {
+ const Map res1 = const {...{1: 1, 2: 2}, 4: 3};
+ Expect.mapEquals({1:1, 2: 2, 4: 3}, res1);
+
+ const Map res2 = const {...<Object, Object>{}};
+ Expect.mapEquals(<Object, Object>{}, res2);
+
+ const Map res3 = const {...{}};
+ Expect.mapEquals({}, res3);
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t21.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t21.dart
new file mode 100644
index 0000000..a257fc0
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t21.dart
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks that constant map spread element can be [List], [Set],
+ * [int] or [null].
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+main() {
+ const Map res1 = const {...{1, 3}}; //# 01: compile-time error
+ const Map res2 = const {...[]}; //# 02: compile-time error
+ const Map res3 = const {...44}; //# 03: compile-time error
+ const Map res4 = const {...<int>{}}; //# 04: compile-time error
+ const Map res5 = const {...null}; //# 05: compile-time error
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t22.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t22.dart
new file mode 100644
index 0000000..3247c2f
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t22.dart
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks some disambiguilty cases for sets and maps.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+import "../../Utils/expect.dart";
+
+const l1 = [];
+const s1 = {11};
+const m1 = {1: 1};
+const int i1 = 25;
+const n = null;
+
+Set emptyset = {};
+
+main() {
+ const res1 = {...l1};
+ Expect.setEquals(emptyset, res1);
+
+ const res2 = {1, ...l1, 2};
+ Expect.setEquals({1, 2}, res2);
+
+ const res3 = {...s1};
+ Expect.setEquals({11}, res3);
+
+ const res4 = {1, ...s1, 2};
+ Expect.setEquals({1, 11, 2}, res4);
+
+ const res5 = {...m1};
+ Expect.mapEquals(m1, res5);
+
+ const res6 = {7: 1, ...m1, 3: 14};
+ Expect.mapEquals({7: 1, 1: 1, 3: 14}, res6);
+}
diff --git a/LanguageFeatures/Spread-collections/ConstSpreads_A09_t23.dart b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t23.dart
new file mode 100644
index 0000000..2bf9baa
--- /dev/null
+++ b/LanguageFeatures/Spread-collections/ConstSpreads_A09_t23.dart
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019, 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 From the Unified collection Spec:
+ * A spreadElement starting with [...] is a constant element if its expression
+ * is constant and it evaluates to a constant List, Set or Map instance
+ * originally created by a list, set or map literal. It is a potentially
+ * constant element if the expression is a potentially constant expression.
+ * @description: Checks some disambiguilty cases for sets and maps.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=spread-collections,constant-update-2018
+
+const l1 = [];
+List l2 = [];
+
+const s1 = {11};
+Set s2 = {};
+
+const m1 = {1: 1};
+Map m2 = {2: 2};
+
+const int i1 = 25;
+int i2 = 25;
+
+const n = null;
+
+main() {
+ const res1 = {...l2}; //# 01: compile-time error
+ const res2 = {...s2}; //# 02: compile-time error
+ const res3 = {...l1, 123: 2}; //# 03: compile-time error
+ const res4 = {14: 3, ...s1}; //# 04: compile-time error
+ const res5 = {...m1, 13}; //# 05: compile-time error
+ const res6 = {...m2}; //# 06: compile-time error
+ const res7 = {...i1}; //# 07: compile-time error
+ const res8 = {...i2}; //# 08: compile-time error
+ const res9 = {...n}; //# 09: compile-time error
+ const res10 = {...null}; //# 10: compile-time error
+}