OLD | NEW |
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 'dart:async'; | 5 import 'dart:async'; |
6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
8 import 'mock_compiler.dart'; | 8 import 'mock_compiler.dart'; |
9 import 'package:compiler/src/js/js.dart' as jsAst; | 9 import 'package:compiler/src/js/js.dart' as jsAst; |
10 import 'package:compiler/src/js/js.dart' show js; | 10 import 'package:compiler/src/js/js.dart' show js; |
11 | 11 |
12 Future testExpression(String expression, [String expect = ""]) { | 12 Future testExpression(String expression, [String expect = ""]) { |
13 jsAst.Node node = js(expression); | 13 jsAst.Node node = js(expression); |
14 return MockCompiler.create((MockCompiler compiler) { | 14 return MockCompiler.create((MockCompiler compiler) { |
15 String jsText = | 15 String jsText = jsAst.prettyPrint(node, compiler.options, |
16 jsAst.prettyPrint(node, compiler, allowVariableMinification: false); | 16 allowVariableMinification: false); |
17 if (expect == "") { | 17 if (expect == "") { |
18 Expect.stringEquals(expression, jsText); | 18 Expect.stringEquals(expression, jsText); |
19 } else { | 19 } else { |
20 Expect.stringEquals(expect, jsText); | 20 Expect.stringEquals(expect, jsText); |
21 } | 21 } |
22 }); | 22 }); |
23 } | 23 } |
24 | 24 |
25 Future testError(String expression, [String expect = ""]) { | 25 Future testError(String expression, [String expect = ""]) { |
26 return new Future.sync(() { | 26 return new Future.sync(() { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 testExpression("y = a == null ? b + c : a + c"), | 192 testExpression("y = a == null ? b + c : a + c"), |
193 testExpression("foo = a ? b : c ? d : e"), | 193 testExpression("foo = a ? b : c ? d : e"), |
194 testExpression("foo = a ? b ? c : d : e"), | 194 testExpression("foo = a ? b ? c : d : e"), |
195 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z"), | 195 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z"), |
196 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z"), | 196 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z"), |
197 // Stacked assignment. | 197 // Stacked assignment. |
198 testExpression("a = b = c"), | 198 testExpression("a = b = c"), |
199 testExpression("var a = b = c"), | 199 testExpression("var a = b = c"), |
200 ])); | 200 ])); |
201 } | 201 } |
OLD | NEW |