blob: c88b3605eca4fa943a6699396daa31e0bb0f1bc6 [file] [log] [blame]
// Copyright (c) 2018, 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.
// @dart = 2.9
// Test NaN comparison (dartbug.com/34466 and dartbug.com/34467).
// VMOptions=--no_background_compilation --optimization_counter_threshold=10
import "package:expect/expect.dart";
double dvar = double.nan;
int doit() {
if (!(((-84).toDouble() <= double.nan))) {
return 1;
} else {
return 2;
}
}
doTests() {
Expect.isFalse(dvar > dvar);
Expect.isFalse(dvar < dvar);
Expect.isFalse(dvar <= dvar);
Expect.isFalse(dvar >= dvar);
Expect.isFalse(dvar > -dvar);
Expect.isFalse(-dvar > dvar);
Expect.isTrue(!(dvar > dvar));
Expect.isTrue(!(dvar < dvar));
Expect.isTrue(!(dvar <= dvar));
Expect.isTrue(!(dvar >= dvar));
Expect.isTrue(!(dvar > -dvar));
Expect.isTrue(!(-dvar > dvar));
Expect.equals(1, doit());
Expect.isFalse(dvar == dvar);
Expect.isFalse(dvar == -dvar);
Expect.isTrue(dvar != dvar);
Expect.isTrue(dvar != -dvar);
Expect.isTrue(!(dvar == dvar));
Expect.isTrue(!(dvar == -dvar));
Expect.isFalse(!(dvar != dvar));
Expect.isFalse(!(dvar != -dvar));
}
void main() {
for (int i = 0; i < 20; ++i) {
doTests();
}
}