Files
sdk/pkg/front_end/testcases/patterns/simple_runtime_test.dart
T
Chloe Stefantsova 1f55c4ce32 [cfe] Add desugaring of non-matching rest pattern
Closes https://github.com/dart-lang/sdk/issues/50797

Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: Ide77d1ee262f8778de7eb8743b04508ee290ee10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276940
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-12-22 11:25:05 +00:00

28 lines
684 B
Dart

// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// 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.
test(dynamic x) {
if (x case [String y]) {
return y;
} else {
return null;
}
}
main() {
expectEquals(test(["one", "two", "three"]), null);
expectEquals(test(["one"]), "one");
expectEquals(test([1, 2, 3]), null);
expectEquals(test([1]), null);
expectEquals(test([true, false]), null);
expectEquals(test([true]), null);
expectEquals(test([]), null);
}
expectEquals(x, y) {
if (x != y) {
throw "Expected $x to be equal to $y.";
}
}