Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(993)

Side by Side Diff: tests/compiler/dart2js/number_output_test.dart

Issue 944863002: dart2js: don't emit big integers as integer, but instead use their exponential representation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
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 main() {
12 print(12300000);
13 print(1234567890123456789012345);
14 print(double.MAX_FINITE);
15 }'''};
16
17 void main() {
18 OutputCollector collector = new OutputCollector();
19 var compiler = compilerFor(MEMORY_SOURCE_FILES, outputProvider: collector);
20 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
21 // Check that we use the shorter exponential representations.
22 String jsOutput = collector.getOutput('', 'js');
23
24 Expect.isTrue(jsOutput.contains('1.23e+7')); // Shorter than 12300000.
sra1 2015/02/20 17:02:54 123e5 would be better
floitsch 2015/02/20 20:23:20 https://codereview.chromium.org/938323003
25 Expect.isTrue(jsOutput.contains('1.2345678901234568e+24'));
26 Expect.isTrue(jsOutput.contains('1.7976931348623157e+308'));
27 Expect.isFalse(jsOutput.contains('12300000'));
28 Expect.isFalse(jsOutput.contains('1234567890123456789012345'));
29 // The decimal expansion of double.MAX_FINITE has 308 digits. We only check
30 // for its prefix.
31 Expect.isFalse(jsOutput.contains('179769313486231570814527423731'));
32 }));
33 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698