예제 #1
0
파일: testparser.py 프로젝트: chaosim/dao
 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)    
예제 #2
0
 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)
예제 #3
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_let3(self):
     x, y = Const('x'), Const('y')
     eq_(eval(let([(x, 1), (y, 2)], add(x, y))), 3)
예제 #4
0
 def test_tuple1(self):
     eq_(eval(qq((1, ))), (1, ))
     eq_(eval(qq((1, 2))), (1, 2))
     eq_(eval(qq((add(1, 1), 2))), (add(1, 1), 2))
예제 #5
0
파일: testgencode.py 프로젝트: chaosim/dao
 def test_add(self):
   result = compile(add(1, 2))
   #expect ='(lambda a0: (lambda a1: (lambda v: v)(a0+a1))(2))(1)'
   expect = '3'
   eq_(result, expect)
예제 #6
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_closure1(self):
     x, f = Const('x'), Const('f')
     eq_(eval(let([(f, macrorules([[x], prin(x)])), (x, 1)], f(add(x, x)))),
         None)
예제 #7
0
파일: testeval.py 프로젝트: hermetique/dao
 def testeval4(self):
     x = Const('x')
     eq_(eval(let([(x, quote(add(1, 1)))], eval_(x))), 2)
예제 #8
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_arithmetic(self):
     eq_(eval(add(1, 2)), 3)
     eq_(eval(sub(1, 1)), 0)
     eq_(eval(mul(2, 2)), 4)
     eq_(eval(div(2, 2)), 1)
예제 #9
0
파일: testeval.py 프로젝트: hermetique/dao
 def testdouble5(self):
     f = Var('f')
     x = Var('x')
     assert_raises(TypeError, eval,
                   let([(f, rules([[x], add(x, x)]))], f(1, 2)))  # passed
예제 #10
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_let3(self):
   x, y = Const('x'), Const('y')
   eq_(eval(let([(x,1), (y,2)], add(x, y))), 3)
예제 #11
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_letrec(self):
   x, y = Const('x'), Const('y')
   eq_(eval(letrec([(x, 1), (y, x)], y)), 1)
   eq_(eval(letrec([(x, 1), (y, add(x, 1))], y)), 2)
예제 #12
0
 def test_add(self):
     result = compile_optimize(add(1, 2))
     expect = il.Integer(3)
     eq_(result, expect)
예제 #13
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_lamda2(self):
   x, y = Const('x'), Const('y')
   eq_(eval(lamda((x, y), add(x, y))(1, 3)), 4)
예제 #14
0
 def test_too_many_unquote(self):
     assert_raises(DaoSyntaxError, eval, qq(uq(uq(add(1, 1)))))
예제 #15
0
 def test_unquote_slice(self):
     eq_(eval(qq(add(uqs(quote((3, 4)))))), add(3, 4))
예제 #16
0
 def test_unquote_add(self):
     eq_(eval(qq(uq(add(1, 1)))), 2)
예제 #17
0
파일: testeval.py 프로젝트: hermetique/dao
 def testletdouble(self):
     x, f = Const('x'), Const('f')
     eq_(eval(let([(f, lamda([x], add(x, x)))], f(1))), 2)
예제 #18
0
파일: testeval.py 프로젝트: chaosim/dao
 def testletdouble(self):
   x, f = Const('x'), Const('f')
   eq_(eval(let([(f, lamda([x], add(x, x)))], f(1))), 2)
예제 #19
0
파일: testeval.py 프로젝트: hermetique/dao
 def testletdouble1(self):
     x, f = Var('x'), MacroVar('f')
     eq_(eval(let([(f, macro([x], add(x, x)))], f(1))), 2)
예제 #20
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_macro2(self):
   x, y = Var('x'), Var('y')
   eq_(eval(macro((x, y), add(x, y))(1, 3)), 4)
예제 #21
0
파일: testeval.py 프로젝트: hermetique/dao
 def testdouble2(self):
     x = Var('x')
     eq_(eval(rules([[x], x])(add(2, 2))), 4)
예제 #22
0
파일: testeval.py 프로젝트: chaosim/dao
 def testletdouble1(self):
   x, f = Var('x'), MacroVar('f')
   eq_(eval(let([(f, macro([x], add(x, x)))], f(1))), 2)
예제 #23
0
파일: testeval.py 프로젝트: hermetique/dao
 def test4(self):
     x = Var('x')
     eq_(eval(macrorules([[x], prin(x)])(add(1, 1))), None)
예제 #24
0
파일: testeval.py 프로젝트: chaosim/dao
 def testletdouble2(self):
   x, f = Const('x'), ConstMacroVar('f')
   eq_(eval(let([(f, macro([x], add(x, x)))], f(1))), 2)
예제 #25
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_closure3(self):
     x, y, f = Const('x'), Const('y'), Const('f')
     eq_(
         eval(
             let([(f, macrorules([[x, y], begin(x, y)])), (x, 1)],
                 f(prin(x), prin(add(x, x))))), None)
예제 #26
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_arithmetic(self):
   eq_(eval(add(1, 2)), 3) 
   eq_(eval(sub(1, 1)), 0)
   eq_(eval(mul(2, 2)), 4)
   eq_(eval(div(2, 2)), 1)
예제 #27
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_callcc(self):
     k = Var('k')
     eq_(eval(add(callcc(lamda((k, ), k(1))), 2)), 3)
예제 #28
0
파일: testeval.py 프로젝트: chaosim/dao
 def testdouble1(self):
   x = Var('x')
   eq_(eval(rules([[x], add(x, x)])(2)), 4)
예제 #29
0
파일: testbuiltin.py 프로젝트: chaosim/dao
 def test_unquote_slice(self):
   eq_(eval(qq(add(uqs(quote((3,4)))))), add(3, 4))
예제 #30
0
파일: testeval.py 프로젝트: chaosim/dao
 def testdouble2(self):
   x = Var('x')
   eq_(eval(rules([[x], x])(add(2, 2))), 4)
예제 #31
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_lamda2(self):
     x, y = Const('x'), Const('y')
     eq_(eval(lamda((x, y), add(x, y))(1, 3)), 4)
예제 #32
0
파일: testeval.py 프로젝트: chaosim/dao
 def testdouble4(self):
   f = Var('f')
   x = Var('x')
   eq_(eval(let([(f, rules([[x], add(x, x)]))], f(f(1)))), 4) 
예제 #33
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_letrec(self):
     x, y = Const('x'), Const('y')
     eq_(eval(letrec([(x, 1), (y, x)], y)), 1)
     eq_(eval(letrec([(x, 1), (y, add(x, 1))], y)), 2)
예제 #34
0
파일: testeval.py 프로젝트: chaosim/dao
 def testdouble5(self):
   f = Var('f')
   x = Var('x')
   assert_raises(TypeError, eval, let([(f, rules([[x], add(x, x)]))], f(1, 2))) # passed
예제 #35
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_macro2(self):
     x, y = Var('x'), Var('y')
     eq_(eval(macro((x, y), add(x, y))(1, 3)), 4)
예제 #36
0
파일: testeval.py 프로젝트: chaosim/dao
 def test3(self):
   x = Var('x')
   eq_(eval(macrorules([[x], add(x, x)])(1)), 2) 
예제 #37
0
파일: testeval.py 프로젝트: hermetique/dao
 def testletdouble2(self):
     x, f = Const('x'), ConstMacroVar('f')
     eq_(eval(let([(f, macro([x], add(x, x)))], f(1))), 2)
예제 #38
0
파일: testeval.py 프로젝트: chaosim/dao
 def test4(self):
   x = Var('x')
   eq_(eval(macrorules([[x], prin(x)])(add(1, 1))), None) 
예제 #39
0
파일: testeval.py 프로젝트: hermetique/dao
 def testdouble1(self):
     x = Var('x')
     eq_(eval(rules([[x], add(x, x)])(2)), 4)
예제 #40
0
파일: testeval.py 프로젝트: chaosim/dao
 def test5(self):
   x = Var('x')
   y = Var('y')
   eq_(eval(let([(y, 1)], macrorules([[x], prin(x)])(add(y, 1)))), None) 
예제 #41
0
파일: testeval.py 프로젝트: hermetique/dao
 def testdouble4(self):
     f = Var('f')
     x = Var('x')
     eq_(eval(let([(f, rules([[x], add(x, x)]))], f(f(1)))), 4)
예제 #42
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_closure1(self):
   x, f = Const('x'), Const('f')
   eq_(eval(let([(f, macrorules([[x], prin(x)])),
                 (x, 1)],
            f(add(x,x)))), None) 
예제 #43
0
파일: testeval.py 프로젝트: hermetique/dao
 def test3(self):
     x = Var('x')
     eq_(eval(macrorules([[x], add(x, x)])(1)), 2)
예제 #44
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_closure2(self):
   x, f = Const('x'), Const('f')
   eq_(eval(let([(f, macrorules([[x], x])),
                 (x, 1)],
            f(add(x,x)))), 2)
예제 #45
0
파일: testeval.py 프로젝트: hermetique/dao
 def test5(self):
     x = Var('x')
     y = Var('y')
     eq_(eval(let([(y, 1)], macrorules([[x], prin(x)])(add(y, 1)))), None)
예제 #46
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_closure3(self):
   x, y, f = Const('x'), Const('y'), Const('f')
   eq_(eval(let([(f, macrorules([[x, y], begin(x, y)])),
                 (x, 1)],
            f(prin(x), prin(add(x,x))))), None) 
예제 #47
0
파일: testeval.py 프로젝트: hermetique/dao
 def test_closure2(self):
     x, f = Const('x'), Const('f')
     eq_(eval(let([(f, macrorules([[x], x])), (x, 1)], f(add(x, x)))), 2)
예제 #48
0
파일: testeval.py 프로젝트: chaosim/dao
 def testeval5(self):
   eq_(eval(eval_(quote(begin(1, 2)))), 2)
   eq_(eval(eval_(quote(begin(1, add(1, 2))))), 3)
예제 #49
0
파일: testeval.py 프로젝트: hermetique/dao
 def testeval5(self):
     eq_(eval(eval_(quote(begin(1, 2)))), 2)
     eq_(eval(eval_(quote(begin(1, add(1, 2))))), 3)
예제 #50
0
 def test_add(self):
   result = cps(add(1, 2))
   expect = il.Clamda(a0, il.Clamda(a1, done()(il.add((a0, a1))))(2))(1)
   eq_(result, expect)
예제 #51
0
파일: testeval.py 프로젝트: hermetique/dao
 def testeval1(self):
     eq_(eval(eval_(quote(add(1, 1)))), (2))
예제 #52
0
파일: testbuiltin.py 프로젝트: chaosim/dao
 def test_tuple1(self):
   eq_(eval(qq((1,))), (1,))
   eq_(eval(qq((1,2))), (1,2))
   eq_(eval(qq((add(1,1),2))), (add(1,1),2))
예제 #53
0
파일: testeval.py 프로젝트: chaosim/dao
 def testeval4(self):
   x = Const('x')
   eq_(eval(let([(x, quote(add(1,1)))], eval_(x))), 2)
예제 #54
0
파일: testoptimize.py 프로젝트: chaosim/dao
 def test_add(self):
   result = compile_optimize(add(1, 2))
   expect = il.Integer(3)
   eq_(result, expect)
예제 #55
0
 def test_add(self):
     result = cps(add(1, 2))
     expect = il.Clamda(a0, il.Clamda(a1, done()(il.add((a0, a1))))(2))(1)
     eq_(result, expect)
예제 #56
0
파일: testeval.py 프로젝트: chaosim/dao
 def testeval1(self):
   eq_(eval(eval_(quote(add(1, 1)))), (2))
예제 #57
0
파일: testbuiltin.py 프로젝트: chaosim/dao
 def test_unquote_add(self):
   eq_(eval(qq(uq(add(1,1)))), 2)
예제 #58
0
파일: testeval.py 프로젝트: chaosim/dao
 def test_callcc(self):
   k = Var('k')
   eq_(eval(add(callcc(lamda((k,), k(1))),2)), 3)
예제 #59
0
파일: testbuiltin.py 프로젝트: chaosim/dao
 def test_too_many_unquote(self):
   assert_raises(DaoSyntaxError, eval, qq(uq(uq(add(1,1)))))
예제 #60
0
 def test_add(self):
     result = compile(add(1, 2))
     #expect ='(lambda a0: (lambda a1: (lambda v: v)(a0+a1))(2))(1)'
     expect = '3'
     eq_(result, expect)