| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library parser_test; | 5 library parser_test; |
| 6 | 6 |
| 7 import 'package:polymer_expressions/parser.dart'; | 7 import 'package:polymer_expressions/parser.dart'; |
| 8 import 'package:polymer_expressions/expression.dart'; | 8 import 'package:polymer_expressions/expression.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 expectParse('a[][]', index(index(ident('a'), null), null)); | 154 expectParse('a[][]', index(index(ident('a'), null), null)); |
| 155 }); | 155 }); |
| 156 | 156 |
| 157 test('should parse multiple index operators', () { | 157 test('should parse multiple index operators', () { |
| 158 expectParse('a[b] + c[d]', binary( | 158 expectParse('a[b] + c[d]', binary( |
| 159 index(ident('a'), ident('b')), | 159 index(ident('a'), ident('b')), |
| 160 '+', | 160 '+', |
| 161 index(ident('c'), ident('d')))); | 161 index(ident('c'), ident('d')))); |
| 162 }); | 162 }); |
| 163 | 163 |
| 164 test('should parse ternary operators', () { |
| 165 expectParse('a ? b : c', ternary(ident('a'), ident('b'), ident('c'))); |
| 166 expectParse('a.a ? b.a : c.a', ternary(getter(ident('a'), 'a'), |
| 167 getter(ident('b'), 'a'), getter(ident('c'), 'a'))); |
| 168 expect(() => parse('a + 1 ? b + 1 :: c.d + 3'), throws); |
| 169 }); |
| 170 |
| 164 test('should parse a filter chain', () { | 171 test('should parse a filter chain', () { |
| 165 expectParse('a | b | c', binary(binary(ident('a'), '|', ident('b')), | 172 expectParse('a | b | c', binary(binary(ident('a'), '|', ident('b')), |
| 166 '|', ident('c'))); | 173 '|', ident('c'))); |
| 167 }); | 174 }); |
| 168 | 175 |
| 169 test('should parse comprehension', () { | 176 test('should parse comprehension', () { |
| 170 expectParse('a in b', inExpr(ident('a'), ident('b'))); | 177 expectParse('a in b', inExpr(ident('a'), ident('b'))); |
| 171 expectParse('a in b.c', | 178 expectParse('a in b.c', |
| 172 inExpr(ident('a'), getter(ident('b'), 'c'))); | 179 inExpr(ident('a'), getter(ident('b'), 'c'))); |
| 173 expectParse('a in b + c', | 180 expectParse('a in b + c', |
| (...skipping 24 matching lines...) Expand all Loading... |
| 198 literal('a'), invoke(ident('foo'), null, [literal('a')]))])); | 205 literal('a'), invoke(ident('foo'), null, [literal('a')]))])); |
| 199 }); | 206 }); |
| 200 | 207 |
| 201 test('should parse map literals with method calls', () { | 208 test('should parse map literals with method calls', () { |
| 202 expectParse("{'a': 1}.length", | 209 expectParse("{'a': 1}.length", |
| 203 getter(mapLiteral([mapLiteralEntry(literal('a'), literal(1))]), | 210 getter(mapLiteral([mapLiteralEntry(literal('a'), literal(1))]), |
| 204 'length')); | 211 'length')); |
| 205 }); | 212 }); |
| 206 }); | 213 }); |
| 207 } | 214 } |
| OLD | NEW |