| 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 library tests.dart2js.interop_anonymous_unreachable_test; | 5 library tests.dart2js.interop_anonymous_unreachable_test; |
| 6 | 6 |
| 7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
| 8 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 test("unreachable code doesn't crash the compiler", () async { | 11 test("unreachable code doesn't crash the compiler", () async { |
| 12 // This test is a regression for Issue #24974 | 12 // This test is a regression for Issue #24974 |
| 13 String generated = await compile( | 13 String generated = await compile(""" |
| 14 """ | |
| 15 import 'package:js/js.dart'; | 14 import 'package:js/js.dart'; |
| 16 | 15 |
| 17 @JS() @anonymous | 16 @JS() @anonymous |
| 18 class UniqueLongNameForTesting_A { | 17 class UniqueLongNameForTesting_A { |
| 19 external factory UniqueLongNameForTesting_A(); | 18 external factory UniqueLongNameForTesting_A(); |
| 20 } | 19 } |
| 21 main() {} | 20 main() {} |
| 22 """, | 21 """, returnAll: true); |
| 23 returnAll: true); | |
| 24 | 22 |
| 25 // the code should not be included in the output either. | 23 // the code should not be included in the output either. |
| 26 expect(generated, isNot(contains("UniqueLongNameForTesting_A"))); | 24 expect(generated, isNot(contains("UniqueLongNameForTesting_A"))); |
| 27 }); | 25 }); |
| 28 | 26 |
| 29 group('tree-shaking interop types', () { | 27 group('tree-shaking interop types', () { |
| 30 String program = """ | 28 String program = """ |
| 31 import 'package:js/js.dart'; | 29 import 'package:js/js.dart'; |
| 32 | 30 |
| 33 // reachable and allocated | 31 // reachable and allocated |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 163 |
| 166 generated = await compile(program2, returnAll: true); | 164 generated = await compile(program2, returnAll: true); |
| 167 expect(generated.contains("UniqueLongNameForTesting_A"), isTrue); | 165 expect(generated.contains("UniqueLongNameForTesting_A"), isTrue); |
| 168 // This extra check is to make sure that we don't include HTMLAudioElement | 166 // This extra check is to make sure that we don't include HTMLAudioElement |
| 169 // just because of the is-check. It is optimized away in this case because | 167 // just because of the is-check. It is optimized away in this case because |
| 170 // we believe it was never instantiated. | 168 // we believe it was never instantiated. |
| 171 expect(generated.contains("HTMLAudioElement"), isFalse); | 169 expect(generated.contains("HTMLAudioElement"), isFalse); |
| 172 }); | 170 }); |
| 173 }); | 171 }); |
| 174 } | 172 } |
| OLD | NEW |