| 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 "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 main() { | 11 main() { |
| 12 print(12300000); | 12 print(12300000); |
| 13 print(1234567890123456789012345); | 13 print(1234567890123456789012345); |
| 14 print(double.MAX_FINITE); | 14 print(double.MAX_FINITE); |
| 15 }'''}; | 15 }'''}; |
| 16 | 16 |
| 17 void main() { | 17 void test({bool minify}) { |
| 18 OutputCollector collector = new OutputCollector(); | 18 OutputCollector collector = new OutputCollector(); |
| 19 var compiler = compilerFor(MEMORY_SOURCE_FILES, outputProvider: collector); | 19 var compiler = compilerFor(MEMORY_SOURCE_FILES, |
| 20 outputProvider: collector, |
| 21 options: minify ? ['--minify'] : []); |
| 20 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 22 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 21 // Check that we use the shorter exponential representations. | 23 // Check that we use the shorter exponential representations. |
| 22 String jsOutput = collector.getOutput('', 'js'); | 24 String jsOutput = collector.getOutput('', 'js'); |
| 23 | 25 |
| 24 Expect.isTrue(jsOutput.contains('1.23e+7')); // Shorter than 12300000. | 26 if (minify) { |
| 25 Expect.isTrue(jsOutput.contains('1.2345678901234568e+24')); | 27 Expect.isTrue(jsOutput.contains('123e5')); // Shorter than 12300000. |
| 26 Expect.isTrue(jsOutput.contains('1.7976931348623157e+308')); | 28 Expect.isTrue(jsOutput.contains('12345678901234568e8')); |
| 27 Expect.isFalse(jsOutput.contains('12300000')); | 29 Expect.isTrue(jsOutput.contains('17976931348623157e292')); |
| 30 Expect.isFalse(jsOutput.contains('12300000')); |
| 31 } else { |
| 32 Expect.isTrue(jsOutput.contains('12300000')); |
| 33 Expect.isTrue(jsOutput.contains('1.2345678901234568e+24')); |
| 34 Expect.isTrue(jsOutput.contains('1.7976931348623157e+308')); |
| 35 } |
| 28 Expect.isFalse(jsOutput.contains('1234567890123456789012345')); | 36 Expect.isFalse(jsOutput.contains('1234567890123456789012345')); |
| 29 // The decimal expansion of double.MAX_FINITE has 308 digits. We only check | 37 // The decimal expansion of double.MAX_FINITE has 308 digits. We only check |
| 30 // for its prefix. | 38 // for its prefix. |
| 31 Expect.isFalse(jsOutput.contains('179769313486231570814527423731')); | 39 Expect.isFalse(jsOutput.contains('179769313486231570814527423731')); |
| 32 })); | 40 })); |
| 33 } | 41 } |
| 42 |
| 43 main() { |
| 44 test(minify: true); |
| 45 test(minify: false); |
| 46 } |
| OLD | NEW |