Test for Expression.inConstantContext when the expression is RecordLiteral.

Change-Id: I1330b966296e9521bdb0d5e576cd1a63f2c5fbdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260077
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-09-20 21:31:35 +00:00 committed by Commit Bot
parent 141556c15f
commit 1ad52e061a

View file

@ -580,6 +580,48 @@ f(v) {
''');
assertInContext("{}", true);
}
test_inConstantContext_recordLiteral_listLiteral_false() {
parse('''
final x = [0, (1, 2)];
''');
assertInContext('(1, 2)', false);
}
test_inConstantContext_recordLiteral_listLiteral_true() {
parse('''
final x = const [0, (1, 2)];
''');
assertInContext('(1, 2)', true);
}
test_inConstantContext_recordLiteral_namedFields_recordLiteral_false() {
parse('''
final x = (0, foo: (1, 2));
''');
assertInContext('(1, 2)', false);
}
test_inConstantContext_recordLiteral_namedFields_recordLiteral_true() {
parse('''
final x = const (0, foo: (1, 2));
''');
assertInContext('(1, 2)', true);
}
test_inConstantContext_recordLiteral_positionalFields_recordLiteral_false() {
parse('''
final x = (0, (1, 2));
''');
assertInContext('(1, 2)', false);
}
test_inConstantContext_recordLiteral_positionalFields_recordLiteral_true() {
parse('''
final x = const (0, (1, 2));
''');
assertInContext('(1, 2)', true);
}
}
@reflectiveTest