OLD | NEW |
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 createOtherNAN() { | 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.setFloat64(0, double.NAN); | 14 bdata.setFloat64(0, double.NAN); |
15 bdata.setInt8(7, bdata.getInt8(7) ^ 1); // Flip bit 0, big endian. | 15 bdata.setInt8(7, bdata.getInt8(7) ^ 1); // Flip bit 0, big endian. |
16 double result = bdata.getFloat64(0); | 16 double result = bdata.getFloat64(0); |
17 Expect.isTrue(result.isNaN); | 17 Expect.isTrue(result.isNaN); |
18 return result; | 18 return result; |
19 } | 19 } |
20 | 20 |
21 main() { | 21 main() { |
22 var otherNAN = createOtherNAN(); | 22 var otherNAN = createOtherNAN(); |
23 for (int i = 0; i < 100; i++) { | 23 for (int i = 0; i < 100; i++) { |
24 Expect.isFalse(checkIdentical(double.NAN, -double.NAN)); | 24 Expect.isFalse(checkIdentical(double.NAN, -double.NAN)); |
25 Expect.isTrue(checkIdentical(double.NAN, double.NAN)); | 25 Expect.isTrue(checkIdentical(double.NAN, double.NAN)); |
(...skipping 15 matching lines...) Expand all Loading... |
41 Expect.isFalse(checkIdentical(-a, -b)); | 41 Expect.isFalse(checkIdentical(-a, -b)); |
42 Expect.isFalse(checkIdentical(-a, b)); | 42 Expect.isFalse(checkIdentical(-a, b)); |
43 Expect.isFalse(checkIdentical(a, -b)); | 43 Expect.isFalse(checkIdentical(a, -b)); |
44 | 44 |
45 Expect.isTrue(checkIdentical(-(-a), a)); | 45 Expect.isTrue(checkIdentical(-(-a), a)); |
46 Expect.isTrue(checkIdentical(-(-b), b)); | 46 Expect.isTrue(checkIdentical(-(-b), b)); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 checkIdentical(a, b) => identical(a, b); | 50 checkIdentical(a, b) => identical(a, b); |
OLD | NEW |