Reformat tests/language/s** using 3.8 style.
Change-Id: I3c5cfbc1bc5e41d2ef1598427067dea00f9f42b4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425403 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
committed by
Commit Queue
parent
200e0c83bd
commit
c9d54c12f6
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
|
||||
part "script1_part.dart";
|
||||
import "script1_lib.dart";
|
||||
// [error line 8, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE
|
||||
// [cfe] Import directives must precede part directives.
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ abstract class OutsideA with SealedClass {}
|
||||
// [cfe] The class 'SealedClass' can't be used as a mixin because it isn't a mixin class nor a mixin.
|
||||
|
||||
class OutsideB with SealedClass {
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CLASS_USED_AS_MIXIN
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
// [cfe] The class 'SealedClass' can't be used as a mixin because it isn't a mixin class nor a mixin.
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CLASS_USED_AS_MIXIN
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
// [cfe] The class 'SealedClass' can't be used as a mixin because it isn't a mixin class nor a mixin.
|
||||
int foo = 2;
|
||||
int bar(int value) => value;
|
||||
}
|
||||
@@ -46,3 +46,4 @@ abstract class OutsideE with Mixin, SealedClass {}
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
// [cfe] The class 'SealedClass' can't be used as a mixin because it isn't a mixin class nor a mixin.
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ abstract class OutsideA extends SealedClass {}
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
|
||||
class OutsideB extends SealedClass {
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
int foo = 2;
|
||||
int bar(int value) => value;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ abstract class OutsideA implements SealedClass {}
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
|
||||
class OutsideB implements SealedClass {
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
int nonAbstractFoo = 2;
|
||||
int foo = 2;
|
||||
int nonAbstractBar(int value) => value;
|
||||
@@ -30,3 +30,4 @@ enum EnumOutside implements ClassForEnum { x }
|
||||
// ^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'ClassForEnum' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ class ATypeDef extends SealedClassTypeDef {}
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
|
||||
class BTypeDef implements SealedClassTypeDef {
|
||||
// ^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
// ^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ class A extends ATypeDef {}
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
|
||||
class B implements ATypeDef {
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
|
||||
// [cfe] The class 'SealedClass' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
|
||||
int foo = 1;
|
||||
}
|
||||
|
||||
@@ -70,18 +70,25 @@ void test() {
|
||||
checkSet<Symbol>(const {#foo, #bar}, [#foo, #bar]);
|
||||
checkSet<Symbol>(const {#_foo, #_bar}, [#_foo, #_bar]);
|
||||
const object = Object();
|
||||
checkSet<Object>(const {#foo, 1, "string", object, true},
|
||||
[#foo, 1, "string", object, true]);
|
||||
checkSet<Object>(
|
||||
const {#foo, 1, "string", object, true},
|
||||
[#foo, 1, "string", object, true],
|
||||
);
|
||||
|
||||
// Nested constant literals.
|
||||
const Object o = {{2}};
|
||||
const Object o = {
|
||||
{2},
|
||||
};
|
||||
Expect.type<Set<Set<int>>>(o);
|
||||
Set<Set<int>> set = o as Set<Set<int>>;
|
||||
Expect.equals(1, set.length);
|
||||
Expect.equals(1, set.first.length);
|
||||
Expect.equals(2, set.first.first);
|
||||
|
||||
const Object o2 = {{2}, <int>{}};
|
||||
const Object o2 = {
|
||||
{2},
|
||||
<int>{},
|
||||
};
|
||||
Expect.type<Set<Set<int>>>(o);
|
||||
set = o2 as Set<Set<int>>;
|
||||
Expect.equals(2, set.length);
|
||||
@@ -97,7 +104,10 @@ void test() {
|
||||
Expect.equals(1, o4.length);
|
||||
Expect.equals(0, o4.first.length);
|
||||
|
||||
const o5 = {{1}, {}}; // Set<Object>
|
||||
const o5 = {
|
||||
{1},
|
||||
{},
|
||||
}; // Set<Object>
|
||||
Expect.type<Set<Object>>(o5);
|
||||
Expect.notType<Set<Set<Object>>>(o5);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class A<@Meta({}) T> {
|
||||
@Meta({})
|
||||
enum E {
|
||||
@Meta({})
|
||||
v
|
||||
v,
|
||||
}
|
||||
|
||||
class Meta {
|
||||
|
||||
@@ -79,12 +79,17 @@ void test() {
|
||||
entries.add(entry);
|
||||
return value;
|
||||
}
|
||||
|
||||
checkSet<Equality>(
|
||||
{log(e1a, 1), log(e2b, 2), log(e1b, 3), log(e2a, 4)}, [e1a, e2b]);
|
||||
{log(e1a, 1), log(e2b, 2), log(e1b, 3), log(e2a, 4)},
|
||||
[e1a, e2b],
|
||||
);
|
||||
Expect.listEquals([1, 2, 3, 4], entries);
|
||||
|
||||
// Nested literals.
|
||||
Object o = {{2}};
|
||||
Object o = {
|
||||
{2},
|
||||
};
|
||||
Expect.type<LinkedHashSet<Set<int>>>(o);
|
||||
Expect.type<LinkedHashSet<int>>((o as Set).first);
|
||||
Set<Set<int>> set = o as Set<Set<int>>;
|
||||
@@ -92,7 +97,10 @@ void test() {
|
||||
Expect.equals(1, set.first.length);
|
||||
Expect.equals(2, set.first.first);
|
||||
|
||||
o = {{2}, <int>{}};
|
||||
o = {
|
||||
{2},
|
||||
<int>{},
|
||||
};
|
||||
Expect.type<LinkedHashSet<Set<int>>>(o);
|
||||
Expect.type<LinkedHashSet<int>>((o as Set).first);
|
||||
set = o as Set<Set<int>>;
|
||||
@@ -105,17 +113,26 @@ void test() {
|
||||
Expect.equals(1, set2.length);
|
||||
Expect.equals(0, set2.first.length);
|
||||
|
||||
var set3 = {{1}, {}}; // Set<Object>
|
||||
var set3 = {
|
||||
{1},
|
||||
{},
|
||||
}; // Set<Object>
|
||||
Expect.type<Set<Object>>(set3);
|
||||
Expect.notType<Set<Set<Object>>>(set3);
|
||||
|
||||
// Trailing comma.
|
||||
Iterable<Object> i;
|
||||
// Don't let the formatter remove the trailing commas.
|
||||
// dart format off
|
||||
i = {1,};
|
||||
// dart format on
|
||||
Expect.type<Set<Object>>(i);
|
||||
Expect.equals(1, i.length);
|
||||
|
||||
// Don't let the formatter remove the trailing commas.
|
||||
// dart format off
|
||||
Object o2 = {1, 2, 3,};
|
||||
// dart format on
|
||||
Expect.type<Set<int>>(o2);
|
||||
Set<Object> set4 = o2 as Set<Object>;
|
||||
Expect.equals(3, set4.length);
|
||||
@@ -126,6 +143,6 @@ class Equality {
|
||||
final String name;
|
||||
const Equality(this.id, this.name);
|
||||
int get hashCode => id;
|
||||
bool operator==(Object other) => other is Equality && id == other.id;
|
||||
bool operator ==(Object other) => other is Equality && id == other.id;
|
||||
String toString() => "$id:$name";
|
||||
}
|
||||
|
||||
@@ -18,18 +18,18 @@ set tooMany(var value, var extra) {}
|
||||
// ^
|
||||
// [cfe] A setter should have exactly one formal parameter.
|
||||
|
||||
/*space*/ int? set wrongReturnType1(_) => 1;
|
||||
// ^^^^
|
||||
int? set wrongReturnType1(_) => 1;
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
|
||||
/*space*/ FutureOr<void> set wrongReturnType2(_) {}
|
||||
// ^^^^^^^^^^^^^^
|
||||
FutureOr<void> set wrongReturnType2(_) {}
|
||||
// [error column 1, length 14]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
|
||||
/*space*/ Never set wrongReturnType3(_) => throw 1;
|
||||
// ^^^^^
|
||||
Never set wrongReturnType3(_) => throw 1;
|
||||
// [error column 1, length 5]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
|
||||
@@ -73,18 +73,18 @@ class C {
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
|
||||
/*space*/ int? set wrongReturnType1(_) => 1;
|
||||
// ^^^^
|
||||
int? set wrongReturnType1(_) => 1;
|
||||
// [error column 3, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
|
||||
/*space*/ FutureOr<void> set wrongReturnType2(_) {}
|
||||
// ^^^^^^^^^^^^^^
|
||||
FutureOr<void> set wrongReturnType2(_) {}
|
||||
// [error column 3, length 14]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
|
||||
/*space*/ Never set wrongReturnType3(_) => throw 1;
|
||||
// ^^^^^
|
||||
Never set wrongReturnType3(_) => throw 1;
|
||||
// [error column 3, length 5]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import "package:expect/expect.dart";
|
||||
|
||||
var topLevelClosure;
|
||||
|
||||
|
||||
get topLevel => topLevelClosure;
|
||||
|
||||
set topLevel(var value) {}
|
||||
|
||||
@@ -10,8 +10,8 @@ class Example {
|
||||
|
||||
main() {
|
||||
print(topLevel++);
|
||||
// ^
|
||||
// [analyzer] unspecified
|
||||
// ^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
|
||||
// [cfe] Getter not found: 'topLevel'.
|
||||
|
||||
Example ex = new Example();
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
class A {
|
||||
set foo(x) {}
|
||||
void set bar(x) {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -10,13 +10,13 @@ class A {
|
||||
set foo(x) {}
|
||||
void set bar(x) {}
|
||||
dynamic set baz(x) {}
|
||||
//^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
// [error column 3, length 7]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
bool set bob(x) {}
|
||||
//^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
// [error column 3, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.NON_VOID_RETURN_FOR_SETTER
|
||||
// [cfe] The return type of the setter must be 'void' or absent.
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -27,8 +27,13 @@ Future<void> testList() async {
|
||||
Expect.listEquals(list, [...await future12, 3, ...await future45]);
|
||||
|
||||
// Await in null-aware spread.
|
||||
Expect.listEquals(
|
||||
list, [...?await nullableFuture12, 3, ...?await futureNull, 4, 5]);
|
||||
Expect.listEquals(list, [
|
||||
...?await nullableFuture12,
|
||||
3,
|
||||
...?await futureNull,
|
||||
4,
|
||||
5,
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> testMap() async {
|
||||
@@ -41,8 +46,13 @@ Future<void> testMap() async {
|
||||
Expect.mapEquals(map, {...await future12, 3: 3, ...await future45});
|
||||
|
||||
// Await in null-aware spread.
|
||||
Expect.mapEquals(map,
|
||||
{...?await nullableFuture12, 3: 3, ...?await futureNull, 4: 4, 5: 5});
|
||||
Expect.mapEquals(map, {
|
||||
...?await nullableFuture12,
|
||||
3: 3,
|
||||
...?await futureNull,
|
||||
4: 4,
|
||||
5: 5,
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> testSet() async {
|
||||
@@ -55,6 +65,11 @@ Future<void> testSet() async {
|
||||
Expect.setEquals(set, {...await future12, 3, ...await future45});
|
||||
|
||||
// Await in null-aware spread.
|
||||
Expect.setEquals(
|
||||
set, {...?await nullableFuture12, 3, ...?await futureNull, 4, 5});
|
||||
Expect.setEquals(set, {
|
||||
...?await nullableFuture12,
|
||||
3,
|
||||
...?await futureNull,
|
||||
4,
|
||||
5,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,40 +22,82 @@ void testList() {
|
||||
Expect.identical(list, const <int>[...set]);
|
||||
|
||||
// Spread at beginning.
|
||||
Expect.identical(list, const <int>[...<int>[1, 2], 3, 4]);
|
||||
Expect.identical(list, const <int>[
|
||||
...<int>[1, 2],
|
||||
3,
|
||||
4,
|
||||
]);
|
||||
|
||||
// Spread in middle.
|
||||
Expect.identical(list, const <int>[1, ...<int>[2, 3], 4]);
|
||||
Expect.identical(list, const <int>[
|
||||
1,
|
||||
...<int>[2, 3],
|
||||
4,
|
||||
]);
|
||||
|
||||
// Spread at end.
|
||||
Expect.identical(list, const <int>[1, 2, ...<int>[3, 4]]);
|
||||
Expect.identical(list, const <int>[
|
||||
1,
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
]);
|
||||
|
||||
// Empty spreads.
|
||||
Expect.identical(list,
|
||||
const <int>[...<int>[], 1, 2, ...<int>[], 3, 4, ...<int>[]]);
|
||||
Expect.identical(list, const <int>[
|
||||
...<int>[],
|
||||
1,
|
||||
2,
|
||||
...<int>[],
|
||||
3,
|
||||
4,
|
||||
...<int>[],
|
||||
]);
|
||||
|
||||
// Multiple spreads.
|
||||
Expect.identical(list,
|
||||
const <int>[...<int>[1], 2, ...<int>[3, 4]]);
|
||||
Expect.identical(list, const <int>[
|
||||
...<int>[1],
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
]);
|
||||
|
||||
// Nested spreads.
|
||||
Expect.identical(list,
|
||||
const <int>[...<int>[...<int>[1, 2], ...<int>[3, 4]]]);
|
||||
Expect.identical(list, const <int>[
|
||||
...<int>[
|
||||
...<int>[1, 2],
|
||||
...<int>[3, 4],
|
||||
],
|
||||
]);
|
||||
|
||||
// Null-aware.
|
||||
const list23 = <int>[2, 3] as List<int>?;
|
||||
const list4 = <int>[4] as List<int>?;
|
||||
Expect.identical(list,
|
||||
const <int>[1, ...?list23, ...?(null), ...?list4]);
|
||||
Expect.identical(list, const <int>[1, ...?list23, ...?(null), ...?list4]);
|
||||
|
||||
// Does not deep flatten.
|
||||
Expect.identical(
|
||||
const <Object>[1, 2, <int>[3], 4],
|
||||
const <Object>[1, ...<Object>[2, <int>[3], 4]]);
|
||||
const <Object>[
|
||||
1,
|
||||
2,
|
||||
<int>[3],
|
||||
4,
|
||||
],
|
||||
const <Object>[
|
||||
1,
|
||||
...<Object>[
|
||||
2,
|
||||
<int>[3],
|
||||
4,
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
// Establishes const context.
|
||||
Expect.identical(const <Symbol>[Symbol("sym")],
|
||||
const <Symbol>[...<Symbol>[Symbol("sym")]]);
|
||||
Expect.identical(
|
||||
const <Symbol>[Symbol("sym")],
|
||||
const <Symbol>[
|
||||
...<Symbol>[Symbol("sym")],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void testMap() {
|
||||
@@ -63,16 +105,25 @@ void testMap() {
|
||||
Expect.identical(map, const <int, int>{...map});
|
||||
|
||||
// Spread at beginning.
|
||||
Expect.identical(map,
|
||||
const <int, int>{...<int, int>{1: 1, 2: 2}, 3: 3, 4: 4});
|
||||
Expect.identical(map, const <int, int>{
|
||||
...<int, int>{1: 1, 2: 2},
|
||||
3: 3,
|
||||
4: 4,
|
||||
});
|
||||
|
||||
// Spread in middle.
|
||||
Expect.identical(map,
|
||||
const <int, int>{1: 1, ...<int, int>{2: 2, 3: 3}, 4: 4});
|
||||
Expect.identical(map, const <int, int>{
|
||||
1: 1,
|
||||
...<int, int>{2: 2, 3: 3},
|
||||
4: 4,
|
||||
});
|
||||
|
||||
// Spread at end.
|
||||
Expect.identical(map,
|
||||
const <int, int>{1: 1, 2: 2, ...<int, int>{3: 3, 4: 4}});
|
||||
Expect.identical(map, const <int, int>{
|
||||
1: 1,
|
||||
2: 2,
|
||||
...<int, int>{3: 3, 4: 4},
|
||||
});
|
||||
|
||||
// Empty spreads.
|
||||
Expect.identical(map, const <int, int>{
|
||||
@@ -82,19 +133,22 @@ void testMap() {
|
||||
...<int, int>{},
|
||||
3: 3,
|
||||
4: 4,
|
||||
...<int, int>{}
|
||||
...<int, int>{},
|
||||
});
|
||||
|
||||
// Multiple spreads.
|
||||
Expect.identical(map,
|
||||
const <int, int>{...<int, int>{1: 1}, 2: 2, ...<int, int>{3: 3, 4: 4}});
|
||||
Expect.identical(map, const <int, int>{
|
||||
...<int, int>{1: 1},
|
||||
2: 2,
|
||||
...<int, int>{3: 3, 4: 4},
|
||||
});
|
||||
|
||||
// Nested spreads.
|
||||
Expect.identical(map, const <int, int>{
|
||||
...<int, int>{
|
||||
...<int, int>{1: 1, 2: 2},
|
||||
...<int, int>{3: 3, 4: 4}
|
||||
}
|
||||
...<int, int>{3: 3, 4: 4},
|
||||
},
|
||||
});
|
||||
|
||||
// Null-aware.
|
||||
@@ -104,30 +158,34 @@ void testMap() {
|
||||
1: 1,
|
||||
...?map23,
|
||||
...?(null),
|
||||
...?map4
|
||||
...?map4,
|
||||
});
|
||||
|
||||
// Does not deep flatten.
|
||||
Expect.identical(const <int, Object>{
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: <int, int>{3: 3},
|
||||
4: 4
|
||||
}, const <int, Object>{
|
||||
1: 1,
|
||||
...<int, Object>{
|
||||
Expect.identical(
|
||||
const <int, Object>{
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: <int, int>{3: 3},
|
||||
4: 4
|
||||
}
|
||||
});
|
||||
4: 4,
|
||||
},
|
||||
const <int, Object>{
|
||||
1: 1,
|
||||
...<int, Object>{
|
||||
2: 2,
|
||||
3: <int, int>{3: 3},
|
||||
4: 4,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Establishes const context.
|
||||
Expect.identical(const <Symbol, Symbol>{
|
||||
Symbol("sym"): Symbol("bol")
|
||||
}, const <Symbol, Symbol>{
|
||||
...<Symbol, Symbol>{Symbol("sym"): Symbol("bol")}
|
||||
});
|
||||
Expect.identical(
|
||||
const <Symbol, Symbol>{Symbol("sym"): Symbol("bol")},
|
||||
const <Symbol, Symbol>{
|
||||
...<Symbol, Symbol>{Symbol("sym"): Symbol("bol")},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void testSet() {
|
||||
@@ -136,51 +194,123 @@ void testSet() {
|
||||
Expect.identical(set, const <int>{...list});
|
||||
|
||||
// Spread at beginning.
|
||||
Expect.identical(set, const <int>{...<int>[1, 2], 3, 4});
|
||||
Expect.identical(set, const <int>{
|
||||
...<int>[1, 2],
|
||||
3,
|
||||
4,
|
||||
});
|
||||
|
||||
// Spread in middle.
|
||||
Expect.identical(set, const <int>{1, ...<int>[2, 3], 4});
|
||||
Expect.identical(set, const <int>{
|
||||
1,
|
||||
...<int>[2, 3],
|
||||
4,
|
||||
});
|
||||
|
||||
// Spread at end.
|
||||
Expect.identical(set, const <int>{1, 2, ...<int>[3, 4]});
|
||||
Expect.identical(set, const <int>{
|
||||
1,
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
});
|
||||
|
||||
// Empty spreads.
|
||||
Expect.identical(set,
|
||||
const <int>{...<int>[], 1, 2, ...<int>[], 3, 4, ...<int>[]});
|
||||
Expect.identical(set, const <int>{
|
||||
...<int>[],
|
||||
1,
|
||||
2,
|
||||
...<int>[],
|
||||
3,
|
||||
4,
|
||||
...<int>[],
|
||||
});
|
||||
|
||||
// Multiple spreads.
|
||||
Expect.identical(set, const <int>{...<int>[1], 2, ...<int>[3, 4]});
|
||||
Expect.identical(set, const <int>{
|
||||
...<int>[1],
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
});
|
||||
|
||||
// Nested spreads.
|
||||
Expect.identical(set, const <int>{...<int>{...<int>[1, 2], ...<int>[3, 4]}});
|
||||
Expect.identical(set, const <int>{
|
||||
...<int>{
|
||||
...<int>[1, 2],
|
||||
...<int>[3, 4],
|
||||
},
|
||||
});
|
||||
|
||||
// Null-aware.
|
||||
const list23 = <int>[2, 3] as List<int>?;
|
||||
const list4 = <int>[4] as List<int>?;
|
||||
Expect.identical(set,
|
||||
const <int>{1, ...?list23, ...?(null), ...?list4});
|
||||
Expect.identical(set, const <int>{1, ...?list23, ...?(null), ...?list4});
|
||||
|
||||
// Does not deep flatten.
|
||||
Expect.identical(const <Object>{1, 2, <int>{3}, 4},
|
||||
const <Object>{1, ...<Object>{2, <int>{3}, 4}});
|
||||
Expect.identical(
|
||||
const <Object>{
|
||||
1,
|
||||
2,
|
||||
<int>{3},
|
||||
4,
|
||||
},
|
||||
const <Object>{
|
||||
1,
|
||||
...<Object>{
|
||||
2,
|
||||
<int>{3},
|
||||
4,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Establishes const context.
|
||||
Expect.identical(const <Symbol>{Symbol("sym")},
|
||||
const <Symbol>{...<Symbol>{Symbol("sym")}});
|
||||
Expect.identical(
|
||||
const <Symbol>{Symbol("sym")},
|
||||
const <Symbol>{
|
||||
...<Symbol>{Symbol("sym")},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void testKeyOrder() {
|
||||
// Canonicalization isn't affected by which elements are spread.
|
||||
Expect.identical(map,
|
||||
const <int, int>{1: 1, ...<int, int>{2: 2, 3: 3}, 4: 4});
|
||||
Expect.identical(map,
|
||||
const <int, int>{1: 1, ...<int, int>{2: 2}, 3: 3, ...<int, int>{4: 4}});
|
||||
Expect.identical(map, const <int, int>{
|
||||
1: 1,
|
||||
...<int, int>{2: 2, 3: 3},
|
||||
4: 4,
|
||||
});
|
||||
Expect.identical(map, const <int, int>{
|
||||
1: 1,
|
||||
...<int, int>{2: 2},
|
||||
3: 3,
|
||||
...<int, int>{4: 4},
|
||||
});
|
||||
|
||||
Expect.identical(set, const <int>{1, ...<int>{2, 3}, 4});
|
||||
Expect.identical(set, const <int>{1, ...<int>{2}, 3, ...<int>{4}});
|
||||
Expect.identical(set, const <int>{
|
||||
1,
|
||||
...<int>{2, 3},
|
||||
4,
|
||||
});
|
||||
Expect.identical(set, const <int>{
|
||||
1,
|
||||
...<int>{2},
|
||||
3,
|
||||
...<int>{4},
|
||||
});
|
||||
|
||||
// Ordering does affect canonicalization.
|
||||
Expect.notIdentical(const <int, int>{1: 1, 2: 2, 3: 3},
|
||||
const <int, int>{1: 1, ...<int, int>{3: 3, 2: 2}});
|
||||
Expect.notIdentical(const <int>{1, 2, 3}, const <int>{1, ...<int>{3, 2}});
|
||||
Expect.notIdentical(
|
||||
const <int, int>{1: 1, 2: 2, 3: 3},
|
||||
const <int, int>{
|
||||
1: 1,
|
||||
...<int, int>{3: 3, 2: 2},
|
||||
},
|
||||
);
|
||||
Expect.notIdentical(
|
||||
const <int>{1, 2, 3},
|
||||
const <int>{
|
||||
1,
|
||||
...<int>{3, 2},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,9 +39,11 @@ class ConstMap implements Map<int, String> {
|
||||
String? remove(Object? key) => throw UnsupportedError("unsupported");
|
||||
void removeWhere(bool Function(int key, String value) predicate) =>
|
||||
throw UnsupportedError("unsupported");
|
||||
String update(int key, String Function(String value) update,
|
||||
{String Function()? ifAbsent}) =>
|
||||
throw UnsupportedError("unsupported");
|
||||
String update(
|
||||
int key,
|
||||
String Function(String value) update, {
|
||||
String Function()? ifAbsent,
|
||||
}) => throw UnsupportedError("unsupported");
|
||||
void updateAll(String Function(int key, String value) update) =>
|
||||
throw UnsupportedError("unsupported");
|
||||
}
|
||||
|
||||
@@ -14,37 +14,97 @@ void testBottomUpInference() {
|
||||
// Lists.
|
||||
Expect.type<List<dynamic>>([...[]]);
|
||||
Expect.type<List<int>>([...<int>[]]);
|
||||
Expect.type<List<int>>([...[1]]);
|
||||
Expect.type<List<int>>([1, ...[2]]);
|
||||
Expect.type<List<num>>([1, ...[0.2]]);
|
||||
Expect.type<List<int>>([...[1, 2]]);
|
||||
Expect.type<List<num>>([...[1, 0.2]]);
|
||||
Expect.type<List<int>>([...[1], ...[2]]);
|
||||
Expect.type<List<num>>([...[1], ...[0.2]]);
|
||||
Expect.type<List<int>>([
|
||||
...[1],
|
||||
]);
|
||||
Expect.type<List<int>>([
|
||||
1,
|
||||
...[2],
|
||||
]);
|
||||
Expect.type<List<num>>([
|
||||
1,
|
||||
...[0.2],
|
||||
]);
|
||||
Expect.type<List<int>>([
|
||||
...[1, 2],
|
||||
]);
|
||||
Expect.type<List<num>>([
|
||||
...[1, 0.2],
|
||||
]);
|
||||
Expect.type<List<int>>([
|
||||
...[1],
|
||||
...[2],
|
||||
]);
|
||||
Expect.type<List<num>>([
|
||||
...[1],
|
||||
...[0.2],
|
||||
]);
|
||||
|
||||
// Maps.
|
||||
Expect.type<Map<dynamic, dynamic>>({...{}});
|
||||
Expect.type<Map<int, int>>({...<int, int>{}});
|
||||
Expect.type<Map<int, int>>({...{1: 1}});
|
||||
Expect.type<Map<int, int>>({1: 1, ...{2: 2}});
|
||||
Expect.type<Map<num, num>>({1: 1, ...{0.2: 0.2}});
|
||||
Expect.type<Map<int, int>>({...{1: 1, 2: 2}});
|
||||
Expect.type<Map<num, num>>({...{1: 1, 0.2: 0.2}});
|
||||
Expect.type<Map<int, int>>({...{1: 1}, ...{2: 2}});
|
||||
Expect.type<Map<num, num>>({...{1: 1}, ...{0.2: 0.2}});
|
||||
Expect.type<Map<int, int>>({
|
||||
...{1: 1},
|
||||
});
|
||||
Expect.type<Map<int, int>>({
|
||||
1: 1,
|
||||
...{2: 2},
|
||||
});
|
||||
Expect.type<Map<num, num>>({
|
||||
1: 1,
|
||||
...{0.2: 0.2},
|
||||
});
|
||||
Expect.type<Map<int, int>>({
|
||||
...{1: 1, 2: 2},
|
||||
});
|
||||
Expect.type<Map<num, num>>({
|
||||
...{1: 1, 0.2: 0.2},
|
||||
});
|
||||
Expect.type<Map<int, int>>({
|
||||
...{1: 1},
|
||||
...{2: 2},
|
||||
});
|
||||
Expect.type<Map<num, num>>({
|
||||
...{1: 1},
|
||||
...{0.2: 0.2},
|
||||
});
|
||||
|
||||
// Sets.
|
||||
Expect.type<Set<dynamic>>({...[]});
|
||||
Expect.type<Set<int>>({...<int>[]});
|
||||
Expect.type<Set<int>>({...[1]});
|
||||
Expect.type<Set<int>>({1, ...[2]});
|
||||
Expect.type<Set<num>>({1, ...[0.2]});
|
||||
Expect.type<Set<int>>({...[1, 2]});
|
||||
Expect.type<Set<num>>({...[1, 0.2]});
|
||||
Expect.type<Set<int>>({...[1], ...[2]});
|
||||
Expect.type<Set<num>>({...[1], ...[0.2]});
|
||||
Expect.type<Set<num>>({...{1}, ...[0.2]});
|
||||
Expect.type<Set<num>>({...{1}, ...{0.2}});
|
||||
Expect.type<Set<int>>({
|
||||
...[1],
|
||||
});
|
||||
Expect.type<Set<int>>({
|
||||
1,
|
||||
...[2],
|
||||
});
|
||||
Expect.type<Set<num>>({
|
||||
1,
|
||||
...[0.2],
|
||||
});
|
||||
Expect.type<Set<int>>({
|
||||
...[1, 2],
|
||||
});
|
||||
Expect.type<Set<num>>({
|
||||
...[1, 0.2],
|
||||
});
|
||||
Expect.type<Set<int>>({
|
||||
...[1],
|
||||
...[2],
|
||||
});
|
||||
Expect.type<Set<num>>({
|
||||
...[1],
|
||||
...[0.2],
|
||||
});
|
||||
Expect.type<Set<num>>({
|
||||
...{1},
|
||||
...[0.2],
|
||||
});
|
||||
Expect.type<Set<num>>({
|
||||
...{1},
|
||||
...{0.2},
|
||||
});
|
||||
|
||||
// If the iterable's type is dynamic, the element type is inferred as dynamic.
|
||||
Expect.type<List<dynamic>>([...([] as dynamic)]);
|
||||
@@ -92,8 +152,10 @@ void testTopDownInference() {
|
||||
Expect.mapEquals(<int, String>{}, <int, String>{...expectIntStringMap()});
|
||||
|
||||
// Bottom up-inference from elements is not pushed back down into spread.
|
||||
Expect.mapEquals(<int, String>{1: "s"},
|
||||
{1: "s", ...expectDynamicDynamicMap()});
|
||||
Expect.mapEquals(
|
||||
<int, String>{1: "s"},
|
||||
{1: "s", ...expectDynamicDynamicMap()},
|
||||
);
|
||||
|
||||
// Sets.
|
||||
Set<T> expectIntSet<T>() {
|
||||
|
||||
@@ -8,7 +8,6 @@ f(Object? objectQuestion) {
|
||||
// [analyzer] COMPILE_TIME_ERROR.AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
||||
// ^
|
||||
// [cfe] Unexpected type 'Object?' of a map spread entry. Expected 'dynamic' or a Map.
|
||||
}
|
||||
|
||||
|
||||
@@ -11,27 +11,28 @@ import 'package:expect/static_type_helper.dart';
|
||||
main() {
|
||||
{
|
||||
List<int> notNullAware = [
|
||||
...(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>>>())
|
||||
...(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>>>()),
|
||||
];
|
||||
List<int> nullAware = [
|
||||
...?(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>?>>())
|
||||
...?(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>?>>()),
|
||||
];
|
||||
}
|
||||
{
|
||||
Set<int> notNullAware = {
|
||||
...(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>>>())
|
||||
...(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>>>()),
|
||||
};
|
||||
Set<int> nullAware = {
|
||||
...?(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>?>>())
|
||||
...?(contextType(<int>[])..expectStaticType<Exactly<Iterable<int>?>>()),
|
||||
};
|
||||
}
|
||||
{
|
||||
Map<int, int> notNullAware = {
|
||||
...(contextType(<int, int>{})..expectStaticType<Exactly<Map<int, int>>>())
|
||||
...(contextType(<int, int>{})
|
||||
..expectStaticType<Exactly<Map<int, int>>>()),
|
||||
};
|
||||
Map<int, int> nullAware = {
|
||||
...?(contextType(<int, int>{})
|
||||
..expectStaticType<Exactly<Map<int, int>?>>())
|
||||
..expectStaticType<Exactly<Map<int, int>?>>()),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,23 +24,51 @@ void testList() {
|
||||
Expect.listEquals(list, <int>[...list]);
|
||||
|
||||
// Spread at beginning.
|
||||
Expect.listEquals(list, <int>[...<int>[1, 2], 3, 4]);
|
||||
Expect.listEquals(list, <int>[
|
||||
...<int>[1, 2],
|
||||
3,
|
||||
4,
|
||||
]);
|
||||
|
||||
// Spread in middle.
|
||||
Expect.listEquals(list, <int>[1, ...<int>[2, 3], 4]);
|
||||
Expect.listEquals(list, <int>[
|
||||
1,
|
||||
...<int>[2, 3],
|
||||
4,
|
||||
]);
|
||||
|
||||
// Spread at end.
|
||||
Expect.listEquals(list, <int>[1, 2, ...<int>[3, 4]]);
|
||||
Expect.listEquals(list, <int>[
|
||||
1,
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
]);
|
||||
|
||||
// Empty spreads.
|
||||
Expect.listEquals(list,
|
||||
<int>[...<int>[], 1, 2, ...<int>[], 3, 4, ...<int>[]]);
|
||||
Expect.listEquals(list, <int>[
|
||||
...<int>[],
|
||||
1,
|
||||
2,
|
||||
...<int>[],
|
||||
3,
|
||||
4,
|
||||
...<int>[],
|
||||
]);
|
||||
|
||||
// Multiple spreads.
|
||||
Expect.listEquals(list, <int>[...<int>[1], 2, ...<int>[3, 4]]);
|
||||
Expect.listEquals(list, <int>[
|
||||
...<int>[1],
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
]);
|
||||
|
||||
// Nested spreads.
|
||||
Expect.listEquals(list, <int>[...<int>[...<int>[1, 2], ...<int>[3, 4]]]);
|
||||
Expect.listEquals(list, <int>[
|
||||
...<int>[
|
||||
...<int>[1, 2],
|
||||
...<int>[3, 4],
|
||||
],
|
||||
]);
|
||||
|
||||
// Null-aware.
|
||||
var list23 = [2, 3] as List<int>?;
|
||||
@@ -50,11 +78,17 @@ void testList() {
|
||||
// Does not deep flatten.
|
||||
var innerList = <int>[3];
|
||||
Expect.listEquals(
|
||||
<Object>[1, 2, innerList, 4],
|
||||
<Object>[1, ...<Object>[2, innerList, 4]]);
|
||||
<Object>[1, 2, innerList, 4],
|
||||
<Object>[
|
||||
1,
|
||||
...<Object>[2, innerList, 4],
|
||||
],
|
||||
);
|
||||
|
||||
// Downcast element from dynamic.
|
||||
Expect.listEquals(list, <int>[...<dynamic>[1, 2, 3, 4]]);
|
||||
Expect.listEquals(list, <int>[
|
||||
...<dynamic>[1, 2, 3, 4],
|
||||
]);
|
||||
}
|
||||
|
||||
void testMap() {
|
||||
@@ -62,13 +96,25 @@ void testMap() {
|
||||
Expect.mapEquals(map, <int, int>{...map});
|
||||
|
||||
// Spread at beginning.
|
||||
Expect.mapEquals(map, <int, int>{...<int, int>{1: 1, 2: 2}, 3: 3, 4: 4});
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
...<int, int>{1: 1, 2: 2},
|
||||
3: 3,
|
||||
4: 4,
|
||||
});
|
||||
|
||||
// Spread in middle.
|
||||
Expect.mapEquals(map, <int, int>{1: 1, ...<int, int>{2: 2, 3: 3}, 4: 4});
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
1: 1,
|
||||
...<int, int>{2: 2, 3: 3},
|
||||
4: 4,
|
||||
});
|
||||
|
||||
// Spread at end.
|
||||
Expect.mapEquals(map, <int, int>{1: 1, 2: 2, ...<int, int>{3: 3, 4: 4}});
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
1: 1,
|
||||
2: 2,
|
||||
...<int, int>{3: 3, 4: 4},
|
||||
});
|
||||
|
||||
// Empty spreads.
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
@@ -78,50 +124,43 @@ void testMap() {
|
||||
...<int, int>{},
|
||||
3: 3,
|
||||
4: 4,
|
||||
...<int, int>{}
|
||||
...<int, int>{},
|
||||
});
|
||||
|
||||
// Multiple spreads.
|
||||
Expect.mapEquals(map,
|
||||
<int, int>{...<int, int>{1: 1}, 2: 2, ...<int, int>{3: 3, 4: 4}});
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
...<int, int>{1: 1},
|
||||
2: 2,
|
||||
...<int, int>{3: 3, 4: 4},
|
||||
});
|
||||
|
||||
// Nested spreads.
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
...<int, int>{
|
||||
...<int, int>{1: 1, 2: 2},
|
||||
...<int, int>{3: 3, 4: 4}
|
||||
}
|
||||
...<int, int>{3: 3, 4: 4},
|
||||
},
|
||||
});
|
||||
|
||||
// Null-aware.
|
||||
var map23 = {2: 2, 3: 3} as Map<int, int>?;
|
||||
var map4 = {4: 4} as Map<int, int>?;
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
1: 1,
|
||||
...?map23,
|
||||
...?(null),
|
||||
...?map4
|
||||
});
|
||||
Expect.mapEquals(map, <int, int>{1: 1, ...?map23, ...?(null), ...?map4});
|
||||
|
||||
// Does not deep flatten.
|
||||
var innerMap = <int, int>{3: 3};
|
||||
Expect.mapEquals(<int, Object>{
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: innerMap,
|
||||
4: 4
|
||||
}, <int, Object>{
|
||||
1: 1,
|
||||
...<int, Object>{
|
||||
2: 2,
|
||||
3: innerMap,
|
||||
4: 4
|
||||
}
|
||||
});
|
||||
Expect.mapEquals(
|
||||
<int, Object>{1: 1, 2: 2, 3: innerMap, 4: 4},
|
||||
<int, Object>{
|
||||
1: 1,
|
||||
...<int, Object>{2: 2, 3: innerMap, 4: 4},
|
||||
},
|
||||
);
|
||||
|
||||
// Downcast element from dynamic.
|
||||
Expect.mapEquals(
|
||||
map, <int, int>{...<dynamic, dynamic>{1: 1, 2: 2, 3: 3, 4: 4}});
|
||||
Expect.mapEquals(map, <int, int>{
|
||||
...<dynamic, dynamic>{1: 1, 2: 2, 3: 3, 4: 4},
|
||||
});
|
||||
}
|
||||
|
||||
void testSet() {
|
||||
@@ -129,22 +168,43 @@ void testSet() {
|
||||
Expect.setEquals(set, <int>{...set});
|
||||
|
||||
// Spread at beginning.
|
||||
Expect.setEquals(set, <int>{...<int>[1, 2], 3, 4});
|
||||
Expect.setEquals(set, <int>{
|
||||
...<int>[1, 2],
|
||||
3,
|
||||
4,
|
||||
});
|
||||
|
||||
// Spread in middle.
|
||||
Expect.setEquals(set, <int>{1, ...<int>[2, 3], 4});
|
||||
Expect.setEquals(set, <int>{
|
||||
1,
|
||||
...<int>[2, 3],
|
||||
4,
|
||||
});
|
||||
|
||||
// Spread at end.
|
||||
Expect.setEquals(set, <int>{1, 2, ...<int>[3, 4]});
|
||||
Expect.setEquals(set, <int>{
|
||||
1,
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
});
|
||||
|
||||
// Empty spreads.
|
||||
Expect.setEquals(set, <int>{...<int>[], 1, 2, ...<int>[], 3, 4, ...<int>[]});
|
||||
|
||||
// Multiple spreads.
|
||||
Expect.setEquals(set, <int>{...<int>[1], 2, ...<int>[3, 4]});
|
||||
Expect.setEquals(set, <int>{
|
||||
...<int>[1],
|
||||
2,
|
||||
...<int>[3, 4],
|
||||
});
|
||||
|
||||
// Nested spreads.
|
||||
Expect.setEquals(set, <int>{...<int>{...<int>[1, 2], ...<int>[3, 4]}});
|
||||
Expect.setEquals(set, <int>{
|
||||
...<int>{
|
||||
...<int>[1, 2],
|
||||
...<int>[3, 4],
|
||||
},
|
||||
});
|
||||
|
||||
// Null-aware.
|
||||
var list23 = [2, 3] as List<int>?;
|
||||
@@ -153,11 +213,18 @@ void testSet() {
|
||||
|
||||
// Does not deep flatten.
|
||||
var innerSet = <int>{3};
|
||||
Expect.setEquals(<Object>{1, 2, innerSet, 4},
|
||||
<Object>{1, ...<Object>[2, innerSet, 4]});
|
||||
Expect.setEquals(
|
||||
<Object>{1, 2, innerSet, 4},
|
||||
<Object>{
|
||||
1,
|
||||
...<Object>[2, innerSet, 4],
|
||||
},
|
||||
);
|
||||
|
||||
// Downcast element from dynamic.
|
||||
Expect.setEquals(set, <int>{...<dynamic>[1, 2, 3, 4]});
|
||||
Expect.setEquals(set, <int>{
|
||||
...<dynamic>[1, 2, 3, 4],
|
||||
});
|
||||
}
|
||||
|
||||
void testDuplicateKeys() {
|
||||
@@ -166,9 +233,15 @@ void testDuplicateKeys() {
|
||||
2: 2,
|
||||
...<int, int>{2: 2, 3: 3, 4: 4},
|
||||
...<int, int>{3: 3},
|
||||
4: 4
|
||||
4: 4,
|
||||
});
|
||||
Expect.setEquals(set, <int>{
|
||||
1,
|
||||
2,
|
||||
...<int>[1, 2, 3, 4],
|
||||
...<int>[2, 3],
|
||||
4,
|
||||
});
|
||||
Expect.setEquals(set, <int>{1, 2, ...<int>[1, 2, 3, 4], ...<int>[2, 3], 4});
|
||||
}
|
||||
|
||||
void testKeyOrder() {
|
||||
@@ -178,10 +251,16 @@ void testKeyOrder() {
|
||||
var e2a = Equality(2, "a");
|
||||
var e2b = Equality(2, "b");
|
||||
|
||||
var map = <Equality, int>{e1a: 1, ...<Equality, int>{e1b: 2, e2a: 3, e2b: 4}};
|
||||
var map = <Equality, int>{
|
||||
e1a: 1,
|
||||
...<Equality, int>{e1b: 2, e2a: 3, e2b: 4},
|
||||
};
|
||||
Expect.equals("1:a,2:a", map.keys.join(","));
|
||||
|
||||
var set = <Equality>{e1a, ...<Equality>[e1b, e2a, e2b]};
|
||||
var set = <Equality>{
|
||||
e1a,
|
||||
...<Equality>[e1b, e2a, e2b],
|
||||
};
|
||||
Expect.equals("1:a,2:a", set.join(","));
|
||||
|
||||
// All elements are evaluated, left to right.
|
||||
@@ -193,11 +272,14 @@ void testKeyOrder() {
|
||||
|
||||
map = <Equality, int>{
|
||||
log(e1a): log(1),
|
||||
...<Equality, int>{log(e1b): log(2), log(e2a): log(3), log(e2b): log(4)}
|
||||
...<Equality, int>{log(e1b): log(2), log(e2a): log(3), log(e2b): log(4)},
|
||||
};
|
||||
Expect.equals("1:a,1,1:b,2,2:a,3,2:b,4", transcript.join(","));
|
||||
|
||||
transcript.clear();
|
||||
set = <Equality>{log(e1a), ...<Equality>[log(e1b), log(e2a), log(e2b)]};
|
||||
set = <Equality>{
|
||||
log(e1a),
|
||||
...<Equality>[log(e1b), log(e2a), log(e2b)],
|
||||
};
|
||||
Expect.equals("1:a,1:b,2:a,2:b", transcript.join(","));
|
||||
}
|
||||
|
||||
@@ -7,16 +7,45 @@ import 'package:expect/expect.dart';
|
||||
|
||||
void main() {
|
||||
// Trailing comma.
|
||||
Expect.listEquals([1, 2], [...[1, 2],]);
|
||||
Expect.mapEquals({1: 1, 2: 2}, {...{1: 1, 2: 2},});
|
||||
Expect.setEquals({1, 2}, {...{1, 2},});
|
||||
Expect.listEquals(
|
||||
[1, 2],
|
||||
[
|
||||
...[1, 2],
|
||||
],
|
||||
);
|
||||
Expect.mapEquals(
|
||||
{1: 1, 2: 2},
|
||||
{
|
||||
...{1: 1, 2: 2},
|
||||
},
|
||||
);
|
||||
Expect.setEquals(
|
||||
{1, 2},
|
||||
{
|
||||
...{1, 2},
|
||||
},
|
||||
);
|
||||
|
||||
// Precedence.
|
||||
Expect.listEquals([1, 2, 3], [1, ...true ? [2] : [], 3]);
|
||||
Expect.listEquals(
|
||||
[1, 2, 3],
|
||||
[
|
||||
1,
|
||||
...true ? [2] : [],
|
||||
3,
|
||||
],
|
||||
);
|
||||
Expect.listEquals([1, 3], [1, ...?true ? null : [], 3]);
|
||||
|
||||
var a = [0];
|
||||
Expect.listEquals([1, 2, 3], [1, ...a = [2], 3]);
|
||||
Expect.listEquals(
|
||||
[1, 2, 3],
|
||||
[
|
||||
1,
|
||||
...a = [2],
|
||||
3,
|
||||
],
|
||||
);
|
||||
var nullableA = [0] as List<int>?;
|
||||
Expect.listEquals([1, 3], [1, ...?nullableA = null, 3]);
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ main() {
|
||||
Niesen.goodCall(1, 2, 3);
|
||||
|
||||
Niesen.goodCall(1, 2, 3, 4);
|
||||
// ^
|
||||
// [cfe] Too many positional arguments: 3 allowed, but 4 found.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
|
||||
// ^^^^^^^^^^^^
|
||||
// [cfe] Too many positional arguments: 3 allowed, but 4 found.
|
||||
}
|
||||
|
||||
@@ -30,10 +30,7 @@ class A implements Switzerland {
|
||||
static const artist2 = Switzerland.AG;
|
||||
static const architect1 = Spain.AG;
|
||||
static const array1 = const <int>[1, 2];
|
||||
static const map1 = const {
|
||||
"Monday": 1,
|
||||
"Tuesday": 2,
|
||||
};
|
||||
static const map1 = const {"Monday": 1, "Tuesday": 2};
|
||||
}
|
||||
|
||||
class StaticFinalFieldTest {
|
||||
|
||||
@@ -15,7 +15,6 @@ class StaticField1Test {
|
||||
static testMain() {
|
||||
if (false) {
|
||||
var foo = new Foo();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ class StaticField1aTest {
|
||||
static testMain() {
|
||||
if (false) {
|
||||
var foo = new Foo();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,5 @@ class Foo {
|
||||
}
|
||||
|
||||
main() {
|
||||
if (false) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (false) {}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ class B {
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
new B();
|
||||
print(B.b);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ class B {
|
||||
|
||||
main() {
|
||||
A.x = 2;
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_CONST
|
||||
// [cfe] Setter not found: 'x'.
|
||||
//^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_CONST
|
||||
// [cfe] Setter not found: 'x'.
|
||||
new B();
|
||||
print(B.b);
|
||||
print(B.a);
|
||||
|
||||
@@ -10,9 +10,7 @@ import 'package:expect/expect.dart';
|
||||
class Class {
|
||||
static int get getter => 0;
|
||||
|
||||
method() {
|
||||
|
||||
}
|
||||
method() {}
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -9,9 +9,9 @@ class Class {
|
||||
|
||||
method() {
|
||||
getter++;
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
// [error column 5, length 6]
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ import 'package:expect/expect.dart';
|
||||
class Class {
|
||||
static int get getter => 0;
|
||||
|
||||
method() {
|
||||
|
||||
}
|
||||
method() {}
|
||||
|
||||
noSuchMethod(i) => 42;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ class Class {
|
||||
|
||||
method() {
|
||||
getter++;
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
// [error column 5, length 6]
|
||||
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_FINAL_NO_SETTER
|
||||
// [cfe] Setter not found: 'getter'.
|
||||
}
|
||||
|
||||
noSuchMethod(i) => 42;
|
||||
|
||||
@@ -13,6 +13,4 @@ class Class {
|
||||
noSuchMethod(_) => 42;
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
}
|
||||
main() {}
|
||||
|
||||
@@ -5,14 +5,4 @@
|
||||
// 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void main() {}
|
||||
|
||||
@@ -3,36 +3,36 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
static method() { }
|
||||
// [error line 5, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
static var field;
|
||||
// [error line 9, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
static const finalField = 42;
|
||||
// [error line 13, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
static const constant = 123;
|
||||
// [error line 17, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
|
||||
static int typedMethod() => 87;
|
||||
// [error line 22, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
static int typedField = -1;
|
||||
// [error line 26, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
static const int typedFinalField = 99;
|
||||
// [error line 30, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
static const int typedConstant = 1;
|
||||
// [error line 34, column 1, length 6]
|
||||
// [error column 1, length 6]
|
||||
// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
|
||||
// [cfe] Can't have modifier 'static' here.
|
||||
|
||||
|
||||
@@ -21,97 +21,310 @@ main() {
|
||||
}
|
||||
|
||||
testEmpty() {
|
||||
Expect.equals("", (const Conster("" "" "")).toString());
|
||||
Expect.equals("", (const Conster("" '' "")).toString());
|
||||
Expect.equals("", (const Conster("" "" r"")).toString());
|
||||
Expect.equals(
|
||||
"",
|
||||
(const Conster(
|
||||
""
|
||||
""
|
||||
"",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"",
|
||||
(const Conster(
|
||||
""
|
||||
''
|
||||
"",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"",
|
||||
(const Conster(
|
||||
""
|
||||
""
|
||||
r"",
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals("a", (const Conster("a" "")).toString());
|
||||
Expect.equals("a", (const Conster("a" '')).toString());
|
||||
Expect.equals("a", (const Conster("a" r'')).toString());
|
||||
Expect.equals(
|
||||
"a",
|
||||
(const Conster(
|
||||
"a"
|
||||
"",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
(const Conster(
|
||||
"a"
|
||||
'',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
(const Conster(
|
||||
"a"
|
||||
r'',
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals("b", (const Conster('b' "")).toString());
|
||||
Expect.equals("b", (const Conster('b' '')).toString());
|
||||
Expect.equals("b", (const Conster('b' r'')).toString());
|
||||
Expect.equals(
|
||||
"b",
|
||||
(const Conster(
|
||||
'b'
|
||||
"",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
(const Conster(
|
||||
'b'
|
||||
'',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
(const Conster(
|
||||
'b'
|
||||
r'',
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals("c", (const Conster(r'c' "")).toString());
|
||||
Expect.equals("c", (const Conster(r'c' '')).toString());
|
||||
Expect.equals("c", (const Conster(r'c' r'')).toString());
|
||||
Expect.equals(
|
||||
"c",
|
||||
(const Conster(
|
||||
r'c'
|
||||
"",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
(const Conster(
|
||||
r'c'
|
||||
'',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
(const Conster(
|
||||
r'c'
|
||||
r'',
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals("a", (const Conster("" "a")).toString());
|
||||
Expect.equals("a", (const Conster("" 'a')).toString());
|
||||
Expect.equals("a", (const Conster("" r'a')).toString());
|
||||
Expect.equals(
|
||||
"a",
|
||||
(const Conster(
|
||||
""
|
||||
"a",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
(const Conster(
|
||||
""
|
||||
'a',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
(const Conster(
|
||||
""
|
||||
r'a',
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals("b", (const Conster('' "b")).toString());
|
||||
Expect.equals("b", (const Conster('' 'b')).toString());
|
||||
Expect.equals("b", (const Conster('' r'b')).toString());
|
||||
Expect.equals(
|
||||
"b",
|
||||
(const Conster(
|
||||
''
|
||||
"b",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
(const Conster(
|
||||
''
|
||||
'b',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
(const Conster(
|
||||
''
|
||||
r'b',
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals("c", (const Conster(r'' "c")).toString());
|
||||
Expect.equals("c", (const Conster(r'' 'c')).toString());
|
||||
Expect.equals("c", (const Conster(r'' r'c')).toString());
|
||||
Expect.equals(
|
||||
"c",
|
||||
(const Conster(
|
||||
r''
|
||||
"c",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
(const Conster(
|
||||
r''
|
||||
'c',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
(const Conster(
|
||||
r''
|
||||
r'c',
|
||||
)).toString(),
|
||||
);
|
||||
}
|
||||
|
||||
const s = "a";
|
||||
|
||||
testInterpolation() {
|
||||
Expect.equals(r"ab", (const Conster("$s" "b")).toString());
|
||||
Expect.equals(r"ab", (const Conster('$s' "b")).toString());
|
||||
Expect.equals(r"$sb", (const Conster(r'$s' "b")).toString());
|
||||
Expect.equals(
|
||||
r"ab",
|
||||
(const Conster(
|
||||
"$s"
|
||||
"b",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"ab",
|
||||
(const Conster(
|
||||
'$s'
|
||||
"b",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"$sb",
|
||||
(const Conster(
|
||||
r'$s'
|
||||
"b",
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals(r"-a-b", (const Conster("-$s-" "b")).toString());
|
||||
Expect.equals(r"-a-b", (const Conster('-$s-' "b")).toString());
|
||||
Expect.equals(r"-$s-b", (const Conster(r'-$s-' "b")).toString());
|
||||
Expect.equals(
|
||||
r"-a-b",
|
||||
(const Conster(
|
||||
"-$s-"
|
||||
"b",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"-a-b",
|
||||
(const Conster(
|
||||
'-$s-'
|
||||
"b",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"-$s-b",
|
||||
(const Conster(
|
||||
r'-$s-'
|
||||
"b",
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals(r"ba", (const Conster('b' "$s")).toString());
|
||||
Expect.equals(r"ba", (const Conster('b' '$s')).toString());
|
||||
Expect.equals(r"b$s", (const Conster('b' r'$s')).toString());
|
||||
Expect.equals(
|
||||
r"ba",
|
||||
(const Conster(
|
||||
'b'
|
||||
"$s",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"ba",
|
||||
(const Conster(
|
||||
'b'
|
||||
'$s',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"b$s",
|
||||
(const Conster(
|
||||
'b'
|
||||
r'$s',
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals(r"b-a-", (const Conster('b' "-$s-")).toString());
|
||||
Expect.equals(r"b-a-", (const Conster('b' '-$s-')).toString());
|
||||
Expect.equals(r"b-$s-", (const Conster('b' r'-$s-')).toString());
|
||||
Expect.equals(
|
||||
r"b-a-",
|
||||
(const Conster(
|
||||
'b'
|
||||
"-$s-",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"b-a-",
|
||||
(const Conster(
|
||||
'b'
|
||||
'-$s-',
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
r"b-$s-",
|
||||
(const Conster(
|
||||
'b'
|
||||
r'-$s-',
|
||||
)).toString(),
|
||||
);
|
||||
}
|
||||
|
||||
testMultiline() {
|
||||
Expect.equals(
|
||||
"abe",
|
||||
(const Conster("a"
|
||||
"b"
|
||||
"e"))
|
||||
.toString());
|
||||
"abe",
|
||||
(const Conster(
|
||||
"a"
|
||||
"b"
|
||||
"e",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"a b e",
|
||||
(const Conster("a "
|
||||
"b "
|
||||
"e"))
|
||||
.toString());
|
||||
"a b e",
|
||||
(const Conster(
|
||||
"a "
|
||||
"b "
|
||||
"e",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"a b e",
|
||||
(const Conster("a"
|
||||
" b"
|
||||
" e"))
|
||||
.toString());
|
||||
"a b e",
|
||||
(const Conster(
|
||||
"a"
|
||||
" b"
|
||||
" e",
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals(
|
||||
"abe",
|
||||
(const Conster("""
|
||||
"abe",
|
||||
(const Conster(
|
||||
"""
|
||||
a"""
|
||||
"b"
|
||||
"e"))
|
||||
.toString());
|
||||
"b"
|
||||
"e",
|
||||
)).toString(),
|
||||
);
|
||||
Expect.equals(
|
||||
"a b e",
|
||||
(const Conster("""
|
||||
"a b e",
|
||||
(const Conster(
|
||||
"""
|
||||
a"""
|
||||
" b"
|
||||
" e"))
|
||||
.toString());
|
||||
" b"
|
||||
" e",
|
||||
)).toString(),
|
||||
);
|
||||
|
||||
Expect.equals(
|
||||
"abe",
|
||||
(const Conster("""
|
||||
"abe",
|
||||
(const Conster(
|
||||
"""
|
||||
a"""
|
||||
"""
|
||||
"""
|
||||
b"""
|
||||
"""
|
||||
e"""))
|
||||
.toString());
|
||||
"""
|
||||
e""",
|
||||
)).toString(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,90 +11,231 @@ main() {
|
||||
}
|
||||
|
||||
testEmpty() {
|
||||
Expect.equals("", "" "" "");
|
||||
Expect.equals("", "" '' "");
|
||||
Expect.equals("", "" "" r"");
|
||||
Expect.equals(
|
||||
"",
|
||||
""
|
||||
""
|
||||
"",
|
||||
);
|
||||
Expect.equals(
|
||||
"",
|
||||
""
|
||||
''
|
||||
"",
|
||||
);
|
||||
Expect.equals(
|
||||
"",
|
||||
""
|
||||
""
|
||||
r"",
|
||||
);
|
||||
|
||||
Expect.equals("a", "a" "");
|
||||
Expect.equals("a", "a" '');
|
||||
Expect.equals("a", "a" r'');
|
||||
Expect.equals(
|
||||
"a",
|
||||
"a"
|
||||
"",
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
"a"
|
||||
'',
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
"a"
|
||||
r'',
|
||||
);
|
||||
|
||||
Expect.equals("b", 'b' "");
|
||||
Expect.equals("b", 'b' '');
|
||||
Expect.equals("b", 'b' r'');
|
||||
Expect.equals(
|
||||
"b",
|
||||
'b'
|
||||
"",
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
'b'
|
||||
'',
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
'b'
|
||||
r'',
|
||||
);
|
||||
|
||||
Expect.equals("c", r'c' "");
|
||||
Expect.equals("c", r'c' '');
|
||||
Expect.equals("c", r'c' r'');
|
||||
Expect.equals(
|
||||
"c",
|
||||
r'c'
|
||||
"",
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
r'c'
|
||||
'',
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
r'c'
|
||||
r'',
|
||||
);
|
||||
|
||||
Expect.equals("a", "" "a");
|
||||
Expect.equals("a", "" 'a');
|
||||
Expect.equals("a", "" r'a');
|
||||
Expect.equals(
|
||||
"a",
|
||||
""
|
||||
"a",
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
""
|
||||
'a',
|
||||
);
|
||||
Expect.equals(
|
||||
"a",
|
||||
""
|
||||
r'a',
|
||||
);
|
||||
|
||||
Expect.equals("b", '' "b");
|
||||
Expect.equals("b", '' 'b');
|
||||
Expect.equals("b", '' r'b');
|
||||
Expect.equals(
|
||||
"b",
|
||||
''
|
||||
"b",
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
''
|
||||
'b',
|
||||
);
|
||||
Expect.equals(
|
||||
"b",
|
||||
''
|
||||
r'b',
|
||||
);
|
||||
|
||||
Expect.equals("c", r'' "c");
|
||||
Expect.equals("c", r'' 'c');
|
||||
Expect.equals("c", r'' r'c');
|
||||
Expect.equals(
|
||||
"c",
|
||||
r''
|
||||
"c",
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
r''
|
||||
'c',
|
||||
);
|
||||
Expect.equals(
|
||||
"c",
|
||||
r''
|
||||
r'c',
|
||||
);
|
||||
}
|
||||
|
||||
testInterpolation() {
|
||||
var s = "a";
|
||||
Expect.equals(r"ab", "$s" "b");
|
||||
Expect.equals(r"ab", '$s' "b");
|
||||
Expect.equals(r"$sb", r'$s' "b");
|
||||
Expect.equals(
|
||||
r"ab",
|
||||
"$s"
|
||||
"b",
|
||||
);
|
||||
Expect.equals(
|
||||
r"ab",
|
||||
'$s'
|
||||
"b",
|
||||
);
|
||||
Expect.equals(
|
||||
r"$sb",
|
||||
r'$s'
|
||||
"b",
|
||||
);
|
||||
|
||||
Expect.equals(r"-a-b", "-$s-" "b");
|
||||
Expect.equals(r"-a-b", '-$s-' "b");
|
||||
Expect.equals(r"-$s-b", r'-$s-' "b");
|
||||
Expect.equals(
|
||||
r"-a-b",
|
||||
"-$s-"
|
||||
"b",
|
||||
);
|
||||
Expect.equals(
|
||||
r"-a-b",
|
||||
'-$s-'
|
||||
"b",
|
||||
);
|
||||
Expect.equals(
|
||||
r"-$s-b",
|
||||
r'-$s-'
|
||||
"b",
|
||||
);
|
||||
|
||||
Expect.equals(r"ba", 'b' "$s");
|
||||
Expect.equals(r"ba", 'b' '$s');
|
||||
Expect.equals(r"b$s", 'b' r'$s');
|
||||
Expect.equals(
|
||||
r"ba",
|
||||
'b'
|
||||
"$s",
|
||||
);
|
||||
Expect.equals(
|
||||
r"ba",
|
||||
'b'
|
||||
'$s',
|
||||
);
|
||||
Expect.equals(
|
||||
r"b$s",
|
||||
'b'
|
||||
r'$s',
|
||||
);
|
||||
|
||||
Expect.equals(r"b-a-", 'b' "-$s-");
|
||||
Expect.equals(r"b-a-", 'b' '-$s-');
|
||||
Expect.equals(r"b-$s-", 'b' r'-$s-');
|
||||
Expect.equals(
|
||||
r"b-a-",
|
||||
'b'
|
||||
"-$s-",
|
||||
);
|
||||
Expect.equals(
|
||||
r"b-a-",
|
||||
'b'
|
||||
'-$s-',
|
||||
);
|
||||
Expect.equals(
|
||||
r"b-$s-",
|
||||
'b'
|
||||
r'-$s-',
|
||||
);
|
||||
}
|
||||
|
||||
testMultiline() {
|
||||
Expect.equals(
|
||||
"abe",
|
||||
"a"
|
||||
"b"
|
||||
"e");
|
||||
"abe",
|
||||
"a"
|
||||
"b"
|
||||
"e",
|
||||
);
|
||||
Expect.equals(
|
||||
"a b e",
|
||||
"a "
|
||||
"b "
|
||||
"e");
|
||||
"a b e",
|
||||
"a "
|
||||
"b "
|
||||
"e",
|
||||
);
|
||||
Expect.equals(
|
||||
"a b e",
|
||||
"a"
|
||||
" b"
|
||||
" e");
|
||||
"a b e",
|
||||
"a"
|
||||
" b"
|
||||
" e",
|
||||
);
|
||||
|
||||
Expect.equals(
|
||||
"abe",
|
||||
"""
|
||||
"abe",
|
||||
"""
|
||||
a"""
|
||||
"b"
|
||||
"e");
|
||||
"b"
|
||||
"e",
|
||||
);
|
||||
Expect.equals(
|
||||
"a b e",
|
||||
"""
|
||||
"a b e",
|
||||
"""
|
||||
a"""
|
||||
" b"
|
||||
" e");
|
||||
" b"
|
||||
" e",
|
||||
);
|
||||
|
||||
Expect.equals(
|
||||
"abe",
|
||||
"""
|
||||
"abe",
|
||||
"""
|
||||
a"""
|
||||
"""
|
||||
"""
|
||||
b"""
|
||||
"""
|
||||
e""");
|
||||
"""
|
||||
e""",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,20 +7,14 @@
|
||||
|
||||
main() {
|
||||
// Raw String may not contain newline (may not be multi-line).
|
||||
String x = ''
|
||||
|
||||
|
||||
|
||||
|
||||
String x =
|
||||
''
|
||||
// Test that a raw string containing just one character, a \n char, fails.
|
||||
// Enclose the test string in a bigger multiline string, except in case 03:
|
||||
|
||||
"""
|
||||
|
||||
r'
|
||||
'
|
||||
|
||||
"""
|
||||
|
||||
;
|
||||
""";
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ main() {
|
||||
// ^
|
||||
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
|
||||
'
|
||||
// [error line 13, column 1, length 1]
|
||||
// [error column 1, length 1]
|
||||
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
|
||||
// [cfe] String starting with ' must end with '.
|
||||
r"
|
||||
@@ -20,7 +20,7 @@ main() {
|
||||
// ^
|
||||
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
|
||||
"
|
||||
// [error line 22, column 1, length 1]
|
||||
// [error column 1, length 1]
|
||||
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
|
||||
// [cfe] String starting with " must end with ".
|
||||
|
||||
@@ -35,7 +35,7 @@ main() {
|
||||
// ^
|
||||
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
|
||||
'
|
||||
// [error line 37, column 1, length 1]
|
||||
// [error column 1, length 1]
|
||||
// [analyzer] SYNTACTIC_ERROR.UNTERMINATED_STRING_LITERAL
|
||||
// [cfe] String starting with ' must end with '.
|
||||
'''
|
||||
|
||||
@@ -62,16 +62,18 @@ const interpolation1 =
|
||||
// (Single string, the linebreak to fit this into 80 chars is inside an
|
||||
// interpolation, which is allowed, even for single-line strings).
|
||||
const interpolation2 =
|
||||
"${u1} ${u2} ${u3} ${u4} ${u5} ${u6} ${n1} ${n2} ${n3} ${n4} ${n5} ${n6} ${
|
||||
s1} ${s2} ${s3} ${s4} ${b1} ${b2} ${b3} ${b4}";
|
||||
"${u1} ${u2} ${u3} ${u4} ${u5} ${u6} ${n1} ${n2} ${n3} ${n4} ${n5} ${n6} ${s1} ${s2} ${s3} ${s4} ${b1} ${b2} ${b3} ${b4}";
|
||||
// Adjacent string literals are combined.
|
||||
const interpolation3 = "$u1 $u2 $u3 $u4 $u5 "
|
||||
const interpolation3 =
|
||||
"$u1 $u2 $u3 $u4 $u5 "
|
||||
'$u6 $n1 $n2 $n3 $n4 '
|
||||
"""$n5 $n6 $s1 $s2 $s3 """
|
||||
'''$s4 $b1 $b2 $b3 $b4''';
|
||||
// Nested interpolations.
|
||||
const interpolation4 = "${"$u1 $u2 $u3 $u4 $u5 " '$u6 $n1 $n2 $n3 $n4'} ${
|
||||
"""$n5 $n6 $s1 $s2 $s3 """ '''$s4 $b1 $b2 $b3 $b4'''}";
|
||||
const interpolation4 =
|
||||
"${"$u1 $u2 $u3 $u4 $u5 "
|
||||
'$u6 $n1 $n2 $n3 $n4'} ${"""$n5 $n6 $s1 $s2 $s3 """
|
||||
'''$s4 $b1 $b2 $b3 $b4'''}";
|
||||
|
||||
main() {
|
||||
Expect.equals(u1.toString(), su1);
|
||||
@@ -94,7 +96,8 @@ main() {
|
||||
Expect.equals(b2.toString(), sb2);
|
||||
Expect.equals(b3.toString(), sb3);
|
||||
Expect.equals(b4.toString(), sb4);
|
||||
var expect = "null null null null null null 42 3.1415 37 4.6692 2.71828 87 "
|
||||
var expect =
|
||||
"null null null null null null 42 3.1415 37 4.6692 2.71828 87 "
|
||||
"s1 s2 s1s2 s4 true false false true";
|
||||
Expect.equals(expect, interpolation1);
|
||||
Expect.equals(expect, interpolation2);
|
||||
|
||||
@@ -9,7 +9,7 @@ class StringInterpolate2Test {
|
||||
static var F1;
|
||||
|
||||
static void testMain() {
|
||||
F1 = "1 + 5 = ${1+5}";
|
||||
F1 = "1 + 5 = ${1 + 5}";
|
||||
|
||||
Expect.equals("1 + 5 = 6", F1);
|
||||
|
||||
@@ -23,17 +23,14 @@ class StringInterpolate2Test {
|
||||
Expect.equals("fib(5) = 8", s);
|
||||
|
||||
i = 5;
|
||||
s = "$i squared is ${((x) => x*x)(i)}";
|
||||
s = "$i squared is ${((x) => x * x)(i)}";
|
||||
Expect.equals("5 squared is 25", s);
|
||||
|
||||
Expect.equals("8", "${fib.length}");
|
||||
// test single quote
|
||||
Expect.equals("8", '${fib.length}');
|
||||
// test multi-line
|
||||
Expect.equals(
|
||||
"8",
|
||||
'${fib.
|
||||
length}');
|
||||
Expect.equals("8", '${fib.length}');
|
||||
|
||||
var map = {"red": 1, "green": 2, "blue": 3};
|
||||
s = "green has value ${map["green"]}";
|
||||
@@ -46,8 +43,13 @@ class StringInterpolate2Test {
|
||||
|
||||
// test multiple levels of nesting, including changing quotes and
|
||||
// multiline string types
|
||||
s = "a ${(){ return 'b ${(){ return """
|
||||
c""";}()}'; }()} d";
|
||||
s =
|
||||
"a ${() {
|
||||
return 'b ${() {
|
||||
return """
|
||||
c""";
|
||||
}()}';
|
||||
}()} d";
|
||||
Expect.equals("a b c d", s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@ class WhatchamaCallIt {
|
||||
}
|
||||
|
||||
class ThingamaBob extends WhatchamaCallIt {
|
||||
ThingamaBob(String s)
|
||||
: name = s,
|
||||
super();
|
||||
ThingamaBob(String s) : name = s, super();
|
||||
String name;
|
||||
toString() => "Hansel";
|
||||
}
|
||||
@@ -78,159 +76,173 @@ void testStringVariants() {
|
||||
// ASCII.
|
||||
Expect.equals(latin * 3, "$latin$latin$latin");
|
||||
Expect.equals(
|
||||
latin * 64,
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin");
|
||||
latin * 64,
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin",
|
||||
);
|
||||
Expect.equals(
|
||||
latin * 64,
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}");
|
||||
latin * 64,
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}",
|
||||
);
|
||||
// Non-ASCII.
|
||||
Expect.equals(nonLatin * 3, "$nonLatin$nonLatin$nonLatin");
|
||||
Expect.equals(
|
||||
nonLatin * 64,
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin");
|
||||
nonLatin * 64,
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin",
|
||||
);
|
||||
Expect.equals(
|
||||
nonLatin * 64,
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}");
|
||||
nonLatin * 64,
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}"
|
||||
"${nonLatin * 4}${nonLatin * 4}",
|
||||
);
|
||||
// Mixed.
|
||||
Expect.equals(latin * 3 + nonLatin, "$latin$latin$latin$nonLatin");
|
||||
Expect.equals(nonLatin + latin * 3, "$nonLatin$latin$latin$latin");
|
||||
Expect.equals(
|
||||
latin * 60 + nonLatin * 4,
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin");
|
||||
latin * 60 + nonLatin * 4,
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin"
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin",
|
||||
);
|
||||
Expect.equals(
|
||||
nonLatin * 4 + latin * 60,
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin");
|
||||
nonLatin * 4 + latin * 60,
|
||||
"$nonLatin$nonLatin$nonLatin$nonLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$latin"
|
||||
"$latin$latin$latin$latin",
|
||||
);
|
||||
Expect.equals(
|
||||
latin * 60 + nonLatin * 4,
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${nonLatin * 4}");
|
||||
latin * 60 + nonLatin * 4,
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${nonLatin * 4}",
|
||||
);
|
||||
Expect.equals(
|
||||
nonLatin * 4 + latin * 60,
|
||||
"${nonLatin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}");
|
||||
nonLatin * 4 + latin * 60,
|
||||
"${nonLatin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${latin * 4}",
|
||||
);
|
||||
// With objects.
|
||||
Expect.equals(latin * 3, "$latin$oLatin$latin");
|
||||
Expect.equals(
|
||||
latin * 64,
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin");
|
||||
latin * 64,
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin"
|
||||
"$latin$latin$latin$latin$latin$latin$latin$oLatin",
|
||||
);
|
||||
Expect.equals(
|
||||
latin * 64,
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}");
|
||||
latin * 64,
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}"
|
||||
"${latin * 4}${latin * 4}${latin * 4}${oLatin * 4}",
|
||||
);
|
||||
// Non-ASCII.
|
||||
Expect.equals(nonLatin * 3, "$nonLatin$oNonLatin$nonLatin");
|
||||
Expect.equals(
|
||||
nonLatin * 64,
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin");
|
||||
nonLatin * 64,
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin"
|
||||
"$nonLatin$nonLatin$nonLatin$oNonLatin",
|
||||
);
|
||||
Expect.equals(
|
||||
nonLatin * 64,
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}");
|
||||
nonLatin * 64,
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}"
|
||||
"${nonLatin * 4}${oNonLatin * 4}",
|
||||
);
|
||||
// Mixed.
|
||||
Expect.equals(latin * 2 + nonLatin * 2, "$latin$oLatin$nonLatin$oNonLatin");
|
||||
Expect.equals(nonLatin * 2 + latin * 2, "$nonLatin$oNonLatin$latin$oLatin");
|
||||
Expect.equals(
|
||||
(latin * 2 + nonLatin * 2) * 8,
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin");
|
||||
(latin * 2 + nonLatin * 2) * 8,
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin"
|
||||
"$latin$oLatin$nonLatin$oNonLatin",
|
||||
);
|
||||
Expect.equals(
|
||||
(nonLatin * 2 + latin * 2) * 8,
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin");
|
||||
(nonLatin * 2 + latin * 2) * 8,
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin"
|
||||
"$nonLatin$oNonLatin$latin$oLatin",
|
||||
);
|
||||
|
||||
// All combinations
|
||||
var o1 = new Stringable("x");
|
||||
|
||||
@@ -15,9 +15,7 @@ class A {
|
||||
class StringInterpolation1NegativeTest {
|
||||
// Dollar not followed by "{" or identifier.
|
||||
|
||||
static testMain() {
|
||||
|
||||
}
|
||||
static testMain() {}
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
class StringInterpolation2NegativeTest {
|
||||
static testMain() {
|
||||
// Dollar followed by "/".
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
class StringInterpolation3NegativeTest {
|
||||
static testMain() {
|
||||
// Dollar followed by a number.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
class StringInterpolation4NegativeTest {
|
||||
static testMain() {
|
||||
// Dollar not followed by "{" or identifier.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
class StringInterpolation5NegativeTest {
|
||||
static testMain() {
|
||||
// Dollar followed by a number.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,29 +10,5 @@
|
||||
main() {
|
||||
var x;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -47,13 +47,23 @@ void main() {
|
||||
|
||||
// Throws immediately when adding object that doesn't return a String.
|
||||
Expect.equals(
|
||||
(StringBuffer()..write(s)..write(s)).toString(), "StringString");
|
||||
(StringBuffer()
|
||||
..write(s)
|
||||
..write(s))
|
||||
.toString(),
|
||||
"StringString",
|
||||
);
|
||||
Expect.throws<String>(
|
||||
() => StringBuffer()..write(t)..write(throw "unreachable"),
|
||||
(e) => e == "Throw");
|
||||
() => StringBuffer()
|
||||
..write(t)
|
||||
..write(throw "unreachable"),
|
||||
(e) => e == "Throw",
|
||||
);
|
||||
|
||||
// Same behavior for constructor argument as if adding it to buffer later.
|
||||
Expect.equals((StringBuffer(s)..write(s)).toString(), "StringString");
|
||||
Expect.throws<String>(
|
||||
() => StringBuffer(t)..write(throw "unreachable"), (e) => e == "Throw");
|
||||
() => StringBuffer(t)..write(throw "unreachable"),
|
||||
(e) => e == "Throw",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,24 @@
|
||||
|
||||
main() {
|
||||
String expected = '[[{{}: {}}]]';
|
||||
String a = "${ [ "${ [ '${ { '${ { } }' : { } } }' ] }" ] }";
|
||||
String b = "${ [ "${ [ '${ { '${
|
||||
{ } }' : { } } }' ] }" ] }";
|
||||
String c = "${ [ "${ [ '${ { '${
|
||||
{
|
||||
} }' : {
|
||||
} } }' ] }" ] }";
|
||||
String a =
|
||||
"${[
|
||||
"${[
|
||||
'${{'${{}}': {}}}',
|
||||
]}",
|
||||
]}";
|
||||
String b =
|
||||
"${[
|
||||
"${[
|
||||
'${{'${{}}': {}}}',
|
||||
]}",
|
||||
]}";
|
||||
String c =
|
||||
"${[
|
||||
"${[
|
||||
'${{'${{}}': {}}}',
|
||||
]}",
|
||||
]}";
|
||||
if (expected != a) throw 'expecteda: $expected != $a';
|
||||
if (a != b) throw 'ab: $a != $b';
|
||||
if (b != c) throw 'bc: $b != $c';
|
||||
|
||||
@@ -60,9 +60,7 @@ class StringInterpolationTest {
|
||||
Expect.equals("2", "escaped \${3+2}"[16]);
|
||||
Expect.equals("}", "escaped \${3+2}"[17]);
|
||||
|
||||
if (alwaysFalse) {
|
||||
|
||||
}
|
||||
if (alwaysFalse) {}
|
||||
|
||||
Expect.equals("${m}", "$m");
|
||||
}
|
||||
|
||||
@@ -5,8 +5,18 @@
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
var expect = new String.fromCharCodes(
|
||||
[0, 0x0a, 0x0d, 0x7f, 0xff, 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff]);
|
||||
var expect = new String.fromCharCodes([
|
||||
0,
|
||||
0x0a,
|
||||
0x0d,
|
||||
0x7f,
|
||||
0xff,
|
||||
0xffff,
|
||||
0xd800,
|
||||
0xdc00,
|
||||
0xdbff,
|
||||
0xdfff,
|
||||
]);
|
||||
test(string) {
|
||||
Expect.equals(expect, string);
|
||||
}
|
||||
@@ -27,12 +37,12 @@ main() {
|
||||
test('''\x00
|
||||
\x0d\x7f\xff\uffff\ud800\udc00\udbff\udfff''');
|
||||
// Extract code points from multi-character escape string.
|
||||
test("\x00\x0a\x0d\x7f\xff\uffff"
|
||||
"${"\u{10000}"[0]}${"\u{10000}"[1]}"
|
||||
"${"\u{10FFFF}"[0]}${"\u{10FFFF}"[1]}");
|
||||
test(
|
||||
"\x00\x0a\x0d\x7f\xff\uffff"
|
||||
"${"\u{10000}"[0]}${"\u{10000}"[1]}"
|
||||
"${"\u{10FFFF}"[0]}${"\u{10FFFF}"[1]}",
|
||||
);
|
||||
test("\x00\x0a\x0d\x7f\xff\uffff" + "\ud800" + "\udc00\udbff" + "\udfff");
|
||||
// Single line string over multiple lines with newlines inside interpolation.
|
||||
test("\x00\x0a\x0d\x7f\xff${
|
||||
""
|
||||
}\uffff\ud800\udc00\udbff\udfff");
|
||||
test("\x00\x0a\x0d\x7f\xff${""}\uffff\ud800\udc00\udbff\udfff");
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ const constantRawMultilineString = r"""
|
||||
var nonConstantRawMultilineString = r"""
|
||||
\a
|
||||
\b
|
||||
""";
|
||||
""";
|
||||
|
||||
@@ -40,18 +40,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -72,27 +81,15 @@ main() {
|
||||
const c4 = c1 == true ? 1 : 2;
|
||||
Expect.equals(1, c4);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -118,11 +115,4 @@ main() {
|
||||
// constants is similar to the runtime evaluation tested above. For tools
|
||||
// like the analyzer, this ensures that evaluation is tested (there's no
|
||||
// runtime evaluation).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,18 +40,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -69,30 +78,18 @@ main() {
|
||||
Expect.isTrue(c2r);
|
||||
Expect.isTrue(c3r);
|
||||
|
||||
|
||||
|
||||
|
||||
const c5 = c2 == true ? 2 : 3;
|
||||
Expect.equals(2, c5);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -118,11 +115,4 @@ main() {
|
||||
// constants is similar to the runtime evaluation tested above. For tools
|
||||
// like the analyzer, this ensures that evaluation is tested (there's no
|
||||
// runtime evaluation).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,18 +40,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -69,30 +78,18 @@ main() {
|
||||
Expect.isTrue(c2r);
|
||||
Expect.isTrue(c3r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c6 = c3 == true ? 3 : 4;
|
||||
Expect.equals(3, c6);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -118,11 +115,4 @@ main() {
|
||||
// constants is similar to the runtime evaluation tested above. For tools
|
||||
// like the analyzer, this ensures that evaluation is tested (there's no
|
||||
// runtime evaluation).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,18 +40,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -69,30 +78,18 @@ main() {
|
||||
Expect.isTrue(c2r);
|
||||
Expect.isTrue(c3r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c4r = c1r == true ? 1 : 2;
|
||||
Expect.equals(1, c4r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -118,11 +115,4 @@ main() {
|
||||
// constants is similar to the runtime evaluation tested above. For tools
|
||||
// like the analyzer, this ensures that evaluation is tested (there's no
|
||||
// runtime evaluation).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,18 +40,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -69,30 +78,18 @@ main() {
|
||||
Expect.isTrue(c2r);
|
||||
Expect.isTrue(c3r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c5r = c2r == true ? 2 : 3;
|
||||
Expect.equals(2, c5r);
|
||||
|
||||
|
||||
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -118,11 +115,4 @@ main() {
|
||||
// constants is similar to the runtime evaluation tested above. For tools
|
||||
// like the analyzer, this ensures that evaluation is tested (there's no
|
||||
// runtime evaluation).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,18 +40,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -69,30 +78,18 @@ main() {
|
||||
Expect.isTrue(c2r);
|
||||
Expect.isTrue(c3r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c6r = c3r == true ? 3 : 4;
|
||||
Expect.equals(3, c6r);
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -118,11 +115,4 @@ main() {
|
||||
// constants is similar to the runtime evaluation tested above. For tools
|
||||
// like the analyzer, this ensures that evaluation is tested (there's no
|
||||
// runtime evaluation).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,18 +40,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -69,30 +78,15 @@ main() {
|
||||
Expect.isTrue(c2r);
|
||||
Expect.isTrue(c3r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -118,11 +112,4 @@ main() {
|
||||
// constants is similar to the runtime evaluation tested above. For tools
|
||||
// like the analyzer, this ensures that evaluation is tested (there's no
|
||||
// runtime evaluation).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,18 +37,27 @@ main() {
|
||||
Expect.equals(lf.nonConstantMultilineString, cr.nonConstantMultilineString);
|
||||
|
||||
Expect.equals(
|
||||
cr.nonConstantRawMultilineString, crlf.nonConstantRawMultilineString);
|
||||
cr.nonConstantRawMultilineString,
|
||||
crlf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
crlf.nonConstantRawMultilineString, lf.nonConstantRawMultilineString);
|
||||
crlf.nonConstantRawMultilineString,
|
||||
lf.nonConstantRawMultilineString,
|
||||
);
|
||||
Expect.equals(
|
||||
lf.nonConstantRawMultilineString, cr.nonConstantRawMultilineString);
|
||||
lf.nonConstantRawMultilineString,
|
||||
cr.nonConstantRawMultilineString,
|
||||
);
|
||||
|
||||
const c1 =
|
||||
cr.constantMultilineString == crlf.constantMultilineString ? true : null;
|
||||
const c2 =
|
||||
crlf.constantMultilineString == lf.constantMultilineString ? true : null;
|
||||
const c3 =
|
||||
lf.constantMultilineString == cr.constantMultilineString ? true : null;
|
||||
const c1 = cr.constantMultilineString == crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c2 = crlf.constantMultilineString == lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c3 = lf.constantMultilineString == cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isTrue(c1);
|
||||
Expect.isTrue(c2);
|
||||
Expect.isTrue(c3);
|
||||
@@ -102,12 +111,15 @@ main() {
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
Expect.equals(3, c6r);
|
||||
|
||||
const c7 =
|
||||
cr.constantMultilineString != crlf.constantMultilineString ? true : null;
|
||||
const c8 =
|
||||
crlf.constantMultilineString != lf.constantMultilineString ? true : null;
|
||||
const c9 =
|
||||
lf.constantMultilineString != cr.constantMultilineString ? true : null;
|
||||
const c7 = cr.constantMultilineString != crlf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c8 = crlf.constantMultilineString != lf.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
const c9 = lf.constantMultilineString != cr.constantMultilineString
|
||||
? true
|
||||
: null;
|
||||
Expect.isNull(c7);
|
||||
Expect.isNull(c8);
|
||||
Expect.isNull(c9);
|
||||
@@ -136,38 +148,32 @@ main() {
|
||||
const c10 = c7 ? 1 : 2;
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
const c11 = c8 ? 2 : 3;
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
const c12 = c9 ? 3 : 4;
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
// ^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
|
||||
const c10r = c7r ? 1 : 2;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
const c11r = c8r ? 2 : 3;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
const c12r = c9r ? 3 : 4;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_TYPE_BOOL
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
||||
// [cfe] A value of type 'bool?' can't be assigned to a variable of type 'bool' because 'bool?' is nullable and 'bool' isn't.
|
||||
}
|
||||
|
||||
@@ -7,64 +7,40 @@
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
Expect.equals(
|
||||
'foo',
|
||||
'''
|
||||
Expect.equals('foo', '''
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'\\\nfoo',
|
||||
'''\\
|
||||
Expect.equals('\\\nfoo', '''\\
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'\t\nfoo',
|
||||
'''\t
|
||||
Expect.equals('\t\nfoo', '''\t
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'foo',
|
||||
'''\
|
||||
Expect.equals('foo', '''\
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'foo',
|
||||
'''\ \
|
||||
Expect.equals('foo', '''\ \
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
' \nfoo',
|
||||
'''\x20
|
||||
Expect.equals(' \nfoo', '''\x20
|
||||
foo''');
|
||||
|
||||
String x = ' ';
|
||||
Expect.equals(
|
||||
' \nfoo',
|
||||
'''$x
|
||||
Expect.equals(' \nfoo', '''$x
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'foo',
|
||||
r'''
|
||||
Expect.equals('foo', r'''
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'\\\\\nfoo',
|
||||
r'''\\
|
||||
Expect.equals('\\\\\nfoo', r'''\\
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'\\t\nfoo',
|
||||
r'''\t
|
||||
Expect.equals('\\t\nfoo', r'''\t
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'foo',
|
||||
r'''\
|
||||
Expect.equals('foo', r'''\
|
||||
foo''');
|
||||
|
||||
Expect.equals(
|
||||
'foo',
|
||||
r'''\ \
|
||||
Expect.equals('foo', r'''\ \
|
||||
foo''');
|
||||
}
|
||||
|
||||
@@ -10,20 +10,4 @@ import 'package:expect/expect.dart';
|
||||
main() {
|
||||
var x = "x";
|
||||
var y = "y";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,23 +15,15 @@ class RawStringTest {
|
||||
Expect.equals("", r'''''');
|
||||
Expect.equals("''''", r"''''");
|
||||
Expect.equals('""""', r'""""');
|
||||
Expect.equals(
|
||||
"1\n2\n3",
|
||||
r"""1
|
||||
Expect.equals("1\n2\n3", r"""1
|
||||
2
|
||||
3""");
|
||||
Expect.equals(
|
||||
"1\n2\n3",
|
||||
r'''1
|
||||
Expect.equals("1\n2\n3", r'''1
|
||||
2
|
||||
3''');
|
||||
Expect.equals(
|
||||
"1",
|
||||
r"""
|
||||
Expect.equals("1", r"""
|
||||
1""");
|
||||
Expect.equals(
|
||||
"1",
|
||||
r'''
|
||||
Expect.equals("1", r'''
|
||||
1''');
|
||||
Expect.equals("'", r"'");
|
||||
Expect.equals('"', r'"');
|
||||
@@ -41,10 +33,14 @@ class RawStringTest {
|
||||
Expect.equals("\\", r"\");
|
||||
Expect.equals("\\", r'\');
|
||||
Expect.equals("\${12}", r"${12}");
|
||||
Expect.equals("\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m",
|
||||
r"\a\b\c\d\e\f\g\h\i\j\k\l\m");
|
||||
Expect.equals("\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z",
|
||||
r"\n\o\p\q\r\s\t\u\v\w\x\y\z");
|
||||
Expect.equals(
|
||||
"\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m",
|
||||
r"\a\b\c\d\e\f\g\h\i\j\k\l\m",
|
||||
);
|
||||
Expect.equals(
|
||||
"\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z",
|
||||
r"\n\o\p\q\r\s\t\u\v\w\x\y\z",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ class StringTest {
|
||||
|
||||
static testNoSuchMethod() {
|
||||
String a = "Hello";
|
||||
|
||||
}
|
||||
|
||||
static testCharCodes() {
|
||||
|
||||
@@ -30,9 +30,9 @@ class StringTest {
|
||||
static testNoSuchMethod() {
|
||||
String a = "Hello";
|
||||
a[1] = 12;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
|
||||
// [cfe] The operator '[]=' isn't defined for the class 'String'.
|
||||
// [error column 6, length 3]
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
|
||||
// [cfe] The operator '[]=' isn't defined for the class 'String'.
|
||||
}
|
||||
|
||||
static testCharCodes() {
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
try {
|
||||
|
||||
|
||||
} on TypeError catch (e) {
|
||||
try {} on TypeError catch (e) {
|
||||
// OK.
|
||||
} on ArgumentError catch (e) {
|
||||
// OK.
|
||||
|
||||
@@ -18,5 +18,4 @@ class C extends A {
|
||||
main() {
|
||||
A a = new C();
|
||||
a.x = 37;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
A(
|
||||
|
||||
);
|
||||
A();
|
||||
final foo = 499;
|
||||
}
|
||||
|
||||
@@ -25,9 +23,7 @@ class B2 extends A {
|
||||
}
|
||||
|
||||
class C {
|
||||
C
|
||||
|
||||
();
|
||||
C();
|
||||
final foo = 499;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
A(this.x
|
||||
// ^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD
|
||||
// ^
|
||||
// [cfe] 'x' isn't an instance field of this class.
|
||||
);
|
||||
A(this.x);
|
||||
//^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD
|
||||
// ^
|
||||
// [cfe] 'x' isn't an instance field of this class.
|
||||
final foo = 499;
|
||||
}
|
||||
|
||||
@@ -23,13 +22,13 @@ class B extends A {}
|
||||
|
||||
class B2 extends A {
|
||||
B2();
|
||||
//^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS
|
||||
// [cfe] The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
// [error column 3, length 2]
|
||||
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS
|
||||
// [cfe] The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
B2.named() : this.x = 499;
|
||||
//^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS
|
||||
// [cfe] The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
// [error column 3, length 8]
|
||||
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_SUPER_INITIALIZER_MISSING_ARGUMENTS
|
||||
// [cfe] The implicitly called unnamed constructor from 'A' has required parameters.
|
||||
var x;
|
||||
}
|
||||
|
||||
@@ -45,13 +44,13 @@ class D extends C {}
|
||||
|
||||
class D2 extends C {
|
||||
D2();
|
||||
//^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
|
||||
// [cfe] The superclass, 'C', has no unnamed constructor that takes no arguments.
|
||||
// [error column 3, length 2]
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
|
||||
// [cfe] The superclass, 'C', has no unnamed constructor that takes no arguments.
|
||||
D2.named() : this.x = 499;
|
||||
//^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
|
||||
// [cfe] The superclass, 'C', has no unnamed constructor that takes no arguments.
|
||||
// [error column 3, length 2]
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER
|
||||
// [cfe] The superclass, 'C', has no unnamed constructor that takes no arguments.
|
||||
var x;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,29 +15,9 @@ class B {
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
C()
|
||||
C();
|
||||
|
||||
;
|
||||
|
||||
test() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
test() {}
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -15,12 +15,8 @@ class A {
|
||||
class B extends A {
|
||||
int foo;
|
||||
B.b1(x, this.foo) : super(x);
|
||||
B.b2(x, y)
|
||||
: this.foo = y,
|
||||
super(x);
|
||||
B.b3(x, y)
|
||||
: this.foo = y,
|
||||
super(x);
|
||||
B.b2(x, y) : this.foo = y, super(x);
|
||||
B.b3(x, y) : this.foo = y, super(x);
|
||||
|
||||
super$foo() => super.foo;
|
||||
sum() => foo + super.foo;
|
||||
|
||||
@@ -17,8 +17,6 @@ class A {
|
||||
|
||||
class B extends Object with A {
|
||||
noSuchMethod(im) => 87;
|
||||
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
@@ -15,9 +15,7 @@ class A {
|
||||
noSuchMethod(im) => 42;
|
||||
}
|
||||
|
||||
class B extends Object with A {
|
||||
|
||||
}
|
||||
class B extends Object with A {}
|
||||
|
||||
main() {
|
||||
Expect.equals(42, new B().foo());
|
||||
|
||||
@@ -46,7 +46,6 @@ class B extends A {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
var a = new A();
|
||||
a = a + "William"; // operator + of class A.
|
||||
|
||||
@@ -9,22 +9,26 @@ class Base {
|
||||
Base() {}
|
||||
String value_ = "";
|
||||
|
||||
String get value { return value_; }
|
||||
String get value {
|
||||
return value_;
|
||||
}
|
||||
|
||||
set value(String newValue) {
|
||||
value_ = 'Base:$newValue';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Derived extends Base {
|
||||
Derived() : super() {}
|
||||
|
||||
set value(String newValue) {
|
||||
super.value = 'Derived:$newValue';
|
||||
}
|
||||
String get value { return super.value; }
|
||||
}
|
||||
|
||||
String get value {
|
||||
return super.value;
|
||||
}
|
||||
}
|
||||
|
||||
class SuperSetterTest {
|
||||
static void testMain() {
|
||||
|
||||
@@ -28,15 +28,11 @@ main() {
|
||||
class Sup {
|
||||
var x, y, z;
|
||||
|
||||
Sup(a, b)
|
||||
: this.x = a,
|
||||
this.y = b {
|
||||
Sup(a, b) : this.x = a, this.y = b {
|
||||
z = a + b;
|
||||
}
|
||||
|
||||
Sup.stat()
|
||||
: this.x = i++,
|
||||
this.y = i++ {
|
||||
Sup.stat() : this.x = i++, this.y = i++ {
|
||||
z = i++;
|
||||
}
|
||||
}
|
||||
@@ -44,17 +40,11 @@ class Sup {
|
||||
class Sub extends Sup {
|
||||
var u, v, w;
|
||||
|
||||
Sub(a, b)
|
||||
: this.v = a,
|
||||
this.w = b,
|
||||
super(a, b) {
|
||||
Sub(a, b) : this.v = a, this.w = b, super(a, b) {
|
||||
u = a + b;
|
||||
}
|
||||
|
||||
Sub.stat()
|
||||
: this.v = i++,
|
||||
this.w = i++,
|
||||
super.stat() {
|
||||
Sub.stat() : this.v = i++, this.w = i++, super.stat() {
|
||||
u = i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ caesarSays(n) {
|
||||
archimedesSays(n) {
|
||||
switch (n) {
|
||||
case 3.14:
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '3.14' does not have a primitive operator '=='.
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '3.14' does not have a primitive operator '=='.
|
||||
return "Pi";
|
||||
case 2.71828:
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '2.71828' does not have a primitive operator '=='.
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '2.71828' does not have a primitive operator '=='.
|
||||
return "Huh?";
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -22,18 +22,10 @@ caesarSays(n) {
|
||||
return "I";
|
||||
case 4:
|
||||
return "IV";
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
archimedesSays(n) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -32,14 +32,14 @@ caesarSays(n) {
|
||||
archimedesSays(n) {
|
||||
switch (n) {
|
||||
case 3.14:
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '3.14' does not have a primitive operator '=='.
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '3.14' does not have a primitive operator '=='.
|
||||
return "Pi";
|
||||
case 2.71828:
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '2.71828' does not have a primitive operator '=='.
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// [cfe] Case expression '2.71828' does not have a primitive operator '=='.
|
||||
return "Huh?";
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
// Error was in pre-pattern case parsing.
|
||||
// @dart=2.19
|
||||
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
const ERROR_A = 0;
|
||||
|
||||
@@ -208,24 +208,24 @@ dynamic testSwitchWarn(int x) {
|
||||
}
|
||||
}
|
||||
case 10:
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
while (true) break; // Breaks loop, reaches end.
|
||||
case 11:
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
do break; while (true); // Breaks loop, reaches end.
|
||||
case 12:
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
for (;;) break; // Breaks loop, reaches end.
|
||||
case 13:
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
for (var _ in []) break LOOP; // Can be empty, reaches end.
|
||||
case 14:
|
||||
if (x.isEven) {
|
||||
@@ -236,23 +236,23 @@ dynamic testSwitchWarn(int x) {
|
||||
case 15:
|
||||
(throw 0); // Exits switch.
|
||||
case 16:
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
nop(x); // Reaches end.
|
||||
case 17:
|
||||
L:
|
||||
break; // Breaks and exits switch.
|
||||
case 18:
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [error column 9, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
L:
|
||||
break L; // Breaks break statement only, reaches end.
|
||||
case 19:
|
||||
// [error column 9, length 4]
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
// [error column 9, length 4]
|
||||
// [cfe] Switch case may fall through to the next case.
|
||||
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
|
||||
L:
|
||||
if (x.isOdd) {
|
||||
break L; // Breaks if, reaches end.
|
||||
@@ -264,26 +264,30 @@ dynamic testSwitchWarn(int x) {
|
||||
// with any pre-2.12 type.
|
||||
case 20:
|
||||
notEver(x); // Type Never implies not completing.
|
||||
case 21: {
|
||||
notEver(x);
|
||||
}
|
||||
case 22: {
|
||||
case 21:
|
||||
{
|
||||
notEver(x);
|
||||
}
|
||||
}
|
||||
case 23: {
|
||||
do {
|
||||
notEver(x);
|
||||
} while (true);
|
||||
}
|
||||
case 24: {
|
||||
if (x.isEven) {
|
||||
notEver(x);
|
||||
} else {
|
||||
notEver(-x);
|
||||
case 22:
|
||||
{
|
||||
{
|
||||
notEver(x);
|
||||
}
|
||||
}
|
||||
case 23:
|
||||
{
|
||||
do {
|
||||
notEver(x);
|
||||
} while (true);
|
||||
}
|
||||
case 24:
|
||||
{
|
||||
if (x.isEven) {
|
||||
notEver(x);
|
||||
} else {
|
||||
notEver(-x);
|
||||
}
|
||||
}
|
||||
}
|
||||
case 25:
|
||||
nop(x.isEven ? notEver(x) : notEver(-x));
|
||||
LAST:
|
||||
|
||||
@@ -191,26 +191,30 @@ dynamic testSwitch(int x) {
|
||||
}
|
||||
case 39:
|
||||
notEver(x); // Type Never implies not completing.
|
||||
case 40: {
|
||||
notEver(x);
|
||||
}
|
||||
case 41: {
|
||||
case 40:
|
||||
{
|
||||
notEver(x);
|
||||
}
|
||||
}
|
||||
case 42: {
|
||||
do {
|
||||
notEver(x);
|
||||
} while (true);
|
||||
}
|
||||
case 43: {
|
||||
if (x.isEven) {
|
||||
notEver(x);
|
||||
} else {
|
||||
notEver(-x);
|
||||
case 41:
|
||||
{
|
||||
{
|
||||
notEver(x);
|
||||
}
|
||||
}
|
||||
case 42:
|
||||
{
|
||||
do {
|
||||
notEver(x);
|
||||
} while (true);
|
||||
}
|
||||
case 43:
|
||||
{
|
||||
if (x.isEven) {
|
||||
notEver(x);
|
||||
} else {
|
||||
notEver(-x);
|
||||
}
|
||||
}
|
||||
}
|
||||
case 44:
|
||||
nop(x.isEven ? notEver(x) : notEver(-x));
|
||||
LAST:
|
||||
|
||||
@@ -32,11 +32,13 @@ class D implements A {
|
||||
|
||||
main() {
|
||||
switch (new B()) {
|
||||
case const A.B() as B: Expect.fail("bad switch"); break;
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
case const A.B() as B:
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (new C()) {
|
||||
@@ -49,21 +51,25 @@ main() {
|
||||
case const A.C2() as C:
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
case const A(): Expect.fail("bad switch"); break;
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE
|
||||
// ^
|
||||
// [cfe] Type 'A' of the case expression is not a subtype of type 'C' of this switch expression.
|
||||
case const A():
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE
|
||||
// ^
|
||||
// [cfe] Type 'A' of the case expression is not a subtype of type 'C' of this switch expression.
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (new A()) {
|
||||
case const A():
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
case const A.B(): Expect.fail("bad switch"); break;
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
case const A.B():
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,13 @@ class D implements A {
|
||||
|
||||
main() {
|
||||
switch (new B()) {
|
||||
case const A.B() as B: Expect.fail("bad switch"); break;
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
case const A.B() as B:
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (new C()) {
|
||||
@@ -50,21 +52,25 @@ main() {
|
||||
case const A.C2() as C:
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
case const A(): Expect.fail("bad switch"); break;
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE
|
||||
// ^
|
||||
// [cfe] Type 'A' of the case expression is not a subtype of type 'C' of this switch expression.
|
||||
case const A():
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE
|
||||
// ^
|
||||
// [cfe] Type 'A' of the case expression is not a subtype of type 'C' of this switch expression.
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (new A()) {
|
||||
case const A():
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
case const A.B(): Expect.fail("bad switch"); break;
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
case const A.B():
|
||||
// ^^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
|
||||
// ^
|
||||
// [cfe] Case expression 'B {}' does not have a primitive operator '=='.
|
||||
Expect.fail("bad switch");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ main() {
|
||||
case 1:
|
||||
x = 1;
|
||||
continue L;
|
||||
// ^
|
||||
// [cfe] Can't find label 'L'.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.LABEL_UNDEFINED
|
||||
//^
|
||||
// [cfe] Can't find label 'L'.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.LABEL_UNDEFINED
|
||||
case 6:
|
||||
x = 2;
|
||||
break;
|
||||
|
||||
@@ -15,9 +15,9 @@ main() {
|
||||
case 6:
|
||||
x = 2;
|
||||
break L;
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.BREAK_LABEL_ON_SWITCH_MEMBER
|
||||
// [cfe] Can't break to 'L'.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.BREAK_LABEL_ON_SWITCH_MEMBER
|
||||
// [cfe] Can't break to 'L'.
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ main() {
|
||||
L:
|
||||
case 1: // Shadowing another label is OK.
|
||||
break L; // Illegal, can't reference labeled case from break.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.BREAK_LABEL_ON_SWITCH_MEMBER
|
||||
// [cfe] Can't break to 'L'.
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.BREAK_LABEL_ON_SWITCH_MEMBER
|
||||
// [cfe] Can't break to 'L'.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,5 +47,4 @@ main() {
|
||||
Expect.equals(1, m[#B]);
|
||||
|
||||
// Tries to call the symbol literal #a.toString
|
||||
|
||||
}
|
||||
|
||||
@@ -47,5 +47,4 @@ main() {
|
||||
Expect.equals(1, m[#B]);
|
||||
|
||||
// Tries to call the symbol literal #a.toString
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ einsZwei() sync* {
|
||||
|
||||
dreiVier() sync* {
|
||||
// Throws type error: yielded object is not an iterable.
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
@@ -84,7 +83,5 @@ main() {
|
||||
|
||||
print(einsZwei());
|
||||
Expect.equals("(1, 2, 3, 5, [6])", einsZwei().toString());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,9 @@ main() {
|
||||
Expect.isTrue(iterator.moveNext());
|
||||
Expect.equals(100, iterator.current);
|
||||
Expect.equals(
|
||||
'[main.f2.p.y*1][main.f2.p.f1.a][main.f2.catch:iterator@main.f2.p.f1.a]',
|
||||
log);
|
||||
'[main.f2.p.y*1][main.f2.p.f1.a][main.f2.catch:iterator@main.f2.p.f1.a]',
|
||||
log,
|
||||
);
|
||||
log = '';
|
||||
Expect.isFalse(iterator.moveNext());
|
||||
Expect.equals('[main.f2.done]', log);
|
||||
@@ -101,7 +102,9 @@ main() {
|
||||
final iterator = f3('main').iterator;
|
||||
Expect.isFalse(iterator.moveNext());
|
||||
Expect.equals(
|
||||
'[main.f3.f][main.f3.catch:iterator@main.f3.f][main.f3.done]', log);
|
||||
'[main.f3.f][main.f3.catch:iterator@main.f3.f][main.f3.done]',
|
||||
log,
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -110,11 +113,12 @@ main() {
|
||||
Expect.isTrue(iterator.moveNext());
|
||||
Expect.equals(200, iterator.current);
|
||||
Expect.equals(
|
||||
'[M.f4.s.y*1]'
|
||||
'[M.f4.s.f3.f][M.f4.s.f3.catch:iterator@M.f4.s.f3.f][M.f4.s.f3.done]'
|
||||
'[M.f4.s.y*2]'
|
||||
'[M.f4.t.f3.f][M.f4.t.f3.catch:iterator@M.f4.t.f3.f][M.f4.t.f3.done]',
|
||||
log);
|
||||
'[M.f4.s.y*1]'
|
||||
'[M.f4.s.f3.f][M.f4.s.f3.catch:iterator@M.f4.s.f3.f][M.f4.s.f3.done]'
|
||||
'[M.f4.s.y*2]'
|
||||
'[M.f4.t.f3.f][M.f4.t.f3.catch:iterator@M.f4.t.f3.f][M.f4.t.f3.done]',
|
||||
log,
|
||||
);
|
||||
log = '';
|
||||
Expect.isFalse(iterator.moveNext());
|
||||
Expect.equals('[M.f4.done]', log);
|
||||
|
||||
@@ -4,31 +4,35 @@
|
||||
|
||||
// It is an error for a `sync*` function to have return type `void`.
|
||||
|
||||
/*space*/ void f1() sync* {
|
||||
// ^^^^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
void f1() sync* {
|
||||
// [error column 1, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
|
||||
// ^
|
||||
// [cfe] Functions marked 'sync*' can't have return type 'void'.
|
||||
}
|
||||
|
||||
class C {
|
||||
static void f2() sync* {
|
||||
// ^^^^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
|
||||
// ^
|
||||
// [cfe] Functions marked 'sync*' can't have return type 'void'.
|
||||
}
|
||||
|
||||
/*space*/ void f3() sync* {
|
||||
// ^^^^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
void f3() sync* {
|
||||
// [error column 3, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
|
||||
// ^
|
||||
// [cfe] Functions marked 'sync*' can't have return type 'void'.
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
/*space*/ void f4() sync* {
|
||||
// ^^^^
|
||||
// [analyzer] unspecified
|
||||
// [cfe] unspecified
|
||||
void f4() sync* {
|
||||
// [error column 3, length 4]
|
||||
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE
|
||||
// ^
|
||||
// [cfe] Functions marked 'sync*' can't have return type 'void'.
|
||||
}
|
||||
|
||||
// No function literal: It is probably not possible to infer the
|
||||
|
||||
@@ -14,14 +14,17 @@ main() {
|
||||
var c = new Completer();
|
||||
var s = yieldStream(mkStream());
|
||||
var sub;
|
||||
sub = s.listen((v) {
|
||||
sub.pause();
|
||||
print(v);
|
||||
Timer.run(sub.resume);
|
||||
}, onDone: () {
|
||||
print("DONE");
|
||||
c.complete(null);
|
||||
});
|
||||
sub = s.listen(
|
||||
(v) {
|
||||
sub.pause();
|
||||
print(v);
|
||||
Timer.run(sub.resume);
|
||||
},
|
||||
onDone: () {
|
||||
print("DONE");
|
||||
c.complete(null);
|
||||
},
|
||||
);
|
||||
return c.future;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class StatementTest {
|
||||
Expect.equals(5, count);
|
||||
|
||||
// For loop with no test.
|
||||
for (count = 0;; ++count) {
|
||||
for (count = 0; ; ++count) {
|
||||
if (count == 10) {
|
||||
break;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ class StatementTest {
|
||||
var ints = [
|
||||
[32, 87, 3, 589],
|
||||
[12, 1076, 2000, 8],
|
||||
[622, 127, 77, 955]
|
||||
[622, 127, 77, 955],
|
||||
];
|
||||
int i, j = 0;
|
||||
bool foundIt = false;
|
||||
|
||||
@@ -32,9 +32,9 @@ class _JSON native 'JSON' {}
|
||||
// [cfe] expect cfe to report an error here
|
||||
|
||||
class ListFactory<E> implements List<E> native "Array" {
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
noSuchMethod(_) => null; // Allow unimplemented methods
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user