Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1859723002: Support for serializing prefix/postfix increment/decrement. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_const_expr.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index d3d1bcbc86d8e4b4898c7580391e4116eab0abba..bd6315c27ca6836b736dffa76b0316fdbc478a78 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -6129,6 +6129,26 @@ final v = (a.b.c.f = 1);
]);
}
+ test_expr_assignToRef_postfixDecrement() {
+ _assertRefPrefixPostfixIncrementDecrement(
+ 'a-- + 2', UnlinkedExprAssignOperator.postfixDecrement);
+ }
+
+ test_expr_assignToRef_postfixIncrement() {
+ _assertRefPrefixPostfixIncrementDecrement(
+ 'a++ + 2', UnlinkedExprAssignOperator.postfixIncrement);
+ }
+
+ test_expr_assignToRef_prefixDecrement() {
+ _assertRefPrefixPostfixIncrementDecrement(
+ '--a + 2', UnlinkedExprAssignOperator.prefixDecrement);
+ }
+
+ test_expr_assignToRef_prefixIncrement() {
+ _assertRefPrefixPostfixIncrementDecrement(
+ '++a + 2', UnlinkedExprAssignOperator.prefixIncrement);
+ }
+
test_expr_assignToRef_topLevelVariable() {
if (skipNonConstInitializers) {
return;
@@ -8748,6 +8768,33 @@ final v = $expr;
}
/**
+ * Assert that the [expr] of the form `++a + 2` is serialized with the
+ * [expectedAssignmentOperator].
+ */
+ void _assertRefPrefixPostfixIncrementDecrement(
+ String expr, UnlinkedExprAssignOperator expectedAssignmentOperator) {
+ if (skipNonConstInitializers) {
+ return;
+ }
+ UnlinkedVariable variable = serializeVariableText('''
+int a = 0;
+final v = $expr;
+''');
+ _assertUnlinkedConst(variable.constExpr, operators: [
+ UnlinkedConstOperation.assignToRef,
+ UnlinkedConstOperation.pushInt,
+ UnlinkedConstOperation.add,
+ ], assignmentOperators: [
+ expectedAssignmentOperator
+ ], ints: [
+ 2
+ ], strings: [], referenceValidators: [
+ (EntityRef r) => checkTypeRef(r, null, null, 'a',
+ expectedKind: ReferenceKind.topLevelPropertyAccessor)
+ ]);
+ }
+
+ /**
* TODO(scheglov) rename "Const" to "Expr" everywhere
*/
void _assertUnlinkedConst(UnlinkedConst constExpr,
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_const_expr.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698