Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: tests/compiler/dart2js/interop_anonymous_unreachable_test.dart

Issue 1458313002: Fix for the js-interop crash Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library tests.dart2js.interop_anonymous_unreachable_test;
6
7 import 'dart:async';
8
9 import 'package:test/test.dart';
10 import 'compiler_helper.dart';
11
12
13 main() {
14 test("unreachable code doesn't crash the compiler", () async {
15 // This test is a regression for Issue #24974
16 String generated = await compile("""
17 import 'package:js/js.dart';
18
19 @JS() @anonymous
20 class UniqueLongNameForTesting_A {
21 external factory UniqueLongNameForTesting_A();
22 }
23 main() {}
24 """, returnAll: true);
25
26 // the code should not be included in the output either.
27 expect(generated, isNot(contains("UniqueLongNameForTesting_A")));
28 });
29
30 test('interop types can be tree-shaken', () async {
31 String generated = await compile("""
32 import 'package:js/js.dart';
33
34 // reachable and allocated
35 @JS() @anonymous
36 class UniqueLongNameForTesting_A {
37 external bool get x;
38 external UniqueLongNameForTesting_D get d;
39 external UniqueLongNameForTesting_E get e;
40 external factory UniqueLongNameForTesting_A(
41 {UniqueLongNameForTesting_B arg0});
42 }
43
44 // visible through the parameter above, but not used.
45 @JS() @anonymous
46 class UniqueLongNameForTesting_B {
47 external factory UniqueLongNameForTesting_B();
48 }
49
50 // unreachable
51 @JS() @anonymous
52 class UniqueLongNameForTesting_C {
53 external factory UniqueLongNameForTesting_C();
54 }
55
56 // visible and reached through `d`.
57 @JS() @anonymous
58 class UniqueLongNameForTesting_D {
59 external factory UniqueLongNameForTesting_D();
60 }
61
62 // visible through `e`, but not reached.
63 @JS() @anonymous
64 class UniqueLongNameForTesting_E {
65 external factory UniqueLongNameForTesting_E();
66 }
67
68 main() {
69 print(new UniqueLongNameForTesting_A().x);
70 print(new UniqueLongNameForTesting_A().d);
71 }
72 """, returnAll: true);
73 expect(generated, contains("UniqueLongNameForTesting_A"));
74 expect(generated, contains("UniqueLongNameForTesting_D"));
75 expect(generated, isNot(contains("UniqueLongNameForTesting_B")));
76 expect(generated, isNot(contains("UniqueLongNameForTesting_C")));
77 expect(generated, isNot(contains("UniqueLongNameForTesting_E")));
78 });
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698