OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 12 |
13 Future testStatement(String statement, arguments, String expect) { | 13 Future testStatement(String statement, arguments, String expect) { |
14 jsAst.Node node = js.statement(statement, arguments); | 14 jsAst.Node node = js.statement(statement, arguments); |
15 return MockCompiler.create((MockCompiler compiler) { | 15 return MockCompiler.create((MockCompiler compiler) { |
16 String jsText = | 16 String jsText = |
17 jsAst.prettyPrint(node, compiler, allowVariableMinification: false) | 17 jsAst.prettyPrint(node, compiler, allowVariableMinification: false); |
18 .getText(); | |
19 | 18 |
20 Expect.stringEquals(expect.trim(), jsText.trim()); | 19 Expect.stringEquals(expect.trim(), jsText.trim()); |
21 }); | 20 }); |
22 } | 21 } |
23 | 22 |
24 Future testError(String statement, arguments, [String expect = ""]) { | 23 Future testError(String statement, arguments, [String expect = ""]) { |
25 return new Future.sync(() { | 24 return new Future.sync(() { |
26 bool doCheck(exception) { | 25 bool doCheck(exception) { |
27 String message = '$exception'; | 26 String message = '$exception'; |
28 Expect.isTrue(message.contains(expect), '"$message" contains "$expect"'); | 27 Expect.isTrue(message.contains(expect), '"$message" contains "$expect"'); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 testStatement('if (a) {while (true) if (b) {foo1();}} else {foo2();}', | 393 testStatement('if (a) {while (true) if (b) {foo1();}} else {foo2();}', |
395 [], """ | 394 [], """ |
396 if (a) { | 395 if (a) { |
397 while (true) | 396 while (true) |
398 if (b) | 397 if (b) |
399 foo1(); | 398 foo1(); |
400 } else | 399 } else |
401 foo2();"""), | 400 foo2();"""), |
402 ])); | 401 ])); |
403 } | 402 } |
OLD | NEW |