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()
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())')
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()')
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])
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)
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)
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>'
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>'
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>'
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
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