def test_parallel(self): x = Var('x') eq_(eval(parse_text(parallel(letter(x), char(x)), 'a')), 'a') assert_raises(NoSolutionFound, eval, parse_text(parallel(integer(x), char('3')), '2'))
def test_number(self): x, y, z = Var('y'), Var('x'), Var('z') eq_(eval(begin(parse_text(integer(x), '2'), x)), 2) eq_(eval(begin(parse_text(integer(y), '234'), y)), 234) eq_(eval(begin(parse_text(integer(z), '0232'), z)), 154) #0ctal
x, exp, exp_list, result, y, exp2 = vars('x, exp, exp_list, result, y, exp2') (sexpression1, sexpression, bracket_expression, punct_expression, sexpression_list, atom, maybe_spaces, eval_parse_result) = vars( 'sexpression1, sexpression, bracket_expression, punct_expression, sexpression_list, ' 'atom, maybe_spaces, eval_parse_result') _ = DummyVar('_') def from_sexp(var): return from_(sexpression_module, var) defines = in_module(sexpression_module, define(atom, function( ([x], integer(x)), ([x], dqstring(x)), ([x], symbol(x)) )), define(bracket_expression, function( ([exp_list], and_p(char('('), spaces0(_), from_sexp(sexpression_list)(exp_list), spaces0(_), char(')'))), ([exp_list], and_p(char('['), spaces0(_), from_sexp(sexpression_list)(exp_list), spaces0(_), char(']'))))), define(punct_expression, function( ([L(quote, exp)], and_p(char("'"), from_sexp(sexpression)(exp))), ([L(quasiquote, exp)], and_p(char("`"), from_sexp(sexpression)(exp))), ([L(unquote_splice, exp)], and_p(literal(",@"), from_sexp(sexpression)(exp))), ([L(unquote, exp)], and_p(char(","), from_sexp(sexpression)(exp))))), define(sexpression_list, function(