def test_call_args(self): space = ObjSpace() interp = MockInterpreter(space) sin = interp.locate_function("sin") w_res = space.call_args(sin, [space.wrap(1.2)]) assert space.float_w(w_res) == math.sin(1.2) max = interp.locate_function("max") w_res = space.call_args(max, [space.wrap(2), space.wrap(15), space.wrap(3)]) assert space.int_w(w_res) == 15 w_res = space.call_args(max, [W_Reference(space.wrap(2)), space.wrap(15), space.wrap(3)]) assert space.int_w(w_res) == 15 str_repeat = interp.locate_function("str_repeat") w_res = space.call_args(str_repeat, [space.newstr("a"), space.wrap(3)]) assert space.str_w(w_res) == "aaa" source = """<?php function f($a, $b) { return $a + 10 * $b; } """ bc = compile_php('<input>', source, space, interp) interp.run_main(space, bc) f = interp.locate_function("f") w_res = space.call_args(f, [space.wrap(1), space.wrap(2)]) assert space.int_w(w_res) == 21
def test_call_args(self): space = ObjSpace() interp = MockInterpreter(space) sin = interp.locate_function("sin") w_res = space.call_args(sin, [space.wrap(1.2)]) assert space.float_w(w_res) == math.sin(1.2) max = interp.locate_function("max") w_res = space.call_args( max, [space.wrap(2), space.wrap(15), space.wrap(3)]) assert space.int_w(w_res) == 15 w_res = space.call_args( max, [W_Reference(space.wrap(2)), space.wrap(15), space.wrap(3)]) assert space.int_w(w_res) == 15 str_repeat = interp.locate_function("str_repeat") w_res = space.call_args(str_repeat, [space.newstr("a"), space.wrap(3)]) assert space.str_w(w_res) == "aaa" source = """<?php function f($a, $b) { return $a + 10 * $b; } """ bc = compile_php('<input>', source, space, interp) interp.run_main(space, bc) f = interp.locate_function("f") w_res = space.call_args(f, [space.wrap(1), space.wrap(2)]) assert space.int_w(w_res) == 21
def test_parse_misc(): space = ObjSpace() output = run_source(space, ''' echo NULL, 3.5, TRUE; ''') assert output[0] is space.w_Null assert space.float_w(output[1]) == 3.5 assert space.is_true(output[2])