Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "package:expect/expect.dart"; | |
| 6 import "package:async_helper/async_helper.dart"; | |
| 7 import 'memory_compiler.dart'; | |
| 8 | |
| 9 const MEMORY_SOURCE_FILES = const { | |
| 10 'main.dart': ''' | |
| 11 import 'package:expect/expect.dart'; | |
| 12 | |
| 13 @NoInline() | |
| 14 foo(y) => 49912344 + y; | |
| 15 | |
| 16 class A { | |
| 17 @NoInline() | |
| 18 static bar(x) => x + 123455; | |
| 19 | |
| 20 @NoInline() | |
| 21 gee(x, y) => x + y + 81234512; | |
| 22 } | |
| 23 | |
| 24 main() { | |
| 25 print(foo(23412)); | |
| 26 print(A.bar(87654)); | |
| 27 print(new A().gee(1337, 919182)); | |
| 28 }'''}; | |
| 29 | |
| 30 void main() { | |
| 31 OutputCollector collector = new OutputCollector(); | |
| 32 var compiler = compilerFor(MEMORY_SOURCE_FILES, outputProvider: collector); | |
| 33 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | |
| 34 // 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. | |
| 36 String jsOutput = collector.getOutput('', 'js'); | |
| 37 | |
| 38 Expect.isTrue(jsOutput.contains('49912344')); | |
|
karlklose
2015/02/20 09:48:15
I don't think this way of testing is robust enough
floitsch
2015/02/20 10:52:56
We will need to discuss the semantics of @NoInline
| |
| 39 Expect.isTrue(jsOutput.contains('123455')); | |
| 40 Expect.isTrue(jsOutput.contains('81234512')); | |
| 41 Expect.isFalse(jsOutput.contains('49935756')); | |
| 42 Expect.isFalse(jsOutput.contains('211109')); | |
| 43 Expect.isFalse(jsOutput.contains('82155031')); | |
| 44 })); | |
| 45 } | |
| OLD | NEW |