| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
| 7 import 'memory_compiler.dart'; | 7 import 'memory_compiler.dart'; |
| 8 | 8 |
| 9 const MEMORY_SOURCE_FILES = const { | 9 const MEMORY_SOURCE_FILES = const { |
| 10 'main.dart': ''' | 10 'main.dart': ''' |
| 11 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
| 12 | 12 |
| 13 @NoInline() | 13 @NoInline() |
| 14 foo(y) => 49912344 + y; | 14 foo(y) => 49912344 + y; |
| 15 | 15 |
| 16 class A { | 16 class A { |
| 17 var field; | 17 var field; |
| 18 | 18 |
| 19 @NoInline() | 19 @NoInline() |
| 20 A([this.field = 4711]); | 20 A([this.field = 4711]); |
| 21 | 21 |
| 22 @NoInline() | 22 @NoInline() |
| 23 static bar(x) => x + 123455; | 23 static bar(x) => x + 123455; |
| 24 | 24 |
| 25 @NoInline() | 25 @NoInline() |
| 26 gee(x, y) => x + y + 81234512; | 26 gee(x, y) => x + y + 81234512; |
| 27 } | 27 } |
| 28 | 28 |
| 29 main() { | 29 main() { |
| 30 print(foo(23412)); | 30 print(foo(23412)); |
| 31 print(A.bar(87654)); | 31 print(A.bar(87654)); |
| 32 print(new A().gee(1337, 919182)); | 32 print(new A().gee(1337, 919182)); |
| 33 print(new A().field + 1); | 33 print(new A().field + 1); |
| 34 }'''}; | 34 }''' |
| 35 }; |
| 35 | 36 |
| 36 void main() { | 37 void main() { |
| 37 asyncTest(() async { | 38 asyncTest(() async { |
| 38 OutputCollector collector = new OutputCollector(); | 39 OutputCollector collector = new OutputCollector(); |
| 39 CompilationResult result = await runCompiler( | 40 CompilationResult result = await runCompiler( |
| 40 memorySourceFiles: MEMORY_SOURCE_FILES, | 41 memorySourceFiles: MEMORY_SOURCE_FILES, outputProvider: collector); |
| 41 outputProvider: collector); | |
| 42 // Simply check that the constants of the small functions are still in the | 42 // Simply check that the constants of the small functions are still in the |
| 43 // output, and that we don't see the result of constant folding. | 43 // output, and that we don't see the result of constant folding. |
| 44 String jsOutput = collector.getOutput('', 'js'); | 44 String jsOutput = collector.getOutput('', 'js'); |
| 45 | 45 |
| 46 Expect.isTrue(jsOutput.contains('49912344')); | 46 Expect.isTrue(jsOutput.contains('49912344')); |
| 47 Expect.isTrue(jsOutput.contains('123455')); | 47 Expect.isTrue(jsOutput.contains('123455')); |
| 48 Expect.isTrue(jsOutput.contains('81234512')); | 48 Expect.isTrue(jsOutput.contains('81234512')); |
| 49 Expect.isFalse(jsOutput.contains('49935756')); | 49 Expect.isFalse(jsOutput.contains('49935756')); |
| 50 Expect.isFalse(jsOutput.contains('211109')); | 50 Expect.isFalse(jsOutput.contains('211109')); |
| 51 Expect.isFalse(jsOutput.contains('82155031')); | 51 Expect.isFalse(jsOutput.contains('82155031')); |
| 52 Expect.isFalse(jsOutput.contains('4712')); | 52 Expect.isFalse(jsOutput.contains('4712')); |
| 53 }); | 53 }); |
| 54 } | 54 } |
| OLD | NEW |