예제 #1
0
 def test_slice(self):
     i = preparse(v.i)
     j = preparse(v.j)
     eq_(
         preparse(each(v.i, v.j)[1:3][1:3].loop[prin(v.i)]),
         special.EachForm((i, j), zip(range(1, 3), range(1, 3)),
                          (prin(i), )))
예제 #2
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test_eval_a_x2(self):
   #assert 0, 'repace_def rethink'
   x = v.x
   eq_(eval(do[fun. a(x)[prin(x), x], a(1),
             fun. a(x)[prin(-x), -x], a(1)]), -1)
   eq_(eval(do[fun. a(x)[prin(x), x], a(1),
             fun. a(x, i)[prin(-x, i), -x], a(3), a(1, 2)]), -1)
예제 #3
0
 def test_eval_Case1(self):
     x = preparse(v.x)
     eq_(
         eval(
             case(2).of(1)[prin(1)].of(2, 3)[prin(quote((2, 3))),
                                             quote((2, 3))].els[prin(5)]),
         (2, 3))
예제 #4
0
 def test41(self):
     eq_(
         preparse(fun.a(x) >= at[prin(1)][prin(2)]),
         append_def(a, (x, ), (
             (prin(1), ),
             (prin(2), ),
         ), special.UserFunction))
예제 #5
0
파일: testdinpy.py 프로젝트: chaosim/dao
  def test_eval_protect3(self):
    eq_(eval(
catch(1)
  .do[
       protect [ prin(1), throw(1).do[2], prin(3) ]
           .always[ prin(2) ]
     ]), 2)
예제 #6
0
 def test_getitem1(self):
     i = preparse(v.i)
     j = preparse(v.j)
     eq_(
         preparse(
             each(v.i, v.j)[zip(range(2), range(2))].loop[prin(v.i, v.j)]),
         special.EachForm((i, j), tuple(zip(range(2), range(2))),
                          (prin(i, j), )))
예제 #7
0
 def test_eval_Case3(self):
     x = preparse(v.x)
     eq_(
         eval(
             begin(
                 v.x << quote((1, 2)),
                 case(x).of((1, 2), (3, 4))[prin(x), x].of(2, 3)[prin(
                     (2, 3)), (2, 3)].els[prin(5)])), (1, 2))
예제 #8
0
 def test_eval_a_x2(self):
     #assert 0, 'repace_def rethink'
     x = v.x
     eq_(eval(do[fun.a(x)[prin(x), x],
                 a(1),
                 fun.a(x)[prin(-x), -x],
                 a(1)]), -1)
     eq_(
         eval(do[fun.a(x)[prin(x), x],
                 a(1),
                 fun.a(x, i)[prin(-x, i), -x],
                 a(3),
                 a(1, 2)]), -1)
예제 #9
0
 def test_Case1(self):
     x = preparse(v.x)
     eq_(
         preparse(case(x).of(1)[prin(1)].of(2, 3)[prin(4)].els[prin(5)]),
         special.CaseForm(x, {
             1: (prin(1), ),
             2: (prin(4), ),
             3: (prin(4), )
         }, (prin(5), )))
예제 #10
0
 def test_let2(self):
     let1 = let(v.a << 1).do[prin(1)]
     eq_(preparse(let1), special.let([(a, 1)], prin(1)))
예제 #11
0
 def test9(self):
     eq_(preparse(fun()[prin(1)]), special.FunctionForm(((), prin(1))))
예제 #12
0
 def test6(self):
     eq_(
         preparse(fun.a >= at()[prin(1)]),
         special.begin(
             append_def(a, (), ((prin(1), ), ), special.UserFunction)))
예제 #13
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test_let3(self):
   let1 = let(v.a << v.b << 1).do[prin(1)]
   eq_(preparse(let1), special.let(((b,1), (a,b)), prin(1)))
예제 #14
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test5(self):
   eq_(preparse(fun. a== at()[prin(1)]), 
       special.set(a, special.FunctionForm(((), prin(1)))))
예제 #15
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test5(self):
   eq_(preparse(macro. a== at()[prin(1)]), 
       special.set(a, special.MacroForm(((), prin(1)))))
예제 #16
0
파일: testeval.py 프로젝트: charyorde/dao
 def test_closure2(self):
   eq_(eval(let([(f, macro([[x], prin(x)])),
                 (x, 1)],
            f(x+x))), None) 
예제 #17
0
 def test_when_loop2(self):
     eq_(preparse(when(v.i != 0).loop[prin(v.i)]),
         special.WhenLoopForm(preparse(v.i != 0), (prin(i), )))
예제 #18
0
 def test_when_loop(self):
     eq_(preparse(when(1).loop[prin(1)]),
         special.WhenLoopForm(1, (prin(1), )))
예제 #19
0
 def test_eval_loop_when(self):
     eq_(eval(do[v.i << 0, loop[prin(v.i), ++v.i].when(v.i < 3), v.i]), 3)
예제 #20
0
 def test_loop_when(self):
     eq_(preparse(loop[prin(1)].when(1)),
         special.LoopWhenForm((prin(1), ), 1))
예제 #21
0
파일: testdinpy.py 프로젝트: chaosim/dao
  def test_eval_protect2(self): assert_raises(DaoUncaughtThrow, eval, 
    protect [ prin(1), throw(1).do[2] ] .always[ prin(2) ])

  def test_eval_protect3(self):
예제 #22
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test_eval_protect(self):
   eq_(eval(protect [ prin(1) ] .always[ prin(2) ]), None)
예제 #23
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test_let4(self):
   let1 = let( v.a/ v.b << (1,2)).do[prin(1)]
예제 #24
0
 def test_let4(self):
     let1 = let(v.a / v.b << (1, 2)).do[prin(1)]
예제 #25
0
파일: testeval.py 프로젝트: charyorde/dao
 def test_eval(self):
   eq_(eval(macro([[x, y], eval_(x)],
                  [[x, y],eval_(y)])(prin(1), prin(2))), None) 
예제 #26
0
 def test_loop_until(self):
     eq_(preparse(loop[prin(1)].until(v.i == 1)),
         special.LoopUntilForm((prin(1), ), arith.eq(i, 1)))
예제 #27
0
파일: testeval.py 프로젝트: charyorde/dao
 def test4(self):
   eq_(eval(macro([[x], x])(prin(1))), None) 
예제 #28
0
 def test_eval_loop_until(self):
     eq_(eval(do[v.i << 0, loop[prin(v.i), ++v.i].until(v.i == 3), v.i]), 3)
예제 #29
0
 def testonce(self):
   eq_(eval(findall(once(prin('1, ')|prin('2, ')))), True)
예제 #30
0
 def test3(self):
     eq_(preparse(fun.a(x) >= [prin(1)]),
         append_def(a, (x, ), [(prin(1), )], special.UserFunction))
예제 #31
0
 def test42(self):
     eq_(preparse(fun.a(x) <= at[prin(1)]),
         insert_def(a, (x, ), ((prin(1), ), ), special.UserFunction))
예제 #32
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test_let2(self):
   let1 = let(v.a<<1).do[prin(1)]
   eq_(preparse(let1), special.let([(a,1)], prin(1)))
예제 #33
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test42(self):
   eq_(preparse(fun. a(x)<= at[prin(1)]),
       insert_def(a, (x,), ((prin(1),),), special.UserFunction))
예제 #34
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test61(self):
   eq_(preparse(fun. a<= at()[prin(1)]), 
       special.begin(insert_def(a, (), ((prin(1),),), special.UserFunction)))
예제 #35
0
 def test5(self):
     eq_(preparse(fun.a == at()[prin(1)]),
         special.set(a, special.FunctionForm(((), prin(1)))))
예제 #36
0
 def test_eval_Case2(self):
     x = preparse(v.x)
     eq_(eval(case(3).of(1)[prin(1), 1].of(2)[prin(2), 2].els[prin(3), 3]),
         3)
예제 #37
0
 def test61(self):
     eq_(
         preparse(fun.a <= at()[prin(1)]),
         special.begin(
             insert_def(a, (), ((prin(1), ), ), special.UserFunction)))
예제 #38
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test6(self):
   eq_(preparse(fun. a>= at()[prin(1)]), 
       special.begin(append_def(a, (), ((prin(1),),), special.UserFunction)))
예제 #39
0
 def test5(self):
     eq_(preparse(macro.a == at()[prin(1)]),
         special.set(a, special.MacroForm(((), prin(1)))))
예제 #40
0
 def test_eval_slice(self):
     eq_(
         eval(
             each(v.i, v.j)[1:3][1:3].loop[prin(v.i, v.j),
                                           quote((v.i, v.j))]), None)
예제 #41
0
 def test_let3(self):
     let1 = let(v.a << v.b << 1).do[prin(1)]
     eq_(preparse(let1), special.let(((b, 1), (a, b)), prin(1)))
예제 #42
0
파일: testeval.py 프로젝트: charyorde/dao
 def testiff2(self):
   eq_(eval(iff(((0, prin(1)), (0,prin(2))), prin(3))), None)
예제 #43
0
파일: testeval.py 프로젝트: charyorde/dao
 def test1(self):
   eq_(eval(macro([[], prin(1)])()), None) 
예제 #44
0
파일: testeval.py 프로젝트: charyorde/dao
 def test_unwind_protect_loop(self):
   eq_(eval(let([(i,3)], 
                block(a, set(i, sub(i, 1)), 
                           if_(eq(i, 0), exit_block(a, 1)),
                           unwind_protect(continue_block(a), prin(2))), i)), 0)
예제 #45
0
파일: testeval.py 프로젝트: charyorde/dao
 def test_or_p(self):
   eq_(eval(macro([[x, y], x],
                  [[x, y],y])(prin(1), prin(2))), None) 
예제 #46
0
파일: testeval.py 프로젝트: charyorde/dao
 def testLoopWhen(self):
   eq_(eval(tag_loop_label(let([(i,3)], LoopWhenForm((set(i, sub(i, 1)), prin(i)), 
                                    gt(i,0))))), None)
예제 #47
0
파일: testeval.py 프로젝트: charyorde/dao
 def test_closure3(self):
   eq_(eval(let([(f, function([[x], prin(x)])),
                 (x, 1)],
            f(x+x))), None) 
예제 #48
0
파일: testeval.py 프로젝트: charyorde/dao
 def testEachForm(self):
   eq_(eval(tag_loop_label(EachForm(i, range(3), [prin(i)]))), None)
예제 #49
0
파일: testeval.py 프로젝트: charyorde/dao
 def test_unwind_protect2(self):
   eq_(eval(block('foo', unwind_protect(exit_block('foo', 1), 
                           prin(2), prin(3)))), 1)
예제 #50
0
파일: testdinpy.py 프로젝트: chaosim/dao
 def test9(self):
   eq_(preparse(fun()[prin(1)]), special.FunctionForm(((), prin(1))))
예제 #51
0
파일: testeval.py 프로젝트: charyorde/dao
 def testCaseForm(self):
   eq_(eval(CaseForm(2, {0: [prin(0)], 1:[prin(1)], 2:[prin(2)]}, [prin(3)])), None)
예제 #52
0
 def test_eval_getitem1(self):
     eq_(
         eval(
             each(v.i, v.j)[zip(range(2),
                                range(2))].loop[prin(v.i, v.j),
                                                quote((v.i, v.j))]), None)
예제 #53
0
파일: testeval.py 프로젝트: charyorde/dao
 def testLoopTimes(self):
   eq_(eval(tag_loop_label(let([(i,3)], LoopTimesForm(3, (set(i, sub(i, 1)), prin(i)))))), None)
예제 #54
0
 def test_eval_getitem2(self):
     eq_(
         eval(
             each(v.i, v.j)[range(2)][range(2)].loop[prin(v.i, v.j),
                                                     quote((v.i, v.j))]),
         None)
예제 #55
0
파일: testeval.py 프로젝트: charyorde/dao
 def testLoopUntil(self):
   eq_(eval(tag_loop_label(let([(i,3)], LoopUntilForm((set(i, sub(i, 1)), prin(i)), 
                                    eq(i,0))))), None)
예제 #56
0
 def test_at2(self):
     eq_(preparse(at[prin(1)]), AtForm(((None, ((prin(1), ), )), )))
예제 #57
0
파일: testeval.py 프로젝트: charyorde/dao
 def testEachForm2(self):
   eq_(eval(tag_loop_label(EachForm((i, j), zip(range(3), range(3)), [prin(i, j)]))), None)
예제 #58
0
 def test_eval_a_x(self):
     eq_(eval(do[fun.a(x)[prin(x), x], a(1)]), 1)
예제 #59
0
 def testcall(self):
   eq_(eval(call(unify(x, 1))), True)
   eq_(eval(is_(x, quote(prin(1)))&call(x)), None)
예제 #60
0
 def test2(self):
     eq_(preparse(fun.a(x)[prin(1)]),
         replace_def(a, (x, ), ((prin(1), ), ), UserFunction))