Exemple #1
0
def eq_default(a, b):
    # This strongly enforces the null and boolean identity.
    # You can't mess it up by multimethod introductions.
    if a == null or b == null:
        return boolean(a == b)
    elif isinstance(a, Boolean) or isinstance(b, Boolean):
        return boolean(a == b)
    # This reflects how the cmp_ operates, with an exception that
    # if cmp cannot succeed, we will use the identity equality.
    args = [a, b]
    method = cmp_.fetch_method(args, True)
    if method is None:
        c = coerce.fetch_method(args, False)
        if c is not None:
            args = cast(c.call(args), List,
                        u"coerce should return a list").contents
            method = cmp_.fetch_method(args, True)
    if method is not None:
        return boolean(
            cast(method.call(args), Integer, u"cmp should return an int").value
            == 0)
    else:
        # This way, the equality and inequality is always defined,
        # even if comparison is not defined for everything.
        return boolean(a == b)
Exemple #2
0
def ge_default(a, b):
    args = [a, b]
    method = cmp_.fetch_method(args, True)
    if method is not None:
        return boolean(
            cast(method.call(args), Integer, u"cmp should return int").value >=
            0)
    else:
        args = cast(coerce.call(args), List, u"coerce should return a list")
        return ge.call_suppressed(args.contents)
Exemple #3
0
def _(a, b):
    return boolean(a.value == b.value)
Exemple #4
0
def ne_default(a, b):
    return boolean(is_false(eq.call([a, b])))
Exemple #5
0
def cmp_le(a, b):
    return boolean(a.number <= b.number)
Exemple #6
0
def cmp_lt(a, b):
    return boolean(a.number < b.number)
Exemple #7
0
def cmp_le(a, b):
    return boolean(a.value <= b.value)
Exemple #8
0
def _(a, b):
    return boolean(a.string == b.string)
Exemple #9
0
def cmp_le(a, b):
    return boolean(a.number <= b.number)
Exemple #10
0
def cmp_gt(a, b):
    return boolean(a.number > b.number)
Exemple #11
0
def cmp_lt(a, b):
    return boolean(a.number < b.number)
Exemple #12
0
def cmp_ge(a, b):
    return boolean(a.value >= b.value)
Exemple #13
0
def cmp_le(a, b):
    return boolean(a.value <= b.value)
Exemple #14
0
def cmp_gt(a, b):
    return boolean(a.value > b.value)
Exemple #15
0
def cmp_lt(a, b):
    return boolean(a.value < b.value)
Exemple #16
0
def _(a, b):
    return boolean(a.number == b.value)
Exemple #17
0
def _(a, b):
    return boolean(a.ref == b.ref)
Exemple #18
0
def cmp_ge(a, b):
    return boolean(a.number >= b.number)
Exemple #19
0
def cmp_gt(a, b):
    return boolean(a.value > b.value)
Exemple #20
0
def ne_default(a, b):
    return boolean(a != b)
Exemple #21
0
def cmp_ge(a, b):
    return boolean(a.value >= b.value)
Exemple #22
0
def eq_default(a, b):
    return boolean(a == b)
Exemple #23
0
def cmp_gt(a, b):
    return boolean(a.number > b.number)
Exemple #24
0
def _(a, b):
    return boolean(a.value == b.value)
Exemple #25
0
def cmp_ge(a, b):
    return boolean(a.number >= b.number)
Exemple #26
0
def _(a, b):
    return boolean(a.number == b.number)
Exemple #27
0
def _(a, b):
    return boolean(a.number != b.number)
Exemple #28
0
def _(a, b):
    return boolean(a.eq(b))
Exemple #29
0
def ne_default(a, b):
    return boolean(a != b)
Exemple #30
0
def eq_default(a, b):
    return boolean(a == b)
Exemple #31
0
def _(a, b):
    return boolean(a.value == b.number)
Exemple #32
0
def _(a, b):
    return boolean(a.eq(b))
Exemple #33
0
def _(a, b):
    return boolean(a.string == b.string)
Exemple #34
0
def cmp_lt(a, b):
    return boolean(a.value < b.value)
Exemple #35
0
def cmp_eq(a, b):
    return boolean(a.eq(b))
Exemple #36
0
def ne_default(a, b):
    return boolean(is_false(eq.call([a, b])))