| 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; |
| 18 |
| 19 @NoInline() |
| 20 A([this.field = 4711]); |
| 21 |
| 17 @NoInline() | 22 @NoInline() |
| 18 static bar(x) => x + 123455; | 23 static bar(x) => x + 123455; |
| 19 | 24 |
| 20 @NoInline() | 25 @NoInline() |
| 21 gee(x, y) => x + y + 81234512; | 26 gee(x, y) => x + y + 81234512; |
| 22 } | 27 } |
| 23 | 28 |
| 24 main() { | 29 main() { |
| 25 print(foo(23412)); | 30 print(foo(23412)); |
| 26 print(A.bar(87654)); | 31 print(A.bar(87654)); |
| 27 print(new A().gee(1337, 919182)); | 32 print(new A().gee(1337, 919182)); |
| 33 print(new A().field + 1); |
| 28 }'''}; | 34 }'''}; |
| 29 | 35 |
| 30 void main() { | 36 void main() { |
| 31 OutputCollector collector = new OutputCollector(); | 37 OutputCollector collector = new OutputCollector(); |
| 32 var compiler = compilerFor(MEMORY_SOURCE_FILES, outputProvider: collector); | 38 var compiler = compilerFor(MEMORY_SOURCE_FILES, outputProvider: collector); |
| 33 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 39 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 34 // Simply check that the constants of the small functions are still in the | 40 // Simply check that the constants of the small functions are still in the |
| 35 // output, and that we don't see the result of constant folding. | 41 // output, and that we don't see the result of constant folding. |
| 36 String jsOutput = collector.getOutput('', 'js'); | 42 String jsOutput = collector.getOutput('', 'js'); |
| 37 | 43 |
| 38 Expect.isTrue(jsOutput.contains('49912344')); | 44 Expect.isTrue(jsOutput.contains('49912344')); |
| 39 Expect.isTrue(jsOutput.contains('123455')); | 45 Expect.isTrue(jsOutput.contains('123455')); |
| 40 Expect.isTrue(jsOutput.contains('81234512')); | 46 Expect.isTrue(jsOutput.contains('81234512')); |
| 41 Expect.isFalse(jsOutput.contains('49935756')); | 47 Expect.isFalse(jsOutput.contains('49935756')); |
| 42 Expect.isFalse(jsOutput.contains('211109')); | 48 Expect.isFalse(jsOutput.contains('211109')); |
| 43 Expect.isFalse(jsOutput.contains('82155031')); | 49 Expect.isFalse(jsOutput.contains('82155031')); |
| 50 Expect.isFalse(jsOutput.contains('4712')); |
| 44 })); | 51 })); |
| 45 } | 52 } |
| OLD | NEW |