def test_ref_integraton_with_dsl(self): y = P.Ref('y') assert 5 == P.Pipe( 1, P + 4, P.On(y), P * 10, 'y' ) assert 5 == P.Pipe( 1, P + 4, P.On(y), P * 10, 'y' ) assert 5 == P.Pipe( 1, P + 4, P.On('y'), P * 10, 'y' )
def test_ref_props(self): a = P.Ref('a') b = P.Ref('b') assert [7, 3, 5] == P.Pipe( 1, add2, a.set, add2, b.set, add2, [ (), a, b ] )
def test_context(self): y = P.Ref('y') length = P.Pipe( "phi/tests/test.txt", P.With( open, Context, Obj.read(), { y }, len ) ) assert length == 11 assert y() == "hello world"
def test_reference(self): add_ref = P.Ref('add_ref') assert 8 == 3 >> P.Make(P.add(2).On(add_ref).add(3)) assert 5 == add_ref()