def compose_test(): composed = compose( sub2, double, add10 ) assert_equal(composed(100), 218)
def pipe_test(): piped = pipe( sub2, double, add10 ) assert_equal(piped(100), (100-2)*2+10)
def tap_test(): called_box = [False] def set_called(v): called_box[0] = True assert_equal(tap(set_called, 42), 42) assert called_box[0]
def identity_test(): assert_equal(identity(3), 3)
def product_test(): assert_equal(product([2, 3, 5]), 30)
def min_test(): assert_equal(min([3, 1, 4, 2]), 1)
def subtract_nocurry_test(): assert_equal(subtract(4, 3), 1)
def apply_nocurry_test(): assert_equal(apply(add, [1, 2]), 3)
def greater_curry_test(): min5 = greater(5) assert_equal(min5(3), 5) assert_equal(min5(7), 7)
def item_path_curry_test(): get_abc = item_path(["a", "b", "c"]) assert_equal(get_abc(test_dict), "foo")
def item_path_nocurry_test(): assert_equal(item_path(["a", "b", "c"], test_dict), "foo")
def lesser_curry_test(): max5 = lesser(5) assert_equal(max5(3), 3) assert_equal(max5(7), 5)
def lesser_nocurry_test(): assert_equal(lesser(5, 3), 3) assert_equal(lesser(5, 7), 5)
def if_else_curry_test(): inc_away_from_zero = if_else(positive, inc, dec) assert_equal(inc_away_from_zero(5), 6) assert_equal(inc_away_from_zero(-5), -6)
def if_else_nocurry_test(): assert_equal(if_else(positive, inc, dec, 5), 6) assert_equal(if_else(positive, inc, dec, -5), -6)
def getitem_nocurry_item(): assert_equal(getitem("a", {"a": 1}), 1)
def getattr_curry_test(): assert_equal(getattr("val")(test_object), "foo")
def multiply_nocurry_test(): assert_equal(multiply(3, 6), 18)
def divide_nocurry_test(): assert_equal(divide(10, 5), 2)
def multiply_curry_test(): assert_equal(multiply(3)(6), 18)
def apply_curry_test(): assert_equal(apply(add)([1, 2]), 3)
def modulo_nocurry_test(): assert_equal(modulo(12, 5), 2) assert_equal(modulo(-12, 5), 3)
def compose_test(): composed = compose(sub2, double, add10) assert_equal(composed(100), 218)
def modulo_curry_test(): assert_equal(modulo(12)(5), 2)
def subtract_curry_test(): assert_equal(subtract(4)(3), 1)
def find_nocurry_test(): assert_equal(find(positive, [-2, -1, 0, 1, 2]), 1)
def negate_test(): assert_equal(negate(5), -5)
def add_nocurry_test(): assert_equal(add(1, 2), 3)
def run_f_curry_cases(fc): assert_equal(fc(1, 1, 1), 3) assert_equal(fc(1, 1), 5) assert_equal(fc(1)(1), 5) assert_equal(fc(1)(1, 1), 3) assert_equal(fc(x=1, y=1, z=1), 3) assert_equal(fc(x=1, y=1), 5) assert_equal(fc(1)(y=1, z=1), 3) assert_equal(fc(1)(y=1), 5) assert_equal(fc(z=10)(1, 1), 12) assert_equal(fc(y=10)(1), 14)
def add_curry_test(): assert_equal(add(1)(2), 3)
def mean_test(): assert_equal(mean([3, 5, 7]), 5) assert_equal(mean([5, 7, 3]), 5)
def dec_test(): assert_equal(dec(5), 4)
def getitem_curry_item(): assert_equal(getitem("a")({"a": 1}))
def sum_test(): assert_equal(sum([1, 2, 3]), 6)
def greater_nocurry_test(): assert_equal(greater(5, 3), 5) assert_equal(greater(5, 7), 7)
def reduce_nocurry_test(): assert_equal(reduce(string_append, "", ["aa", "bb", "cc"]), "aabbcc")
def inc_test(): assert_equal(inc(5), 6)
def max_test(): assert_equal(max([1, 3, 4, 2]), 4)
def divide_curry_test(): assert_equal(divide(10)(5), 2)
def always_curry_test(): always3 = always(3) assert_equal(always3("foo"), 3)