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

Side by Side Diff: tests/compiler/dart2js/js_parser_test.dart

Issue 13704004: dart2js: Use js('source') instead of js['source'] to invoke JS mini-parser (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Go back to js.if_ instead of jsBuilder.if_ Created 7 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js/class_codegen_test.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
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 import 'mock_compiler.dart'; 5 import 'mock_compiler.dart';
6 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' as jsAst; 6 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' as jsAst;
7 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' show js; 7 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' show js;
8 8
9 void testExpression(String expression, [String expect = ""]) { 9 void testExpression(String expression, [String expect = ""]) {
10 jsAst.Node node = js[expression]; 10 jsAst.Node node = js(expression);
11 MockCompiler compiler = new MockCompiler(); 11 MockCompiler compiler = new MockCompiler();
12 String jsText = 12 String jsText =
13 jsAst.prettyPrint(node, 13 jsAst.prettyPrint(node,
14 compiler, 14 compiler,
15 allowVariableMinification: false).getText(); 15 allowVariableMinification: false).getText();
16 if (expect == "") { 16 if (expect == "") {
17 Expect.stringEquals(expression, jsText); 17 Expect.stringEquals(expression, jsText);
18 } else { 18 } else {
19 Expect.stringEquals(expect, jsText); 19 Expect.stringEquals(expect, jsText);
20 } 20 }
21 } 21 }
22 22
23 void testError(String expression, [String expect = ""]) { 23 void testError(String expression, [String expect = ""]) {
24 bool doCheck(exception) { 24 bool doCheck(exception) {
25 Expect.isTrue(exception.toString().contains(expect)); 25 Expect.isTrue(exception.toString().contains(expect));
26 return true; 26 return true;
27 } 27 }
28 Expect.throws(() => js[expression], doCheck); 28 Expect.throws(() => js(expression), doCheck);
29 } 29 }
30 30
31 31
32 32
33 void main() { 33 void main() {
34 // Asterisk indicates deviations from real JS. 34 // Asterisk indicates deviations from real JS.
35 // Simple var test. 35 // Simple var test.
36 testExpression('var a = ""'); 36 testExpression('var a = ""');
37 // Parse and print will normalize whitespace. 37 // Parse and print will normalize whitespace.
38 testExpression(' var a = "" ', 'var a = ""'); 38 testExpression(' var a = "" ', 'var a = ""');
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 testExpression("y = a == null ? b : a"); 147 testExpression("y = a == null ? b : a");
148 testExpression("y = a == null ? b + c : a + c"); 148 testExpression("y = a == null ? b + c : a + c");
149 testExpression("foo = a ? b : c ? d : e"); 149 testExpression("foo = a ? b : c ? d : e");
150 testExpression("foo = a ? b ? c : d : e"); 150 testExpression("foo = a ? b ? c : d : e");
151 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z"); 151 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z");
152 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z"); 152 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z");
153 // Stacked assignment. 153 // Stacked assignment.
154 testExpression("a = b = c"); 154 testExpression("a = b = c");
155 testExpression("var a = b = c"); 155 testExpression("var a = b = c");
156 } 156 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/class_codegen_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698