Example #1
0
def pipe_test():
    piped = pipe(
        sub2,
        double,
        add10
    )
    assert_equal(piped(100), (100-2)*2+10)
Example #2
0
def compose_test():
    composed = compose(
        sub2,
        double,
        add10
    )
    assert_equal(composed(100), 218)
Example #3
0
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]
Example #4
0
def divide_nocurry_test():
    assert_equal(divide(10, 5), 2)
Example #5
0
def greater_curry_test():
    min5 = greater(5)
    assert_equal(min5(3), 5)
    assert_equal(min5(7), 7)
Example #6
0
def getattr_curry_test():
    assert_equal(getattr("val")(test_object), "foo")
Example #7
0
def identity_test():
    assert_equal(identity(3), 3)
Example #8
0
def min_test():
    assert_equal(min([3, 1, 4, 2]), 1)
Example #9
0
def subtract_nocurry_test():
    assert_equal(subtract(4, 3), 1)
Example #10
0
def multiply_curry_test():
    assert_equal(multiply(3)(6), 18)
Example #11
0
def multiply_nocurry_test():
    assert_equal(multiply(3, 6), 18)
Example #12
0
def item_path_curry_test():
    get_abc = item_path(["a", "b", "c"])
    assert_equal(get_abc(test_dict), "foo")
Example #13
0
def item_path_nocurry_test():
    assert_equal(item_path(["a", "b", "c"], test_dict), "foo")
Example #14
0
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)
Example #15
0
def if_else_nocurry_test():
    assert_equal(if_else(positive, inc, dec, 5), 6)
    assert_equal(if_else(positive, inc, dec, -5), -6)
Example #16
0
def reduce_nocurry_test():
    assert_equal(reduce(string_append, "", ["aa", "bb", "cc"]), "aabbcc")
Example #17
0
def max_test():
    assert_equal(max([1, 3, 4, 2]), 4)
Example #18
0
def modulo_nocurry_test():
    assert_equal(modulo(12, 5), 2)
    assert_equal(modulo(-12, 5), 3)
Example #19
0
def subtract_curry_test():
    assert_equal(subtract(4)(3), 1)
Example #20
0
def modulo_curry_test():
    assert_equal(modulo(12)(5), 2)
Example #21
0
def negate_test():
    assert_equal(negate(5), -5)
Example #22
0
def find_nocurry_test():
    assert_equal(find(positive, [-2, -1, 0, 1, 2]), 1)
Example #23
0
def mean_test():
    assert_equal(mean([3, 5, 7]), 5)
    assert_equal(mean([5, 7, 3]), 5)
Example #24
0
def add_nocurry_test():
    assert_equal(add(1, 2), 3)
Example #25
0
def greater_nocurry_test():
    assert_equal(greater(5, 3), 5)
    assert_equal(greater(5, 7), 7)
Example #26
0
def add_curry_test():
    assert_equal(add(1)(2), 3)
Example #27
0
def inc_test():
    assert_equal(inc(5), 6)
Example #28
0
def sum_test():
    assert_equal(sum([1, 2, 3]), 6)
Example #29
0
def divide_curry_test():
    assert_equal(divide(10)(5), 2)
Example #30
0
def always_curry_test():
    always3 = always(3)
    assert_equal(always3("foo"), 3)