| 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 // VMOptions=--warn_on_javascript_compatibility --warning_as_error --optimizatio
n_counter_threshold=5 | 5 // VMOptions=--warn_on_javascript_compatibility --warning_as_error --optimizatio
n_counter_threshold=5 |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 f(x, y) { | 9 f(x, y) { |
| 10 // Unoptimized and optimized code. | 10 // Unoptimized and optimized code. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 g(x, y) => f(x, y); // Test inlining calls. | 152 g(x, y) => f(x, y); // Test inlining calls. |
| 153 h(x, y) => g(x, y); | 153 h(x, y) => g(x, y); |
| 154 | 154 |
| 155 // We don't test for _JavascriptCompatibilityError since it's not visible. | 155 // We don't test for _JavascriptCompatibilityError since it's not visible. |
| 156 // It should not be visible since it doesn't exist on dart2js. | 156 // It should not be visible since it doesn't exist on dart2js. |
| 157 bool isJavascriptCompatibilityError(e) => | 157 bool isJavascriptCompatibilityError(e) => |
| 158 e is Error && "$e".contains("Javascript Compatibility Error"); | 158 e is Error && "$e".contains("Javascript Compatibility Error"); |
| 159 | 159 |
| 160 main() { | 160 main() { |
| 161 // Since the warning (or error in case of --warning_as_error) is issued at | 161 // The warning (or error in case of --warning_as_error) is issued at |
| 162 // most once per location, the Expect.throw must guard the whole loop. | 162 // most once per location. |
| 163 Expect.throws( | 163 var numWarnings = 0; |
| 164 () { | 164 for (var i = 0; i < 20; i++) { |
| 165 for (var i = 0; i < 20; i++) { | 165 try { |
| 166 h(i, i * 1.0); | 166 h(i, i * 1.0); |
| 167 } | 167 } catch(e) { |
| 168 }, | 168 Expect.isTrue(isJavascriptCompatibilityError(e)); |
| 169 isJavascriptCompatibilityError); | 169 numWarnings++; |
| 170 | 170 } |
| 171 } |
| 172 Expect.equals(1, numWarnings); |
| 171 // No warnings (errors) should be issued after this point. | 173 // No warnings (errors) should be issued after this point. |
| 172 for (var i = 0; i < 20; i++) { | 174 for (var i = 0; i < 20; i++) { |
| 173 k(i * 1.0, i); | 175 k(i * 1.0, i); |
| 174 k(i * 1.0, i + 0.5); | 176 k(i * 1.0, i + 0.5); |
| 175 } | 177 } |
| 176 } | 178 } |
| 177 | 179 |
| OLD | NEW |