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

Side by Side Diff: pkg/fixnum/test/int_64_vm_test.dart

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 11 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
« no previous file with comments | « no previous file | pkg/intl/lib/number_format.dart » ('j') | runtime/lib/double.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // A test to compare the results of the fixnum library with the Dart VM 5 // A test to compare the results of the fixnum library with the Dart VM
6 6
7 library int64vmtest; 7 library int64vmtest;
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 part '../lib/src/int32.dart'; 10 part '../lib/src/int32.dart';
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 i = (i << 1) | ((rand > 0.5) ? 1 : 0); 49 i = (i << 1) | ((rand > 0.5) ? 1 : 0);
50 } 50 }
51 return new int64.fromInt(i); 51 return new int64.fromInt(i);
52 } 52 }
53 53
54 int _randomInt(int n) { 54 int _randomInt(int n) {
55 double rand = random.nextDouble(); 55 double rand = random.nextDouble();
56 for (int i = 0; i < DISCARD; i++) { 56 for (int i = 0; i < DISCARD; i++) {
57 rand = random.nextDouble(); 57 rand = random.nextDouble();
58 } 58 }
59 return (rand * n).floor().toInt(); 59 return (rand * n).floor();
60 } 60 }
61 61
62 class Op { 62 class Op {
63 String name; 63 String name;
64 Function op; 64 Function op;
65 65
66 Op(String this.name, Function this.op); 66 Op(String this.name, Function this.op);
67 67
68 // Truncate x to a value in the range [-2^63, 2^63 - 1] 68 // Truncate x to a value in the range [-2^63, 2^63 - 1]
69 int trunc64(int x) { 69 int trunc64(int x) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 320 }
321 } 321 }
322 for (int i = 0; i < RANDOM_TESTS; i++) { 322 for (int i = 0; i < RANDOM_TESTS; i++) {
323 int64 randomLong = _randomInt64(); 323 int64 randomLong = _randomInt64();
324 for (int shift = -64; shift <= 64; shift++) { 324 for (int shift = -64; shift <= 64; shift++) {
325 _doTestShift(op, randomLong, shift); 325 _doTestShift(op, randomLong, shift);
326 } 326 }
327 } 327 }
328 } 328 }
329 } 329 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/lib/number_format.dart » ('j') | runtime/lib/double.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698