コード例 #1
0
def test_base_iterator_Count_Inner_List():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, List[List[object]], List[int],
                                term_info('a', List[object]), term_info('a.Count()', int), False)
    r = s._inner_lambda(term_info('b', List[object]), 'Select')
    assert r.term == 'b.Select(lambda e0001: e0001.Count())'
    assert _is_of_type(r.type, List[int])
コード例 #2
0
def test_base_iterator_obj_to_obj():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, object, object,
                                term_info('a', object), term_info('a', object), False)
    r = s._inner_lambda(term_info('b', object), 'Select')
    assert r.term == 'b'
    assert _is_of_type(r.type, object)
コード例 #3
0
def test_base_iterator_int_to_int():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, int, int,
                                term_info('a', int), term_info('a+1', int), False)
    r = s._inner_lambda(term_info('b', int), 'Select')
    assert r.term == 'b+1'
    assert _is_of_type(r.type, int)
コード例 #4
0
def test_base_iterator_List_to_2List():
    a = ast.Num(n=10)
    s = statement_base_iterator(a, List[List[int]], List[List[int]],
                                term_info('a', int), term_info('a+1', int), False)
    r = s._inner_lambda(term_info('b', int), 'Select')
    assert r.term == 'b.Select(lambda e0001: e0001.Select(lambda e0002: e0002+1))'
    assert _is_of_type(r.type, List[List[int]])
コード例 #5
0
def test_where_copy_monad_through():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool, ['dude']))
    assert w.has_monad_refs()
コード例 #6
0
def test_select_copies_monads():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb, term_info('eb.pt()', float, ['dude']))
    assert w.has_monad_refs()
コード例 #7
0
def test_where_obj_apply_notseq(object_stream):
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))

    w.apply(object_stream)
    object_stream.Where.assert_called_once_with('lambda eb: eb > 10.0')
コード例 #8
0
def test_where_obj_apply_seq(object_stream):
    a = ast.Num(n=10)
    rep_type = List[int]

    w = statement_where(a, rep_type, term_info('eb', int),
                        term_info('eb > 10.0', bool))

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb.Where(lambda e0001: e0001 > 10.0)')
コード例 #9
0
def test_select_obj_apply_notseq(object_stream):
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb, term_info('eb.pt()', float))

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb.pt()')
コード例 #10
0
def test_select_obj_apply_seq(object_stream):
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb, term_info('eb.pt()', float))

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb.Select(lambda e0001: e0001.pt())')
コード例 #11
0
def test_select_obj_apply_func_txt_seq():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb, term_info('eb.pt()', float))

    r = w.apply_as_function(term_info('e5', List[object]))
    assert r.term == 'e5.Select(lambda e0001: e0001.pt())'
    assert _is_of_type(r.type, List[float])
コード例 #12
0
def test_where_apply_func_seq():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))

    trm = w.apply_as_function(term_info('e10', List[object]))
    assert trm.term == 'e10.Where(lambda e0001: e0001 > 10.0)'
    assert _is_of_type(trm.type, List[object])
コード例 #13
0
def test_select_obj_apply_func_txt_notseq():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb, term_info('eb.pt()', float))

    r = w.apply_as_function(term_info('e5', object))
    assert r.term == 'e5.pt()'
    assert _is_of_type(r.type, float)
コード例 #14
0
def test_where_obj_apply_notseq_prev_monad(object_stream):
    a = ast.Num(n=10)
    rep_type = float
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    w.prev_statement_is_monad()

    w.apply(object_stream)
    object_stream.Where.assert_called_once_with('lambda eb: eb[0] > 10.0')
コード例 #15
0
def test_where_pass_through_monad(object_stream):
    a = ast.Num(n=10)
    rep_type = List[float]
    eb = term_info('eb', float)

    f = term_info('eb > <monad-ref>[1]', bool, ['<monad-ref>'])
    w = statement_where(a, rep_type, eb, f)

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with(
        'lambda eb: eb[0].Where(lambda e0001: e0001 > eb[1])')
コード例 #16
0
def test_where_obj_add_monad_noseq(object_stream):
    a = ast.Num(n=10)
    rep_type = float
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    index = w.add_monad('em', 'em.jets()')
    assert index == 1

    w.apply(object_stream)
    object_stream.Where.assert_called_once_with('lambda eb: (eb > 10.0, eb.jets())')
コード例 #17
0
def test_where_obj_apply_seq_prev_monad(object_stream):
    a = ast.Num(n=10)
    rep_type = List[int]
    eb = term_info('eb', int)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    w.prev_statement_is_monad()

    w.apply(object_stream)
    object_stream.Select.assert_called_once_with('lambda eb: eb[0]'
                                                 '.Where(lambda e0001: e0001 > 10.0)')
コード例 #18
0
def test_where_apply_func_seq_prev_monad():
    a = ast.Num(n=10)
    rep_type = List[float]
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    w.prev_statement_is_monad()

    trm = w.apply_as_function(term_info('e10', List[float]))
    assert trm.term == 'e10[0].Where(lambda e0001: e0001 > 10.0)'
    assert _is_of_type(trm.type, List[float])
コード例 #19
0
def test_select_obj_apply_func_unwrap():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w_base = statement_select(a, rep_type, List[float], eb, term_info('eb.pt()', float))
    w = w_base.unwrap()

    r = w.apply_as_function(term_info('e5', object))
    assert r.term == 'e5.pt()'
    assert _is_of_type(r.type, float)
コード例 #20
0
def test_where_pass_func_through_monad():
    a = ast.Num(n=10)
    rep_type = List[int]
    eb = term_info('eb', int)

    f = term_info('eb > <monad-ref>[1]', bool, ['<monad-ref>'])
    w = statement_where(a, rep_type, eb, f)

    trm = w.apply_as_function(term_info('e10', List[int]))
    assert trm.term == 'e10[0].Where(lambda e0001: e0001 > <monad-ref>[1])'
    assert len(trm.monad_refs) == 1
コード例 #21
0
def test_where_func_add_monad_seq():
    a = ast.Num(n=10)
    rep_type = List[float]
    eb = term_info('eb', float)

    w = statement_where(a, rep_type, eb, term_info('eb > 10.0', bool))
    index = w.add_monad('em', 'em.jets()')
    assert index == 1

    trm = w.apply_as_function(term_info('e10', List[float]))
    assert trm.term == '(e10.Where(lambda e0001: e0001 > 10.0), e10.jets())'
    assert _is_of_type(trm.type, List[float])
コード例 #22
0
def test_select_apply_pass_monad_ref_through():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb,
                         term_info('eb.pt()', float))
    r = w.apply_as_function(term_info('e5', List[object], ['<monad-ref>']))

    assert r.term == 'e5.Select(lambda e0001: e0001.pt())'
    assert _is_of_type(r.type, List[float])
    assert len(r.monad_refs) == 1
    assert r.monad_refs[0] == '<monad-ref>'
コード例 #23
0
def test_select_apply_func_monad_passed():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[object], eb,
                         term_info('<monad-ref>[1].pt(eb.index)', object))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref>')
    r = w.apply_as_function(term_info('e5', List[object]))

    assert r.term == 'e5[0].Select(lambda e0001: <monad-ref>[1].pt(e0001.index))'
    assert _is_of_type(r.type, List[object])
    assert len(r.monad_refs) == 1
    assert r.monad_refs[0] == '<monad-ref>'
コード例 #24
0
def test_select_apply_func_monad_new_sequence():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[object], eb,
                         term_info('<monad-ref>[1].jets()', List[object]))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref>')
    r = w.apply_as_function(term_info('e5', object))

    assert r.term == '<monad-ref>[1].jets()'
    assert _is_of_type(r.type, List[object])
    assert len(r.monad_refs) == 1
    assert r.monad_refs[0] == '<monad-ref>'
コード例 #25
0
def test_select_apply_gain_monad_ref_through():
    a = ast.Num(n=10)
    rep_type = List[object]
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, List[float], eb,
                         term_info('eb.pt()', float))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref-1>')
    r = w.apply_as_function(term_info('e5', List[object], ['<monad-ref-2>']))

    assert r.term == 'e5[0].Select(lambda e0001: e0001.pt())'
    assert _is_of_type(r.type, List[float])
    assert '<monad-ref-1>' in r.monad_refs
    assert '<monad-ref-2>' in r.monad_refs
    assert len(r.monad_refs) == 2
コード例 #26
0
def test_select_apply_func_wrap_monad_passthrough():
    a = ast.Num(n=10)
    rep_type = object
    eb = term_info('eb', object)

    w = statement_select(a, rep_type, float, eb,
                         term_info('eb.pt()+<monad-ref-1>[0]', float))
    w.prev_statement_is_monad()
    w.set_monad_ref('<monad-ref-1>')

    unwrapped = w.wrap()

    r = unwrapped.apply_as_function(term_info('e5', List[object], ['<monad-ref-2>']))

    assert len(r.monad_refs) == 2
    assert '<monad-ref-1>' in r.monad_refs
    assert '<monad-ref-2>' in r.monad_refs