OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // Test a new statement by itself. | |
5 // VMOptions=--optimization-counter-threshold=4 --no-use-osr | |
6 | |
7 import 'dart:typed_data'; | |
8 | |
9 import "package:expect/expect.dart"; | |
10 | |
11 double uint64toDouble(int i) { | |
12 var buffer = new Uint8List(8).buffer; | |
13 var bdata = new ByteData.view(buffer); | |
14 bdata.setUint64(0, i); | |
15 return bdata.getFloat64(0); | |
16 } | |
17 | |
18 double createOtherNAN() { | |
19 return uint64toDouble((1 << 64) - 2); | |
20 } | |
21 | |
22 main() { | |
23 var otherNAN = createOtherNAN(); | |
24 for (int i = 0; i < 100; i++) { | |
25 Expect.isFalse(checkIdentical(double.NAN, -double.NAN)); | |
26 Expect.isTrue(checkIdentical(double.NAN, double.NAN)); | |
27 Expect.isTrue(checkIdentical(-double.NAN, -double.NAN)); | |
28 | |
29 Expect.isFalse(checkIdentical(otherNAN, -otherNAN)); | |
30 Expect.isTrue(checkIdentical(otherNAN, otherNAN)); | |
31 Expect.isTrue(checkIdentical(-otherNAN, -otherNAN)); | |
32 | |
33 var a = otherNAN; | |
34 var b = double.NAN; | |
35 Expect.isFalse(checkIdentical(a, b)); | |
36 Expect.isFalse(checkIdentical(-a, -b)); | |
37 Expect.isFalse(checkIdentical(-a, b)); | |
38 Expect.isFalse(checkIdentical(a, -b)); | |
39 | |
40 a = -a; | |
41 Expect.isFalse(checkIdentical(a, b)); | |
42 Expect.isFalse(checkIdentical(-a, -b)); | |
43 Expect.isFalse(checkIdentical(-a, b)); | |
44 Expect.isFalse(checkIdentical(a, -b)); | |
45 } | |
koda
2015/06/02 23:41:02
Please also check that -(-x) is identical to x for
srdjan
2015/06/03 00:02:52
Done.
| |
46 } | |
47 | |
48 checkIdentical(a, b) => identical(a, b); | |
OLD | NEW |