OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 'memory_compiler.dart' show compilerFor; | 6 import 'memory_compiler.dart' show compilerFor; |
7 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show | 7 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show |
8 Compiler; | 8 Compiler; |
9 import | 9 import |
10 '../../../sdk/lib/_internal/compiler/implementation/dart_backend/dart_backen
d.dart' | 10 '../../../sdk/lib/_internal/compiler/implementation/dart_backend/dart_backen
d.dart' |
(...skipping 15 matching lines...) Expand all Loading... |
26 backend.useMirrorHelperLibrary = useMirrorHelperLibrary; | 26 backend.useMirrorHelperLibrary = useMirrorHelperLibrary; |
27 compiler.runCompiler(Uri.parse('memory:main.dart')); | 27 compiler.runCompiler(Uri.parse('memory:main.dart')); |
28 return compiler; | 28 return compiler; |
29 } | 29 } |
30 | 30 |
31 void testUniqueMinification() { | 31 void testUniqueMinification() { |
32 Compiler compiler = runCompiler(useMirrorHelperLibrary: true, minify: true); | 32 Compiler compiler = runCompiler(useMirrorHelperLibrary: true, minify: true); |
33 DartBackend backend = compiler.backend; | 33 DartBackend backend = compiler.backend; |
34 Map<Node, String> renames = backend.renames; | 34 Map<Node, String> renames = backend.renames; |
35 | 35 |
36 //'Foo' appears twice, so toSet() reduces the length by 1. | 36 //'Foo' appears twice, so toSet() reduces the length by 1, |
37 Expect.equals(renames.values.toSet().length, renames.values.length - 1); | 37 // and the extra code from mirror_helper.dart adds 9 duplicates. |
| 38 Expect.equals(renames.values.toSet().length, renames.values.length - 10); |
38 } | 39 } |
39 | 40 |
40 void testNoUniqueMinification() { | 41 void testNoUniqueMinification() { |
41 Compiler compiler = runCompiler(useMirrorHelperLibrary: false, minify: true); | 42 Compiler compiler = runCompiler(useMirrorHelperLibrary: false, minify: true); |
42 DartBackend backend = compiler.backend; | 43 DartBackend backend = compiler.backend; |
43 Map<Node, String> renames = backend.renames; | 44 Map<Node, String> renames = backend.renames; |
44 | 45 |
45 //'Foo' appears twice and now 'invocation' and 'hest' can get the same name. | 46 //'Foo' appears twice and now 'invocation' and 'hest' can get the same name. |
46 Expect.equals(renames.values.toSet().length, renames.values.length - 2); | 47 Expect.equals(renames.values.toSet().length, renames.values.length - 2); |
47 } | 48 } |
48 | 49 |
49 const MEMORY_SOURCE_FILES = const <String, String> { | 50 const MEMORY_SOURCE_FILES = const <String, String> { |
50 'main.dart': """ | 51 'main.dart': """ |
51 import 'dart:mirrors'; | 52 import 'dart:mirrors'; |
52 | 53 |
53 class Foo { | 54 class Foo { |
54 noSuchMethod(invocation) { | 55 noSuchMethod(invocation) { |
55 MirrorSystem.getName(const Symbol('hest')); | 56 MirrorSystem.getName(const Symbol('hest')); |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 main() { | 60 main() { |
60 new Foo().fisk(); | 61 new Foo().fisk(); |
61 var hest; | 62 var hest; |
62 } | 63 } |
63 """}; | 64 """}; |
OLD | NEW |