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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/all_tests.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/js/builder_test.dart
diff --git a/test/js/builder_test.dart b/test/js/builder_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ba65946a7eaa56a2233e04ae4be8510528ff854c
--- /dev/null
+++ b/test/js/builder_test.dart
@@ -0,0 +1,45 @@
+import 'package:dev_compiler/src/js/js_ast.dart';
+import 'package:test/test.dart';
+
+final _prenumberedPlaceholders = new RegExp(r'#\d+');
+
+_parser(String src) =>
+ new MiniJsParser(src.replaceAll(_prenumberedPlaceholders, '#'));
+
+_check(Node node, String expected) =>
+ expect(node.toString(), 'js_ast `$expected`');
+
+_checkStatement(String src) =>
+ _check(_parser(src).parseStatement(), src);
+
+_checkExpression(String src) =>
+ _check(_parser(src).parseExpression(), src);
+
+main() {
+ group('MiniJsParser', () {
+ // TODO(ochafik): Add more coverage.
+ test('parses classes with complex members', () {
+ _checkExpression(
+ 'class Foo {\n'
+ ' [foo](...args) {}\n'
+ ' [#0](x) {}\n'
+ ' static [foo](...args) {}\n'
+ ' static [#1](x) {}\n'
+ ' get [foo]() {}\n'
+ ' get [#2]() {}\n'
+ ' static get [foo]() {}\n'
+ ' static get [#3]() {}\n'
+ ' set [foo](v) {}\n'
+ ' set [#4](v) {}\n'
+ ' static set [foo](v) {}\n'
+ ' static set [#5](v) {}\n'
+ '}');
+ });
+ test('parses statements', () {
+ _checkStatement('for (let i = 0; i < 10; i++) {\n}\n');
+ _checkStatement('for (let i = 0, j = 1; i < 10; i++) {\n}\n');
+ _checkStatement('var [x, y = []] = list;\n');
+ _checkStatement('var {x, y = {x: y}} = obj;\n');
+ });
+ });
+}
« 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