def test_partial(): @coppertop def myunary_(a, b, c): return a + b + c t = myunary_ >> typeOf assert t == (BTTuple(NO_TYPE, NO_TYPE, NO_TYPE)^NO_TYPE) @coppertop def myunary(a:pyint, b:pyint, c:pyint) -> pyint: return a + b + c myunary >> check >> typeOf >> ((pyint*pyint*pyint)^pyint) myunary(1,_,3) >> check >> typeOf >> (pyint^pyint) fxs = tvseq((N ** pyint)[tvseq], [1, 2, 3]) >> each >> myunary(1,_,3) fxs >> check >> typeOf >> (N ** pyint)[tvseq]
def test_drop(): tvseq((N**pystr)[tvseq], ['a','b','c']) >> drop >> (2 | count) >> check >> typeOf >> (N**pystr)[tvseq]
def test_at(): [1,2,3] >> at(_, 0) >> check >> equal >> 1 [1,2,3] >> at(_, 0 | offset) >> check >> equal >> 1 [1,2,3] >> at(_, 1 | index) >> check >> equal >> 1 tvseq((N**index)[tvseq], [1 | index, 2 | index, 3 | index]) >> at(_, 1 | index) >> check >> typeOf >> index
def ppFnOfCard(fn, sep='') -> display_table: return tvseq( display_table, people >> each >> fn >> append >> sep >> join >> (weapons >> each >> fn >> append >> sep) >> join >> (rooms >> each >> fn))
def test_anon(): f = anon(pyint^pyint, lambda x: x + 1) fxs = tvseq((N ** pyint)[tvseq], [1, 2, 3]) >> each >> f fxs >> check >> typeOf >> (N ** pyint)[tvseq] with assertRaises(TypeError): fxs = tvseq((N ** pyint)[tvseq], [1, 2, 3]) >> each >> anon(pystr ^ pystr, lambda x: x + 1)
def join(a:display_table, b:display_table, options={}) -> display_table: return tvseq(display_table, a.data + b.data) >> ljust
def hjoin(a:display_table, b:display_table, options={}) -> display_table: assert (a >> count) == (b >> count) answer = tvseq(display_table, []) for i in range(len(a)): answer.append(a[i] + options.get('sep', '') + b[i]) return answer