| 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 |
| 11 expectParse(String s, Expression e) => | 11 expectParse(String s, Expression e) => |
| 12 expect(new Parser(s).parse(), e, reason: s); | 12 expect(new Parser(s).parse(), e, reason: s); |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 | 15 |
| 16 group('parser', () { | 16 group('parser', () { |
| 17 | 17 |
| 18 test('should parse an empty expression', () { | 18 test('should parse an empty expression', () { |
| 19 expectParse('', empty()); | 19 expectParse('', empty()); |
| 20 }); | 20 }); |
| 21 | 21 |
| 22 test('should parse an identifier', () { | 22 test('should parse an identifier', () { |
| 23 expectParse('abc', ident('abc')); | 23 expectParse('abc', ident('abc')); |
| 24 }); | 24 }); |
| 25 | 25 |
| 26 test('should parse a string literal', () { | 26 test('should parse a string literal', () { |
| 27 expectParse('"abc"', literal('abc')); | 27 expectParse('"abc"', literal('abc')); |
| 28 }); | 28 }); |
| 29 | 29 |
| 30 test('should parse a bool literal', () { |
| 31 expectParse('true', literal(true)); |
| 32 expectParse('false', literal(false)); |
| 33 }); |
| 34 |
| 35 test('should parse a null literal', () { |
| 36 expectParse('null', literal(null)); |
| 37 }); |
| 38 |
| 30 test('should parse an integer literal', () { | 39 test('should parse an integer literal', () { |
| 31 expectParse('123', literal(123)); | 40 expectParse('123', literal(123)); |
| 32 }); | 41 }); |
| 33 | 42 |
| 34 test('should parse a double literal', () { | 43 test('should parse a double literal', () { |
| 35 expectParse('1.23', literal(1.23)); | 44 expectParse('1.23', literal(1.23)); |
| 36 }); | 45 }); |
| 37 | 46 |
| 38 test('should parse a positive double literal', () { | 47 test('should parse a positive double literal', () { |
| 39 expectParse('+1.23', literal(1.23)); | 48 expectParse('+1.23', literal(1.23)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 literal('a'), invoke(ident('foo'), null, [literal('a')]))])); | 199 literal('a'), invoke(ident('foo'), null, [literal('a')]))])); |
| 191 }); | 200 }); |
| 192 | 201 |
| 193 test('should parse map literals with method calls', () { | 202 test('should parse map literals with method calls', () { |
| 194 expectParse("{'a': 1}.length", | 203 expectParse("{'a': 1}.length", |
| 195 invoke(mapLiteral([mapLiteralEntry(literal('a'), literal(1))]), | 204 invoke(mapLiteral([mapLiteralEntry(literal('a'), literal(1))]), |
| 196 'length')); | 205 'length')); |
| 197 }); | 206 }); |
| 198 }); | 207 }); |
| 199 } | 208 } |
| OLD | NEW |