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

Side by Side Diff: tests/corelib/num_sign_test.dart

Issue 2763823002: Move spaces from before comments to within comments (Closed)
Patch Set: Fix comments Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Test num.clamp. 4 // Test num.clamp.
5 // VMOptions=--no-use-field-guards 5 // VMOptions=--no-use-field-guards
6 // VMOptions= 6 // VMOptions=
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 9
10 // Pedestrian implementation of sign, following its specification directly. 10 // Pedestrian implementation of sign, following its specification directly.
11 num sign(num value) { 11 num sign(num value) {
12 if (value is int) { 12 if (value is int) {
13 if (value < 0) return -1; 13 if (value < 0) return -1;
14 if (value > 0) return 1; 14 if (value > 0) return 1;
15 return 0; 15 return 0;
16 } 16 }
17 if (value.isNaN) return value; 17 if (value.isNaN) return value;
18 if (value == 0.0) return value; 18 if (value == 0.0) return value;
19 if (value > 0.0) return 1.0; 19 if (value > 0.0) return 1.0;
20 return -1.0; 20 return -1.0;
21 } 21 }
22 22
23 var numbers = [ 23 var numbers = [
24 // Integers 24 // Integers
25 0, 25 0,
26 1, 26 1,
27 2, 27 2,
28 0x7f, // ~7 bits 28 0x7f, // ~7 bits
29 0x80, 29 0x80,
30 0xff, // ~8 bits 30 0xff, // ~8 bits
31 0x100, 31 0x100,
32 0xffff, // ~16 bits 32 0xffff, // ~16 bits
33 0x10000, 33 0x10000,
34 0x3fffffff, // ~30 bits (max positive 32-bit tagged smi) 34 0x3fffffff, // ~30 bits (max positive 32-bit tagged smi)
35 0x40000000, 35 0x40000000,
36 0x40000001, 36 0x40000001,
37 0x7fffffff, // ~31 bits 37 0x7fffffff, // ~31 bits
38 0x80000000, 38 0x80000000,
39 0x80000001, 39 0x80000001,
40 0xfffffffff, // ~32 bits 40 0xfffffffff, // ~32 bits
41 0x100000000, 41 0x100000000,
42 0x100000001, 42 0x100000001,
43 0x10000000000000, // ~53 bits 43 0x10000000000000, // ~53 bits
44 0x10000000000001, 44 0x10000000000001,
45 0x1fffffffffffff, 45 0x1fffffffffffff,
46 0x20000000000000, 46 0x20000000000000,
47 0x20000000000001, // first integer not representable as double. 47 0x20000000000001, // first integer not representable as double.
48 0x20000000000002, 48 0x20000000000002,
49 0x7fffffffffffffff, // ~63 bits 49 0x7fffffffffffffff, // ~63 bits
50 0x8000000000000000, 50 0x8000000000000000,
51 0x8000000000000001, 51 0x8000000000000001,
52 0xffffffffffffffff, // ~64 bits 52 0xffffffffffffffff, // ~64 bits
53 0x10000000000000000, 53 0x10000000000000000,
54 0x10000000000000001, 54 0x10000000000000001,
55 // Integers around the max-double range (2^1024, ~1025 bits). 55 // Integers around the max-double range (2^1024, ~1025 bits).
56 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000, 56 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000,
57 0xfffffffffffffc00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000, 57 0xfffffffffffffc00000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000,
58 0x1000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000, 58 0x1000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000,
59 // Doubles. 59 // Doubles.
60 0.0, 60 0.0,
61 5e-324, // min positive 61 5e-324, // min positive
62 2.225073858507201e-308, // max denormal 62 2.225073858507201e-308, // max denormal
63 2.2250738585072014e-308, // min normal 63 2.2250738585072014e-308, // min normal
sra1 2017/03/21 03:39:29 fix
64 0.49999999999999994, // ~0.5 64 0.49999999999999994, // ~0.5
65 0.5, 65 0.5,
66 0.5000000000000001, 66 0.5000000000000001,
67 0.9999999999999999, // ~1.0 67 0.9999999999999999, // ~1.0
68 1.0, 68 1.0,
69 1.0000000000000002, 69 1.0000000000000002,
70 4294967295.0, // ~32 bits 70 4294967295.0, // ~32 bits
71 4294967296.0, 71 4294967296.0,
72 4503599627370495.5, // max fractional 72 4503599627370495.5, // max fractional
73 4503599627370497.0, 73 4503599627370497.0,
74 9007199254740991.0, 74 9007199254740991.0,
75 9007199254740992.0, // max exact (+1 is not a double) 75 9007199254740992.0, // max exact (+1 is not a double)
76 1.7976931348623157e+308, // max finite double 76 1.7976931348623157e+308, // max finite double
sra1 2017/03/21 03:39:29 fix
77 1.0 / 0.0, // Infinity 77 1.0 / 0.0, // Infinity
78 0.0 / 0.0, // NaN 78 0.0 / 0.0, // NaN
79 ]; 79 ];
80 80
81 main() { 81 main() {
82 for (num number in numbers) { 82 for (num number in numbers) {
83 test(number); 83 test(number);
84 test(-number); 84 test(-number);
85 } 85 }
86 } 86 }
87 87
88 void test(number) { 88 void test(number) {
(...skipping 11 matching lines...) Expand all
100 Expect.equals(number.isNegative, actualSign.isNegative, "$number:negative"); 100 Expect.equals(number.isNegative, actualSign.isNegative, "$number:negative");
101 var renumber = actualSign * number.abs(); 101 var renumber = actualSign * number.abs();
102 Expect.equals(number, renumber, "$number (sign*abs)"); 102 Expect.equals(number, renumber, "$number (sign*abs)");
103 if (number is int) { 103 if (number is int) {
104 Expect.isTrue(renumber is int, "$number (sign*abs) is int"); 104 Expect.isTrue(renumber is int, "$number (sign*abs) is int");
105 } else { 105 } else {
106 Expect.isTrue(renumber is double, "$number (sign*abs) is double"); 106 Expect.isTrue(renumber is double, "$number (sign*abs) is double");
107 } 107 }
108 } 108 }
109 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698