| OLD | NEW |
| (Empty) | |
| 1 import 'package:dev_compiler/src/js/js_ast.dart'; |
| 2 import 'package:test/test.dart'; |
| 3 |
| 4 final _prenumberedPlaceholders = new RegExp(r'#\d+'); |
| 5 |
| 6 _parser(String src) => |
| 7 new MiniJsParser(src.replaceAll(_prenumberedPlaceholders, '#')); |
| 8 |
| 9 _check(Node node, String expected) => |
| 10 expect(node.toString(), 'js_ast `$expected`'); |
| 11 |
| 12 _checkStatement(String src) => |
| 13 _check(_parser(src).parseStatement(), src); |
| 14 |
| 15 _checkExpression(String src) => |
| 16 _check(_parser(src).parseExpression(), src); |
| 17 |
| 18 main() { |
| 19 group('MiniJsParser', () { |
| 20 // TODO(ochafik): Add more coverage. |
| 21 test('parses classes with complex members', () { |
| 22 _checkExpression( |
| 23 'class Foo {\n' |
| 24 ' [foo](...args) {}\n' |
| 25 ' [#0](x) {}\n' |
| 26 ' static [foo](...args) {}\n' |
| 27 ' static [#1](x) {}\n' |
| 28 ' get [foo]() {}\n' |
| 29 ' get [#2]() {}\n' |
| 30 ' static get [foo]() {}\n' |
| 31 ' static get [#3]() {}\n' |
| 32 ' set [foo](v) {}\n' |
| 33 ' set [#4](v) {}\n' |
| 34 ' static set [foo](v) {}\n' |
| 35 ' static set [#5](v) {}\n' |
| 36 '}'); |
| 37 }); |
| 38 test('parses statements', () { |
| 39 _checkStatement('for (let i = 0; i < 10; i++) {\n}\n'); |
| 40 _checkStatement('for (let i = 0, j = 1; i < 10; i++) {\n}\n'); |
| 41 _checkStatement('var [x, y = []] = list;\n'); |
| 42 _checkStatement('var {x, y = {x: y}} = obj;\n'); |
| 43 }); |
| 44 }); |
| 45 } |
| OLD | NEW |