mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:49:43 +00:00
Adjust symbol tests to new semantics
Cf. https://github.com/dart-lang/sdk/issues/46207, the semantics of the platform class `Symbol` was changed such that all string argumnts are accepted (previously, only some strings were accepted). Change-Id: I1d2b093e4fdbb5dabf17b7a53c70e9787a7a76a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205480 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Erik Ernst <eernst@google.com>
This commit is contained in:
parent
7e3b17f9dc
commit
166d474257
|
@ -28,14 +28,14 @@ main() {
|
|||
testSymbol(#[]=, ($[$] = $).lastMember, "[]=");
|
||||
testSymbol(Symbol.unaryMinus, -$, "unary-");
|
||||
|
||||
testSymbolThrows(">>>"); // //# 03: ok
|
||||
testSymbolThrows("!"); // //# 03: continued
|
||||
testSymbolThrows("&&"); // //# 03: continued
|
||||
testSymbolThrows("||"); // //# 03: continued
|
||||
testSymbolThrows("?"); // //# 03: continued
|
||||
testSymbolThrows("?:"); // //# 03: continued
|
||||
testSymbolThrows("#"); // //# 03: continued
|
||||
testSymbolThrows("//"); // //# 03: continued
|
||||
testSymbolNotInstanceOperator(">>>");
|
||||
testSymbolNotInstanceOperator("!");
|
||||
testSymbolNotInstanceOperator("&&");
|
||||
testSymbolNotInstanceOperator("||");
|
||||
testSymbolNotInstanceOperator("?");
|
||||
testSymbolNotInstanceOperator("?:");
|
||||
testSymbolNotInstanceOperator("#");
|
||||
testSymbolNotInstanceOperator("//");
|
||||
}
|
||||
|
||||
void testSymbol(Symbol constSymbol, var mirrorSymbol, String name) {
|
||||
|
@ -63,16 +63,8 @@ void testSymbol(Symbol constSymbol, var mirrorSymbol, String name) {
|
|||
}
|
||||
}
|
||||
|
||||
void testSymbolThrows(name) {
|
||||
bool fails = false;
|
||||
try {
|
||||
new Symbol(name);
|
||||
} catch (e) {
|
||||
fails = true;
|
||||
}
|
||||
if (!fails) {
|
||||
throw "Didn't throw: $name";
|
||||
}
|
||||
void testSymbolNotInstanceOperator(name) {
|
||||
new Symbol(name);
|
||||
}
|
||||
|
||||
class Symbolize {
|
||||
|
|
|
@ -15,31 +15,10 @@ main() {
|
|||
print('Caught TypeError');
|
||||
}
|
||||
|
||||
try {
|
||||
print(const Symbol('0')); //# 02: compile-time error
|
||||
} on ArgumentError catch (e) {
|
||||
print('Caught $e');
|
||||
}
|
||||
|
||||
try {
|
||||
print(const Symbol('_')); //# 03: compile-time error
|
||||
} on ArgumentError catch (e) {
|
||||
print('Caught $e');
|
||||
}
|
||||
|
||||
try {
|
||||
print(new Symbol('0'));
|
||||
throw 'Expected an ArgumentError';
|
||||
} on ArgumentError catch (e) {
|
||||
print('Caught $e');
|
||||
}
|
||||
|
||||
try {
|
||||
print(new Symbol('_'));
|
||||
throw 'Expected an ArgumentError';
|
||||
} on ArgumentError catch (e) {
|
||||
print('Caught $e');
|
||||
}
|
||||
print(const Symbol('0'));
|
||||
print(const Symbol('_'));
|
||||
print(new Symbol('0'));
|
||||
print(new Symbol('_'));
|
||||
|
||||
if (!identical(const Symbol('fisk'), x)) {
|
||||
throw 'Symbol constant is not canonicalized';
|
||||
|
|
Loading…
Reference in a new issue