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

Side by Side Diff: tests/lib/math/double_pow_test.dart

Issue 2247553002: Fix a test to not expect NaNs to be bitwise identical. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // VMOptions=--optimization-counter-threshold=5 --no-background-compilation 4 // VMOptions=--optimization-counter-threshold=5 --no-background-compilation
5 5
6 library math_test; 6 library math_test;
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:math'; 8 import 'dart:math';
9 9
10 void checkVeryClose(double a, double b) { 10 void checkVeryClose(double a, double b) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (d == dint && dint.isOdd) { 110 if (d == dint && dint.isOdd) {
111 // if `x` is -Infinity or -0.0 and `y` is an odd integer, then the 111 // if `x` is -Infinity or -0.0 and `y` is an odd integer, then the
112 // result is`-pow(-x ,y)`. 112 // result is`-pow(-x ,y)`.
113 Expect.identical(-pow(Infinity, d), pow(-Infinity, d)); 113 Expect.identical(-pow(Infinity, d), pow(-Infinity, d));
114 Expect.identical(-pow(0.0, d), pow(-0.0, d)); 114 Expect.identical(-pow(0.0, d), pow(-0.0, d));
115 continue; 115 continue;
116 } 116 }
117 } 117 }
118 // if `x` is -Infinity or -0.0 and `y` is not an odd integer, then the 118 // if `x` is -Infinity or -0.0 and `y` is not an odd integer, then the
119 // result is the same as `pow(-x , y)`. 119 // result is the same as `pow(-x , y)`.
120 Expect.identical(pow(Infinity, d), pow(-Infinity, d)); 120 Expect.equals(pow(Infinity, d), pow(-Infinity, d));
121 Expect.identical(pow(0.0, d), pow(-0.0, d)); 121 Expect.equals(pow(0.0, d), pow(-0.0, d));
Lasse Reichstein Nielsen 2016/08/12 23:52:38 I'm not sure that's what we want. If the problem
Florian Schneider 2016/08/13 00:01:29 Never mind my first attempt: Can't use == on NaN i
122 } 122 }
123 123
124 for (var d in samples) { 124 for (var d in samples) {
125 125
126 if (d.abs() < 1) { 126 if (d.abs() < 1) {
127 // if `y` is Infinity and the absolute value of `x` is less than 1, the 127 // if `y` is Infinity and the absolute value of `x` is less than 1, the
128 // result is 0.0. 128 // result is 0.0.
129 Expect.identical(0.0, pow(d, Infinity)); 129 Expect.identical(0.0, pow(d, Infinity));
130 } else if (d.abs() > 1) { 130 } else if (d.abs() > 1) {
131 // if `y` is Infinity and the absolute value of `x` is greater than 1, 131 // if `y` is Infinity and the absolute value of `x` is greater than 1,
132 // the result is Infinity. 132 // the result is Infinity.
133 Expect.identical(Infinity, pow(d, Infinity)); 133 Expect.identical(Infinity, pow(d, Infinity));
134 } else if (d == -1) { 134 } else if (d == -1) {
135 // if `y` is Infinity and `x` is -1, the result is 1.0. 135 // if `y` is Infinity and `x` is -1, the result is 1.0.
136 Expect.identical(1.0, pow(d, Infinity)); 136 Expect.identical(1.0, pow(d, Infinity));
137 } 137 }
138 // if `y` is -Infinity, the result is `1/pow(x, Infinity)`. 138 // if `y` is -Infinity, the result is `1/pow(x, Infinity)`.
139 Expect.identical(1/pow(d, Infinity), pow(d, -Infinity)); 139 Expect.equals(1/pow(d, Infinity), pow(d, -Infinity));
Lasse Reichstein Nielsen 2016/08/12 23:52:38 Again, this should hold, and if it doesn't because
140 } 140 }
141 141
142 // Some non-exceptional values. 142 // Some non-exceptional values.
143 checkVeryClose(16.0, pow(4.0, 2.0)); 143 checkVeryClose(16.0, pow(4.0, 2.0));
144 checkVeryClose(SQRT2, pow(2.0, 0.5)); 144 checkVeryClose(SQRT2, pow(2.0, 0.5));
145 checkVeryClose(SQRT1_2, pow(0.5, 0.5)); 145 checkVeryClose(SQRT1_2, pow(0.5, 0.5));
146 // Denormal result. 146 // Denormal result.
147 Expect.identical(5e-324, pow(2.0, -1074.0)); 147 Expect.identical(5e-324, pow(2.0, -1074.0));
148 // Overflow. 148 // Overflow.
149 Expect.identical(Infinity, pow(10.0, 309.0)); 149 Expect.identical(Infinity, pow(10.0, 309.0));
150 // Underflow. 150 // Underflow.
151 Expect.identical(0.0, pow(10.0, -325.0)); 151 Expect.identical(0.0, pow(10.0, -325.0));
152 152
153 // Conversion to double. 153 // Conversion to double.
154 154
155 // The second argument is an odd integer as int, but not when converted 155 // The second argument is an odd integer as int, but not when converted
156 // to double. 156 // to double.
157 Expect.identical(Infinity, pow(-0.0, -9223372036854775809)); 157 Expect.identical(Infinity, pow(-0.0, -9223372036854775809));
158 } 158 }
159 159
160 main() { 160 main() {
161 for (int i = 0; i < 10; i++) test(); 161 for (int i = 0; i < 10; i++) test();
162 } 162 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698