def test_times_a2(self): X, Y, S = Var('X'), Var('Y'), Var('S') function1 = function(((Y, ), times(char('a'), 2, 'a', Y))) eq_(eval(begin(parse_text(function1(X), 'aa'), X)), ['a', 'a']) assert_raises(NoSolutionFound, eval, begin(parse_text(function1(X), 'a'), X)) assert_raises(NoSolutionFound, eval, begin(parse_text(and_p(function1(X), eoi), 'aaa'), X))
def testIndentUndent(self): _, n, s, line = DummyVar('_'), Var('n'), Var('s'), Var('line') space = char(' ') ruleList = [(s,function( ((n,), some(line(n)),s(add(n,1))), ((n,), some(line(n))))), (line,function( ((n,), times(space, n),some(letter(_)),any(space),char('\n')))) ] eq_(eval(letr(ruleList, parse_text(s(0), 'a\n b\n c\n'))), True) eq_(eval(letr(ruleList, parse_text(s(0), 'asd\n bdf\n cdfh\n'))), True)
def testIndentUndent(self): _, n, s, line = DummyVar('_'), Var('n'), Var('s'), Var('line') space = char(' ') ruleList = [(s, function(((n, ), some(line(n)), s(add(n, 1))), ((n, ), some(line(n))))), (line, function(((n, ), times(space, n), some(letter(_)), any(space), char('\n'))))] eq_(eval(letr(ruleList, parse_text(s(0), 'a\n b\n c\n'))), True) eq_(eval(letr(ruleList, parse_text(s(0), 'asd\n bdf\n cdfh\n'))), True)
def test_times_an(self): X, Y, S, n = Var('X'), Var('Y'), Var('S'), Var('n') function1 = function( ((Y,), times(char('a'), n, 'a', Y))) eq_(eval(begin(parse_text(function1(X), 'a'), X)), ['a']) eq_(eval(begin(parse_text(function1(X), 'aa'), X)), ['a', 'a']) eq_(eval(begin(parse_text(function1(X), 'aaa'), X)), ['a', 'a', 'a'])
def test_times_a2(self): X, Y, S = Var('X'), Var('Y'), Var('S') function1 = function(((Y,), times(char('a'), 2, 'a', Y))) eq_(eval(begin(parse_text(function1(X),'aa'), X)), ['a', 'a']) assert_raises(NoSolutionFound, eval, begin(parse_text(function1(X), 'a'), X)) assert_raises(NoSolutionFound, eval, begin(parse_text(and_p(function1(X), eoi), 'aaa'), X))
def test_dummy_times(self): _, Y = DummyVar('_'), Var('Y') eq_(eval(begin(parse_text(times(char(_), 3, _, Y), '234'), Y)), ['2','3','4'])
def test_times(self): X, Y = Var('X'), Var('Y') eq_(eval(begin(parse_text(times(char(X), 3, X, Y), '222'), Y)), ['2','2','2']) assert_raises(NoSolutionFound, eval, parse_text(times(char(X), 3, X, Y), '2234'))
def test_times_an(self): X, Y, S, n = Var('X'), Var('Y'), Var('S'), Var('n') function1 = function(((Y, ), times(char('a'), n, 'a', Y))) eq_(eval(begin(parse_text(function1(X), 'a'), X)), ['a']) eq_(eval(begin(parse_text(function1(X), 'aa'), X)), ['a', 'a']) eq_(eval(begin(parse_text(function1(X), 'aaa'), X)), ['a', 'a', 'a'])
def test_dummy_times(self): _, Y = DummyVar('_'), Var('Y') eq_(eval(begin(parse_text(times(char(_), 3, _, Y), '234'), Y)), ['2', '3', '4'])
def test_times(self): X, Y = Var('X'), Var('Y') eq_(eval(begin(parse_text(times(char(X), 3, X, Y), '222'), Y)), ['2', '2', '2']) assert_raises(NoSolutionFound, eval, parse_text(times(char(X), 3, X, Y), '2234'))