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

Unified Diff: pkg/polymer_expressions/test/parser_test.dart

Issue 213523004: Fix precedence of ternary operators in polymer expressions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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/polymer_expressions/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer_expressions/test/parser_test.dart
diff --git a/pkg/polymer_expressions/test/parser_test.dart b/pkg/polymer_expressions/test/parser_test.dart
index e57d11a3ccafb5ef1b997b9cc9c2822e459da791..09de5d61f0c7c8ef681453f383ad20e05a0dd2f3 100644
--- a/pkg/polymer_expressions/test/parser_test.dart
+++ b/pkg/polymer_expressions/test/parser_test.dart
@@ -159,6 +159,23 @@ main() {
expect(() => parse('a + 1 ? b + 1 :: c.d + 3'), throws);
});
+ test('ternary operators have lowest associativity', () {
+ expectParse('a == b ? c + d : e - f', ternary(
+ binary(ident('a'), '==', ident('b')),
+ binary(ident('c'), '+', ident('d')),
+ binary(ident('e'), '-', ident('f'))));
+
+ expectParse('a.x == b.y ? c + d : e - f', ternary(
+ binary(getter(ident('a'), 'x'), '==', getter(ident('b'), 'y')),
+ binary(ident('c'), '+', ident('d')),
+ binary(ident('e'), '-', ident('f'))));
+
+ expectParse('a.x == b.y ? c + d : e - f', ternary(
+ binary(getter(ident('a'), 'x'), '==', getter(ident('b'), 'y')),
+ binary(ident('c'), '+', ident('d')),
+ binary(ident('e'), '-', ident('f'))));
+ });
+
test('should parse a filter chain', () {
expectParse('a | b | c', binary(binary(ident('a'), '|', ident('b')),
'|', ident('c')));
« no previous file with comments | « pkg/polymer_expressions/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698