Files
sdk/tests/language/vm/checked_smi_comparison_test.dart
T
Ryan Macnak 2c371ff74e [vm, compiler] Respect --use_slow_path in CheckedSmiOp/Comparison.
TEST=ci
Change-Id: Ib2b1a9b067beb1cbeea2b12355e62a45396697f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192726
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-03-25 17:39:24 +00:00

87 lines
2.0 KiB
Dart

// Copyright (c) 2021, 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.
// VMOptions=
// VMOptions=--use_slow_path
import "package:expect/expect.dart";
@pragma("vm:never-inline")
dynamic hiddenSmi() {
try {
throw 42;
} catch (e) {
return e;
}
return 0;
}
@pragma("vm:never-inline")
dynamic hiddenMint() {
try {
throw 0x8000000000000000;
} catch (e) {
return e;
}
return 0;
}
@pragma("vm:never-inline")
dynamic hiddenDouble() {
try {
throw 3.0;
} catch (e) {
return e;
}
return 0;
}
@pragma("vm:never-inline")
dynamic hiddenCustom() {
try {
throw new Custom();
} catch (e) {
return e;
}
return 0;
}
class Custom {
operator <(other) => "lt";
operator >(other) => "gt";
operator <=(other) => "le";
operator >=(other) => "ge";
operator ==(other) => false;
}
main() {
Expect.equals(false, hiddenSmi() < 2);
Expect.equals(true, hiddenSmi() > 2);
Expect.equals(false, hiddenSmi() <= 2);
Expect.equals(true, hiddenSmi() >= 2);
Expect.equals(false, hiddenSmi() == 2);
Expect.equals(true, hiddenSmi() != 2);
Expect.equals(true, hiddenMint() < 2);
Expect.equals(false, hiddenMint() > 2);
Expect.equals(true, hiddenMint() <= 2);
Expect.equals(false, hiddenMint() >= 2);
Expect.equals(false, hiddenMint() == 2);
Expect.equals(true, hiddenMint() != 2);
Expect.equals(false, hiddenDouble() < 2);
Expect.equals(true, hiddenDouble() > 2);
Expect.equals(false, hiddenDouble() <= 2);
Expect.equals(true, hiddenDouble() >= 2);
Expect.equals(false, hiddenDouble() == 2);
Expect.equals(true, hiddenDouble() != 2);
Expect.equals("lt", hiddenCustom() < 2);
Expect.equals("gt", hiddenCustom() > 2);
Expect.equals("le", hiddenCustom() <= 2);
Expect.equals("ge", hiddenCustom() >= 2);
Expect.equals(false, hiddenCustom() == 2);
Expect.equals(true, hiddenCustom() != 2);
}