c9d54c12f6
Change-Id: I3c5cfbc1bc5e41d2ef1598427067dea00f9f42b4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425403 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
57 lines
1.1 KiB
Dart
57 lines
1.1 KiB
Dart
// Copyright (c) 2019, 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.
|
|
|
|
// Tests syntax edge cases.
|
|
import 'package:expect/expect.dart';
|
|
|
|
void main() {
|
|
// Trailing comma.
|
|
Expect.listEquals(
|
|
[1, 2],
|
|
[
|
|
...[1, 2],
|
|
],
|
|
);
|
|
Expect.mapEquals(
|
|
{1: 1, 2: 2},
|
|
{
|
|
...{1: 1, 2: 2},
|
|
},
|
|
);
|
|
Expect.setEquals(
|
|
{1, 2},
|
|
{
|
|
...{1, 2},
|
|
},
|
|
);
|
|
|
|
// Precedence.
|
|
Expect.listEquals(
|
|
[1, 2, 3],
|
|
[
|
|
1,
|
|
...true ? [2] : [],
|
|
3,
|
|
],
|
|
);
|
|
Expect.listEquals([1, 3], [1, ...?true ? null : [], 3]);
|
|
|
|
var a = [0];
|
|
Expect.listEquals(
|
|
[1, 2, 3],
|
|
[
|
|
1,
|
|
...a = [2],
|
|
3,
|
|
],
|
|
);
|
|
var nullableA = [0] as List<int>?;
|
|
Expect.listEquals([1, 3], [1, ...?nullableA = null, 3]);
|
|
|
|
var b = [2];
|
|
Expect.listEquals([1, 2, 3, 4], [1, ...b..add(3), 4]);
|
|
var nullableB = [2] as List<int>?;
|
|
Expect.listEquals([1, 2, 3, 4], [1, ...?nullableB?..add(3), 4]);
|
|
}
|