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

Unified Diff: tests/compiler/dart2js/parser_test.dart

Issue 1151163004: Implementation of null-aware operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/compiler/lib/src/warnings.dart ('k') | tests/compiler/dart2js_extra/conditional_send_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/parser_test.dart
diff --git a/tests/compiler/dart2js/parser_test.dart b/tests/compiler/dart2js/parser_test.dart
index 6606f884cc1bcef7bae9cfde6499a178a2f33341..1f4cae97b96767b5ca81252990f78060462f8f74 100644
--- a/tests/compiler/dart2js/parser_test.dart
+++ b/tests/compiler/dart2js/parser_test.dart
@@ -144,6 +144,32 @@ void testConditionalExpression() {
conditional = node.expression;
Expect.isNotNull(conditional.thenExpression.asSendSet());
Expect.isNotNull(conditional.elseExpression.asSendSet());
+
+ node = parseStatement("a ?? b ? c : d;");
+ // Should parse as: (a ?? b) ? c : d;
+ conditional = node.expression;
+ Expect.isNotNull(conditional.condition.asSend());
+ Expect.isTrue(conditional.condition.asSend().isIfNull);
+ Expect.isNotNull(conditional.thenExpression.asSend());
+ Expect.isNotNull(conditional.elseExpression.asSend());
+}
+
+void testNullOperators() {
+ Expression node = parseStatement("a ?? b;").expression;
+ Expect.isNotNull(node.asSend());
+ Expect.isTrue(node.asSend().isIfNull);
+
+ node = parseStatement("a ??= b;").expression;
+ Expect.isNotNull(node.asSendSet());
+ Expect.isTrue(node.asSendSet().isIfNullAssignment);
+
+ node = parseStatement("a?.b;").expression;
+ Expect.isNotNull(node.asSend());
+ Expect.isTrue(node.asSend().isConditional);
+
+ node = parseStatement("a?.m();").expression;
+ Expect.isNotNull(node.asSend());
+ Expect.isTrue(node.asSend().isConditional);
}
void testAssignment() {
@@ -338,6 +364,7 @@ void main() {
testDoStatement();
testWhileStatement();
testConditionalExpression();
+ testNullOperators();
testAssignment();
testIndex();
testPostfix();
« no previous file with comments | « pkg/compiler/lib/src/warnings.dart ('k') | tests/compiler/dart2js_extra/conditional_send_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698