| 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 // Test that parameters keep their names in the output. | 4 // Test that parameters keep their names in the output. |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'compiler_helper.dart'; | 9 import 'compiler_helper.dart'; |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (test) { | 67 if (test) { |
| 68 foo(1, 2); | 68 foo(1, 2); |
| 69 result = 42; | 69 result = 42; |
| 70 } | 70 } |
| 71 print(result); | 71 print(result); |
| 72 } | 72 } |
| 73 """; | 73 """; |
| 74 | 74 |
| 75 main() { | 75 main() { |
| 76 asyncTest(() => Future.wait([ | 76 asyncTest(() => Future.wait([ |
| 77 compile(FOO, entry: 'foo', check: (String generated) { | 77 compile(FOO, entry: 'foo', check: (String generated) { |
| 78 Expect.isTrue(generated.contains(r"function(a, b) {")); | 78 Expect.isTrue(generated.contains(r"function(a, b) {")); |
| 79 }), | 79 }), |
| 80 | 80 compile(BAR, entry: 'bar', check: (String generated) { |
| 81 compile(BAR, entry: 'bar', check: (String generated) { | 81 Expect.isTrue(generated.contains(r"function($eval, $$eval) {")); |
| 82 Expect.isTrue(generated.contains(r"function($eval, $$eval) {")); | 82 }), |
| 83 }), | 83 compile(PARAMETER_AND_TEMP, entry: 'bar', check: (String generated) { |
| 84 | 84 Expect.isTrue(generated.contains(r"print(t00)")); |
| 85 compile(PARAMETER_AND_TEMP, entry: 'bar', check: (String generated) { | 85 // Check that the second 't0' got another name. |
| 86 Expect.isTrue(generated.contains(r"print(t00)")); | 86 Expect.isTrue(generated.contains(r"print(t01)")); |
| 87 // Check that the second 't0' got another name. | 87 }), |
| 88 Expect.isTrue(generated.contains(r"print(t01)")); | 88 compile(MULTIPLE_PHIS_ONE_LOCAL, entry: 'foo', |
| 89 }), | 89 check: (String generated) { |
| 90 | 90 Expect.isTrue(generated.contains("var a;")); |
| 91 compile(MULTIPLE_PHIS_ONE_LOCAL, entry: 'foo', check: (String generated) { | 91 // Check that there is only one var declaration. |
| 92 Expect.isTrue(generated.contains("var a;")); | 92 checkNumberOfMatches( |
| 93 // Check that there is only one var declaration. | 93 new RegExp("var").allMatches(generated).iterator, 1); |
| 94 checkNumberOfMatches(new RegExp("var").allMatches(generated).iterator, 1); | 94 }), |
| 95 }), | 95 compile(NO_LOCAL, entry: 'foo', check: (String generated) { |
| 96 | 96 Expect.isFalse(generated.contains('var')); |
| 97 compile(NO_LOCAL, entry: 'foo', check: (String generated) { | 97 }), |
| 98 Expect.isFalse(generated.contains('var')); | 98 compile(PARAMETER_INIT, entry: 'foo', check: (String generated) { |
| 99 }), | 99 // Check that there is only one var declaration. |
| 100 | 100 checkNumberOfMatches( |
| 101 compile(PARAMETER_INIT, entry: 'foo', check: (String generated) { | 101 new RegExp("var").allMatches(generated).iterator, 1); |
| 102 // Check that there is only one var declaration. | 102 }), |
| 103 checkNumberOfMatches(new RegExp("var").allMatches(generated).iterator, 1); | 103 ])); |
| 104 }), | |
| 105 ])); | |
| 106 } | 104 } |
| OLD | NEW |