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

Side by Side Diff: tests/language/nan_identical_test.dart

Issue 1830563003: Fix language test that failed on mips hardware, because the created NaN happened (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | 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) 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 // Test a new statement by itself. 4 // Test a new statement by itself.
5 // VMOptions=--optimization-counter-threshold=4 --no-background-compilation 5 // VMOptions=--optimization-counter-threshold=4 --no-background-compilation
6 6
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
11 double uint64toDouble(int i) { 11 double createOtherNAN() {
12 var buffer = new Uint8List(8).buffer; 12 var buffer = new Uint8List(8).buffer;
13 var bdata = new ByteData.view(buffer); 13 var bdata = new ByteData.view(buffer);
14 bdata.setUint64(0, i); 14 bdata.setFloat64(0, double.NAN);
15 bdata.setInt8(0, bdata.getInt8(0) ^ 1);
15 return bdata.getFloat64(0); 16 return bdata.getFloat64(0);
rmacnak 2016/03/23 22:12:11 var result = bdata.getFloat64(0); Expect.isTrue(re
regis 2016/03/23 22:42:59 Done.
16 } 17 }
17 18
18 double createOtherNAN() {
19 return uint64toDouble((1 << 64) - 2);
20 }
21
22 main() { 19 main() {
23 var otherNAN = createOtherNAN(); 20 var otherNAN = createOtherNAN();
24 for (int i = 0; i < 100; i++) { 21 for (int i = 0; i < 100; i++) {
25 Expect.isFalse(checkIdentical(double.NAN, -double.NAN)); 22 Expect.isFalse(checkIdentical(double.NAN, -double.NAN));
26 Expect.isTrue(checkIdentical(double.NAN, double.NAN)); 23 Expect.isTrue(checkIdentical(double.NAN, double.NAN));
27 Expect.isTrue(checkIdentical(-double.NAN, -double.NAN)); 24 Expect.isTrue(checkIdentical(-double.NAN, -double.NAN));
28 25
29 Expect.isFalse(checkIdentical(otherNAN, -otherNAN)); 26 Expect.isFalse(checkIdentical(otherNAN, -otherNAN));
30 Expect.isTrue(checkIdentical(otherNAN, otherNAN)); 27 Expect.isTrue(checkIdentical(otherNAN, otherNAN));
31 Expect.isTrue(checkIdentical(-otherNAN, -otherNAN)); 28 Expect.isTrue(checkIdentical(-otherNAN, -otherNAN));
(...skipping 10 matching lines...) Expand all
42 Expect.isFalse(checkIdentical(-a, -b)); 39 Expect.isFalse(checkIdentical(-a, -b));
43 Expect.isFalse(checkIdentical(-a, b)); 40 Expect.isFalse(checkIdentical(-a, b));
44 Expect.isFalse(checkIdentical(a, -b)); 41 Expect.isFalse(checkIdentical(a, -b));
45 42
46 Expect.isTrue(checkIdentical(-(-a), a)); 43 Expect.isTrue(checkIdentical(-(-a), a));
47 Expect.isTrue(checkIdentical(-(-b), b)); 44 Expect.isTrue(checkIdentical(-(-b), b));
48 } 45 }
49 } 46 }
50 47
51 checkIdentical(a, b) => identical(a, b); 48 checkIdentical(a, b) => identical(a, b);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698