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

Side by Side Diff: test/js/builder_test.dart

Issue 1522793002: MiniJsParser: fix a regression + support computed props + add tests (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « test/all_tests.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « test/all_tests.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698