Skip to content

Commit 7051c17

Browse files
authored
#1399. [Records] More members tests added (#1501)
1 parent 0612637 commit 7051c17

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion A record type declares all of the members defined on [Object]. It
6+
/// also exposes getters for each named field where the name of the getter is
7+
/// the field's name and the getter's type is the field's type. For each
8+
/// positional field, it exposes a getter whose name is $ followed by the number
9+
/// of preceding positional fields and whose type is the type of the field.
10+
///
11+
/// @description Check that '$' can be used as a member name
12+
/// @author [email protected]
13+
14+
// SharedOptions=--enable-experiment=records
15+
16+
import "../../Utils/expect.dart";
17+
18+
main() {
19+
({String $}) r1 = ($: "x");
20+
Expect.equals("x", r1.$);
21+
22+
(int $,) r2 = (1,);
23+
Expect.equals(1, r2.$0);
24+
}

LanguageFeatures/Records/members_A03_t04.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ main() {
2828
r1.$42;
2929
// ^^^
3030
// [analyzer] unspecified
31+
// [cfe] unspecified
32+
33+
r1.$10000000000000000000000000;
34+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
35+
// [analyzer] unspecified
3136
// [cfe] unspecified
3237

3338
(3, 1, 4, name: "pi").$3;

0 commit comments

Comments
 (0)