Esempio n. 1
0
 def __init__(self):
     BrainFxxk.__init__(self, ope={
         u'nxt':u'Ook. Ook? ',
         u'prv':u'Ook? Ook. ',
         u'inc':u'Ook. Ook. ',
         u'dec':u'Ook! Ook! ',
         u'put':u'Ook! Ook. ',
         u'get':u'Ook. Ook! ',
         u'opn':u'Ook! Ook? ',
         u'cls':u'Ook? Ook! ',
    })
Esempio n. 2
0
 def test_compile_special_chars(self):
     test_ope = {
         u'nxt':u'a',
         u'prv':u'b',
         u'inc':u'c',
         u'dec':u'd',
         u'put':u'e',
         u'get':u'f',
         u'opn':u'[*]',
         u'cls':u'[*',
     }
     bf = BrainFxxk(test_ope)
     src = bf._compile('[*]aaaacc[*aa')
     tools.eq_(u'[>>>>++]>>', src)
Esempio n. 3
0
 def test_compile_multiple(self):
     test_ope = {
         u'nxt':u'a',
         u'prv':u'b',
         u'inc':u'c',
         u'dec':u'd',
         u'put':u'e',
         u'get':u'f',
         u'opn':u'あい',
         u'cls':u'h',
     }
     bf = BrainFxxk(test_ope)
     src = bf._compile('あいaaaacchaa')
     tools.eq_(u'[>>>>++]>>', src)
Esempio n. 4
0
 def test_cls(self):
     bf = BrainFxxk()
     # for test, insert data
     bf.src = u'[>>>>++]>>'
     bf.cur = 7        
     bf.ptr = 0
     bf.buf[0] = 2
     bf.cls()
     tools.eq_(0, bf.cur)
Esempio n. 5
0
    def test_cls_nest(self):
        bf = BrainFxxk()
        # for test, insert data
        bf.src = u'[->[->>+<<]>>[-<+<+>>]<<<]<'
        bf.ptr = 0

        # ptr = 0
        bf.buf[bf.ptr] = 0
        # out
        bf.cur = 25
        bf.cls()
        tools.eq_(25, bf.cur)
        # in1
        bf.cur = 10
        bf.cls()
        tools.eq_(10, bf.cur)
        # in2
        bf.cur = 21
        bf.cls()
        tools.eq_(21, bf.cur)

        # ptr = 1
        bf.buf[bf.ptr] = 1
        # out
        bf.cur = 25
        bf.cls()
        tools.eq_(0, bf.cur)
        # in1
        bf.cur = 10
        bf.cls()
        tools.eq_(3, bf.cur)
        # in2
        bf.cur = 21
        bf.cls()
        tools.eq_(13, bf.cur)
Esempio n. 6
0
 def test_opn(self):
     bf = BrainFxxk()
     # for test, insert data
     bf.src = u'[>>>>++]>>'        
     bf.opn()
     tools.eq_(7, bf.cur)
Esempio n. 7
0
 def test_dec(self):
     bf = BrainFxxk()
     bf.dec()
     tools.eq_(-1, bf.buf[0])        
Esempio n. 8
0
 def test_inc(self):
     bf = BrainFxxk()
     bf.inc()
     tools.eq_(1, bf.buf[0])        
Esempio n. 9
0
 def test_prv(self):
     bf = BrainFxxk()
     bf.prv()
     tools.eq_(-1, bf.ptr)        
Esempio n. 10
0
 def test_nxt(self):
     bf = BrainFxxk()
     bf.nxt()
     tools.eq_(1, bf.ptr)        
Esempio n. 11
0
 def test_fxxk(self):
     bf = BrainFxxk()
     bf.fxxk(u'>>>>++>>')
     tools.eq_(2, bf.buf[4])
     tools.eq_(6, bf.ptr)