dart-sdk/tests/corelib/nan_branching_test.dart
Ryan Macnak 7f9362fb42 [vm, compiler] Avoid extra branch on ARM to handle double comparisons with NaN.
TEST=ci
Change-Id: Ie73a5e11da0fe085a209a6a8f684aaf1f77b696f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322800
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-28 20:16:57 +00:00

35 lines
1.3 KiB
Dart

// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@pragma("vm:never-inline")
@pragma("dart2js:noInline")
double hiddenZero() => double.parse("0.0");
@pragma("vm:never-inline")
@pragma("dart2js:noInline")
double hiddenNaN() => double.parse("NaN");
void main() {
if (hiddenZero() == hiddenNaN()) throw "==";
if (hiddenZero() != hiddenNaN()) {} else throw "!=";
if (hiddenZero() < hiddenNaN()) throw "<";
if (hiddenZero() <= hiddenNaN()) throw "<=";
if (hiddenZero() > hiddenNaN()) throw ">";
if (hiddenZero() >= hiddenNaN()) throw ">=";
if (hiddenNaN() == hiddenNaN()) throw "==";
if (hiddenNaN() != hiddenNaN()) {} else throw "!=";
if (hiddenNaN() < hiddenNaN()) throw "<";
if (hiddenNaN() <= hiddenNaN()) throw "<=";
if (hiddenNaN() > hiddenNaN()) throw ">";
if (hiddenNaN() >= hiddenNaN()) throw ">=";
if (hiddenNaN() == hiddenZero()) throw "==";
if (hiddenNaN() != hiddenZero()) {} else throw "!=";
if (hiddenNaN() < hiddenZero()) throw "<";
if (hiddenNaN() <= hiddenZero()) throw "<=";
if (hiddenNaN() > hiddenZero()) throw ">";
if (hiddenNaN() >= hiddenZero()) throw ">=";
}