mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:27:17 +00:00
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 <rnystrom@google.com> Reviewed-by: Jake Macdonald <jakemac@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
3af33c1ffb
commit
51bc545135
|
@ -2,7 +2,7 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// 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";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case const C<int>.named(42): break;
|
case const (C<int>.named(42)): break;
|
||||||
default: Expect.fail("Didn't match constant");
|
default: Expect.fail("Didn't match constant");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// SharedOptions=--enable-experiment=patterns,records
|
||||||
|
|
||||||
import "package:expect/expect.dart";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
// Test that constructor invocations are constant
|
// Test that constructor invocations are constant
|
||||||
|
@ -38,9 +40,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case C<int>(42):
|
case const (C<int>(42)):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// SharedOptions=--enable-experiment=patterns,records
|
||||||
|
|
||||||
import "package:expect/expect.dart";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
// Test that constructor invocations are constant
|
// Test that constructor invocations are constant
|
||||||
|
@ -38,9 +40,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case C.named(42):
|
case const (C.named(42)):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// SharedOptions=--enable-experiment=patterns,records
|
||||||
|
|
||||||
import "package:expect/expect.dart";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
// Test that constructor invocations are constant
|
// Test that constructor invocations are constant
|
||||||
|
@ -38,9 +40,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case C(42):
|
case const (C(42)):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// SharedOptions=--enable-experiment=patterns,records
|
||||||
|
|
||||||
import "package:expect/expect.dart";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
// Test that list literals are constant when evaluated in a const context.
|
// 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, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case <int>[42]:
|
case const (<int>[42]):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// SharedOptions=--enable-experiment=patterns,records
|
||||||
|
|
||||||
import "package:expect/expect.dart";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
// Test that map literals are constant when evaluated in a const context.
|
// 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, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case <int, int>{37: 87}:
|
case const (<int, int>{37: 87}):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// 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";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case const prefix.C<int>.named(42): break;
|
case const (prefix.C<int>.named(42)): break;
|
||||||
default: Expect.fail("Didn't match constant");
|
default: Expect.fail("Didn't match constant");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// SharedOptions=--enable-experiment=patterns,records
|
||||||
|
|
||||||
import "package:expect/expect.dart";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
import "implicit_const_context_prefix_constructor_generic_test.dart" as prefix;
|
import "implicit_const_context_prefix_constructor_generic_test.dart" as prefix;
|
||||||
|
@ -40,9 +42,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case prefix.C<int>(42):
|
case const (prefix.C<int>(42)):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// 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";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case const prefix.C.named(42):
|
case const (prefix.C.named(42)):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// for details. All rights reserved. Use of this source code is governed by a
|
// 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.
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// SharedOptions=--enable-experiment=patterns,records
|
||||||
|
|
||||||
import "package:expect/expect.dart";
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
import "implicit_const_context_prefix_constructor_test.dart" as prefix;
|
import "implicit_const_context_prefix_constructor_test.dart" as prefix;
|
||||||
|
@ -40,9 +42,9 @@ main() {
|
||||||
Expect.identical(c0, C.staticConst);
|
Expect.identical(c0, C.staticConst);
|
||||||
Expect.identical(c0, topConst);
|
Expect.identical(c0, topConst);
|
||||||
|
|
||||||
// Switch case expression.
|
// Switch case parenthesized const expression.
|
||||||
switch (c0) {
|
switch (c0) {
|
||||||
case prefix.C(42):
|
case const (prefix.C(42)):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Expect.fail("Didn't match constant");
|
Expect.fail("Didn't match constant");
|
||||||
|
|
Loading…
Reference in a new issue