From c89ec96b9683f92b5b70f9129acc958a32d5286e Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Thu, 23 Mar 2023 22:47:49 +0000 Subject: [PATCH] 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 Auto-Submit: Bob Nystrom Commit-Queue: Nicholas Shahan Reviewed-by: Nicholas Shahan --- tests/language/patterns/int_to_double_test.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/language/patterns/int_to_double_test.dart b/tests/language/patterns/int_to_double_test.dart index 96010c60ce0..c8382faf5cf 100644 --- a/tests/language/patterns/int_to_double_test.dart +++ b/tests/language/patterns/int_to_double_test.dart @@ -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 `[123]`, + // which is not matched by `List _`. + if ([123] case List _) { Expect.fail('Should not have matched.'); } else { // OK. } // No coercion on switch statement value. - switch (123) { - case double d: + switch ([123]) { + case List _: 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 _ => 'wrong', _ => 'ok' }; Expect.equals('ok', result); }