Fix int-to-double test to work on the web.

Change-Id: I5e208edc53543de8d11aa6e81072ad7f61a23d52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290913
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Robert Nystrom 2023-03-23 22:47:49 +00:00 committed by Commit Queue
parent 7c6f6d6232
commit c89ec96b96

View file

@ -31,23 +31,25 @@ main() {
Expect.fail('Should have matched.');
}
// No coercion on if-case value.
if (123 case double d) {
// No coercion on if-case value. There should be no context type on the value
// from the pattern, and thus `[123]` should be inferred as `<int>[123]`,
// which is not matched by `List<double> _`.
if ([123] case List<double> _) {
Expect.fail('Should not have matched.');
} else {
// OK.
}
// No coercion on switch statement value.
switch (123) {
case double d:
switch ([123]) {
case List<double> _:
Expect.fail('Should not have matched.');
default:
// OK.
}
// No coercion on switch expression value.
var result = switch (123) { double d => 'wrong', _ => 'ok' };
var result = switch ([123]) { List<double> _ => 'wrong', _ => 'ok' };
Expect.equals('ok', result);
}