| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 7 import 'package:compiler/compiler_new.dart'; |
| 7 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 8 import 'memory_compiler.dart'; | 9 import 'memory_compiler.dart'; |
| 9 | 10 |
| 10 const MEMORY_SOURCE_FILES = const { | 11 const MEMORY_SOURCE_FILES = const { |
| 11 'main.dart': ''' | 12 'main.dart': ''' |
| 12 main() { | 13 main() { |
| 13 print(12300000); | 14 print(12300000); |
| 14 print(1234567890123456789012345); | 15 print(1234567890123456789012345); |
| 15 print(double.MAX_FINITE); | 16 print(double.MAX_FINITE); |
| 16 print(-22230000); | 17 print(-22230000); |
| 17 }''' | 18 }''' |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 Future test({bool minify}) async { | 21 Future test({bool minify}) async { |
| 21 OutputCollector collector = new OutputCollector(); | 22 OutputCollector collector = new OutputCollector(); |
| 22 await runCompiler( | 23 await runCompiler( |
| 23 memorySourceFiles: MEMORY_SOURCE_FILES, | 24 memorySourceFiles: MEMORY_SOURCE_FILES, |
| 24 outputProvider: collector, | 25 outputProvider: collector, |
| 25 options: minify ? ['--minify'] : []); | 26 options: minify ? ['--minify'] : []); |
| 26 | 27 |
| 27 // Check that we use the shorter exponential representations. | 28 // Check that we use the shorter exponential representations. |
| 28 String jsOutput = collector.getOutput('', 'js'); | 29 String jsOutput = collector.getOutput('', OutputType.js); |
| 29 print(jsOutput); | 30 print(jsOutput); |
| 30 | 31 |
| 31 if (minify) { | 32 if (minify) { |
| 32 Expect.isTrue(jsOutput.contains('123e5')); // Shorter than 12300000. | 33 Expect.isTrue(jsOutput.contains('123e5')); // Shorter than 12300000. |
| 33 Expect.isFalse(jsOutput.contains('12300000')); | 34 Expect.isFalse(jsOutput.contains('12300000')); |
| 34 Expect.isTrue(jsOutput.contains('-2223e4')); // Shorter than -22230000. | 35 Expect.isTrue(jsOutput.contains('-2223e4')); // Shorter than -22230000. |
| 35 Expect.isFalse(jsOutput.contains('-22230000')); | 36 Expect.isFalse(jsOutput.contains('-22230000')); |
| 36 } else { | 37 } else { |
| 37 Expect.isTrue(jsOutput.contains('12300000')); | 38 Expect.isTrue(jsOutput.contains('12300000')); |
| 38 Expect.isTrue(jsOutput.contains('-22230000')); | 39 Expect.isTrue(jsOutput.contains('-22230000')); |
| 39 } | 40 } |
| 40 Expect.isTrue(jsOutput.contains('12345678901234568e8')); | 41 Expect.isTrue(jsOutput.contains('12345678901234568e8')); |
| 41 Expect.isTrue(jsOutput.contains('17976931348623157e292')); | 42 Expect.isTrue(jsOutput.contains('17976931348623157e292')); |
| 42 Expect.isFalse(jsOutput.contains('1234567890123456789012345')); | 43 Expect.isFalse(jsOutput.contains('1234567890123456789012345')); |
| 43 // The decimal expansion of double.MAX_FINITE has 308 digits. We only check | 44 // The decimal expansion of double.MAX_FINITE has 308 digits. We only check |
| 44 // for its prefix. | 45 // for its prefix. |
| 45 Expect.isFalse(jsOutput.contains('179769313486231570814527423731')); | 46 Expect.isFalse(jsOutput.contains('179769313486231570814527423731')); |
| 46 } | 47 } |
| 47 | 48 |
| 48 main() { | 49 main() { |
| 49 asyncTest(() async { | 50 asyncTest(() async { |
| 50 await test(minify: true); | 51 await test(minify: true); |
| 51 await test(minify: false); | 52 await test(minify: false); |
| 52 }); | 53 }); |
| 53 } | 54 } |
| OLD | NEW |