From 51bc5451356e6e7f4f344500708e717586dbdf95 Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Tue, 28 Feb 2023 01:34:26 +0000 Subject: [PATCH] Switch cases are no longer const contexts with patterns. But there is a new "const expression" pattern syntax that does introduce a const context, so test that here instead. Change-Id: Iaf615093c3d2fb32065fa8647bf3663118b0c274 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285761 Commit-Queue: Bob Nystrom Reviewed-by: Jake Macdonald Auto-Submit: Bob Nystrom --- ...plicit_const_context_constructor_generic_named_test.dart | 6 +++--- .../implicit_const_context_constructor_generic_test.dart | 6 ++++-- .../implicit_const_context_constructor_named_test.dart | 6 ++++-- .../implicit_const_context_constructor_test.dart | 6 ++++-- .../implicit_creation/implicit_const_context_list_test.dart | 6 ++++-- .../implicit_creation/implicit_const_context_map_test.dart | 6 ++++-- ...const_context_prefix_constructor_generic_named_test.dart | 6 +++--- ...licit_const_context_prefix_constructor_generic_test.dart | 6 ++++-- ...mplicit_const_context_prefix_constructor_named_test.dart | 6 +++--- .../implicit_const_context_prefix_constructor_test.dart | 6 ++++-- 10 files changed, 37 insertions(+), 23 deletions(-) diff --git a/tests/language/implicit_creation/implicit_const_context_constructor_generic_named_test.dart b/tests/language/implicit_creation/implicit_const_context_constructor_generic_named_test.dart index c91a531dece..ea39717bf34 100644 --- a/tests/language/implicit_creation/implicit_const_context_constructor_generic_named_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_constructor_generic_named_test.dart @@ -2,7 +2,7 @@ // 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. -// SharedOptions=--enable-experiment=patterns +// SharedOptions=--enable-experiment=patterns,records import "package:expect/expect.dart"; @@ -40,9 +40,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case const C.named(42): break; + case const (C.named(42)): break; default: Expect.fail("Didn't match constant"); } diff --git a/tests/language/implicit_creation/implicit_const_context_constructor_generic_test.dart b/tests/language/implicit_creation/implicit_const_context_constructor_generic_test.dart index ffeb1fea861..9dc28f9facb 100644 --- a/tests/language/implicit_creation/implicit_const_context_constructor_generic_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_constructor_generic_test.dart @@ -2,6 +2,8 @@ // 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. +// SharedOptions=--enable-experiment=patterns,records + import "package:expect/expect.dart"; // Test that constructor invocations are constant @@ -38,9 +40,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case C(42): + case const (C(42)): break; default: Expect.fail("Didn't match constant"); diff --git a/tests/language/implicit_creation/implicit_const_context_constructor_named_test.dart b/tests/language/implicit_creation/implicit_const_context_constructor_named_test.dart index 16345ab436c..96c40935424 100644 --- a/tests/language/implicit_creation/implicit_const_context_constructor_named_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_constructor_named_test.dart @@ -2,6 +2,8 @@ // 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. +// SharedOptions=--enable-experiment=patterns,records + import "package:expect/expect.dart"; // Test that constructor invocations are constant @@ -38,9 +40,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case C.named(42): + case const (C.named(42)): break; default: Expect.fail("Didn't match constant"); diff --git a/tests/language/implicit_creation/implicit_const_context_constructor_test.dart b/tests/language/implicit_creation/implicit_const_context_constructor_test.dart index fec39c2fa9c..cdfe7177bb6 100644 --- a/tests/language/implicit_creation/implicit_const_context_constructor_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_constructor_test.dart @@ -2,6 +2,8 @@ // 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. +// SharedOptions=--enable-experiment=patterns,records + import "package:expect/expect.dart"; // Test that constructor invocations are constant @@ -38,9 +40,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case C(42): + case const (C(42)): break; default: Expect.fail("Didn't match constant"); diff --git a/tests/language/implicit_creation/implicit_const_context_list_test.dart b/tests/language/implicit_creation/implicit_const_context_list_test.dart index c089d35521d..0ccead59230 100644 --- a/tests/language/implicit_creation/implicit_const_context_list_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_list_test.dart @@ -2,6 +2,8 @@ // 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. +// SharedOptions=--enable-experiment=patterns,records + import "package:expect/expect.dart"; // Test that list literals are constant when evaluated in a const context. @@ -47,9 +49,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case [42]: + case const ([42]): break; default: Expect.fail("Didn't match constant"); diff --git a/tests/language/implicit_creation/implicit_const_context_map_test.dart b/tests/language/implicit_creation/implicit_const_context_map_test.dart index 231bfc379e7..cc53df61e6c 100644 --- a/tests/language/implicit_creation/implicit_const_context_map_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_map_test.dart @@ -2,6 +2,8 @@ // 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. +// SharedOptions=--enable-experiment=patterns,records + import "package:expect/expect.dart"; // Test that map literals are constant when evaluated in a const context. @@ -47,9 +49,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case {37: 87}: + case const ({37: 87}): break; default: Expect.fail("Didn't match constant"); diff --git a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_named_test.dart b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_named_test.dart index 6025fac9bd0..ff64a7c9820 100644 --- a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_named_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_named_test.dart @@ -2,7 +2,7 @@ // 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. -// SharedOptions=--enable-experiment=patterns +// SharedOptions=--enable-experiment=patterns,records import "package:expect/expect.dart"; @@ -43,9 +43,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case const prefix.C.named(42): break; + case const (prefix.C.named(42)): break; default: Expect.fail("Didn't match constant"); } diff --git a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_test.dart b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_test.dart index e86289f040e..e63bd6055ba 100644 --- a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_generic_test.dart @@ -2,6 +2,8 @@ // 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. +// SharedOptions=--enable-experiment=patterns,records + import "package:expect/expect.dart"; import "implicit_const_context_prefix_constructor_generic_test.dart" as prefix; @@ -40,9 +42,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case prefix.C(42): + case const (prefix.C(42)): break; default: Expect.fail("Didn't match constant"); diff --git a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_named_test.dart b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_named_test.dart index 979caf4d257..345c168bede 100644 --- a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_named_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_named_test.dart @@ -2,7 +2,7 @@ // 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. -// SharedOptions=--enable-experiment=patterns +// SharedOptions=--enable-experiment=patterns,records import "package:expect/expect.dart"; @@ -42,9 +42,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case const prefix.C.named(42): + case const (prefix.C.named(42)): break; default: Expect.fail("Didn't match constant"); diff --git a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_test.dart b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_test.dart index cfd8fd1b023..f911e01a167 100644 --- a/tests/language/implicit_creation/implicit_const_context_prefix_constructor_test.dart +++ b/tests/language/implicit_creation/implicit_const_context_prefix_constructor_test.dart @@ -2,6 +2,8 @@ // 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. +// SharedOptions=--enable-experiment=patterns,records + import "package:expect/expect.dart"; import "implicit_const_context_prefix_constructor_test.dart" as prefix; @@ -40,9 +42,9 @@ main() { Expect.identical(c0, C.staticConst); Expect.identical(c0, topConst); - // Switch case expression. + // Switch case parenthesized const expression. switch (c0) { - case prefix.C(42): + case const (prefix.C(42)): break; default: Expect.fail("Didn't match constant");