| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "package:compiler/src/js/js.dart"; | 6 import "package:compiler/src/js/js.dart"; |
| 7 import "package:compiler/src/js/rewrite_async.dart"; | 7 import "package:compiler/src/js/rewrite_async.dart"; |
| 8 | 8 |
| 9 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener; | 9 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener; |
| 10 | 10 |
| 11 void testTransform(String source, String expected) { | 11 void testTransform(String source, String expected) { |
| 12 Fun fun = js(source); | 12 Fun fun = js(source); |
| 13 Fun rewritten = new AsyncRewriter( | 13 Fun rewritten = new AsyncRewriter( |
| 14 null, // The diagnostic helper should not be used in these tests. | 14 null, // The diagnostic helper should not be used in these tests. |
| 15 null, | 15 null, |
| 16 asyncHelper: new VariableUse("thenHelper"), | 16 asyncHelper: new VariableUse("thenHelper"), |
| 17 newCompleter: new VariableUse("Completer"), | 17 newCompleter: new VariableUse("Completer"), |
| 18 safeVariableName: (String name) => "__$name").rewrite(fun); | 18 safeVariableName: (String name) => "__$name", |
| 19 bodyName: "body").rewrite(fun); |
| 19 | 20 |
| 20 JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(); | 21 JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(); |
| 21 SimpleJavaScriptPrintingContext context = | 22 SimpleJavaScriptPrintingContext context = |
| 22 new SimpleJavaScriptPrintingContext(); | 23 new SimpleJavaScriptPrintingContext(); |
| 23 Printer printer = new Printer(options, context); | 24 Printer printer = new Printer(options, context); |
| 24 printer.visit(rewritten); | 25 printer.visit(rewritten); |
| 25 Expect.stringEquals(expected, context.getText()); | 26 Expect.stringEquals(expected, context.getText()); |
| 26 } | 27 } |
| 27 | 28 |
| 28 main() { | 29 main() { |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 // implicit return | 1133 // implicit return |
| 1133 return thenHelper(null, 0, __completer, null); | 1134 return thenHelper(null, 0, __completer, null); |
| 1134 case 1: | 1135 case 1: |
| 1135 // rethrow | 1136 // rethrow |
| 1136 return thenHelper(__currentError, 1, __completer); | 1137 return thenHelper(__currentError, 1, __completer); |
| 1137 } | 1138 } |
| 1138 } | 1139 } |
| 1139 return thenHelper(null, __body, __completer, null); | 1140 return thenHelper(null, __body, __completer, null); |
| 1140 }"""); | 1141 }"""); |
| 1141 } | 1142 } |
| OLD | NEW |