blob: dbb48a9e911382927cdd25bb30ca7f43e2700bd2 [file]
from cpp20_spaceship_operator import *
def check_equal(a, b):
if a != b:
raise RuntimeError("{} is not equal to {}".format(a, b))
check_equal(ALIEN, 1)
check_equal(SPACE, 1)
check_equal(COMET, 1)
check_equal(cvar.v, 42)
x = A(1)
y = A(2)
check_equal(spaceship(x, y) < 0, True)
check_equal(spaceship(x, x), 0)
check_equal(spaceship(y, x) > 0, True)
check_equal(f(), 42)
# The defaulted operator<=> has a deduced return type and is ignored, the
# defaulted operator== returns bool and is wrapped.
check_equal(hasattr(Defaulted, "spaceship"), False)
check_equal(Defaulted(1).is_equal(Defaulted(1)), True)
check_equal(Defaulted(1).is_equal(Defaulted(2)), False)
check_equal(DefaultedTrailing(1).is_equal(DefaultedTrailing(1)), True)
check_equal(DefaultedTrailing(1).is_equal(DefaultedTrailing(2)), False)
# The defaulted friend operator<=> is ignored too, so its rename never takes effect.
check_equal("friend_spaceship" in globals(), False)
check_equal(DefaultedFriend(1).v, 1)
# Deleted functions with a deduced return type are ignored.
check_equal(hasattr(Deleted, "spaceship"), False)
check_equal(hasattr(Deleted, "m"), False)