예제 #1
0
 def testHelloWorldExample(self):
     code=b'-- hello world\n-- by zep\n\nt = 0\n\nmusic(0)\n\nfunction _update()\n t += 1\nend\n\nfunction _draw()\n cls()\n  \n for i=1,11 do\n  for j0=0,7 do\n  j = 7-j0\n  col = 7+j\n  t1 = t + i*4 - j*2\n  x = cos(t0)*5\n  y = 38 + j + cos(t1/50)*5\n  pal(7,col)\n  spr(16+i, 8+i*8 + x, y)\n  end\n end\n \n  print("this is pico-8",\n    37, 70, 14) --8+(t/4)%8)\n\n print("nice to meet you",\n    34, 80, 12) --8+(t/4)%8)\n\n  spr(1, 64-4, 90)\nend\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
     lxr = lexer.Lexer(version=4)
     lxr.process_lines([code])
     tokens = lxr.tokens
     self.assertEqual(lexer.TokComment(b'-- hello world'), tokens[0])
     self.assertEqual(lexer.TokNewline(b'\n'), tokens[1])
     self.assertEqual(lexer.TokComment(b'-- by zep'), tokens[2])
     self.assertEqual(lexer.TokNewline(b'\n'), tokens[3])
예제 #2
0
 def testFromP8PNGFileV0(self):
     pngpath = os.path.join(self.testdata_path, 'test_cart.p8.png')
     with open(pngpath, 'rb') as fh:
         pnggame = game.Game.from_p8png_file(fh)
     first_stat = pnggame.lua.root.stats[0]
     self.assertTrue(isinstance(first_stat, parser.StatFunctionCall))
     tokens = pnggame.lua.tokens
     self.assertEqual(lexer.TokComment('-- memory dump'), tokens[0])
     self.assertEqual(lexer.TokNewline('\n'), tokens[1])
     self.assertEqual(lexer.TokComment('-- by dddaaannn'), tokens[2])
     self.assertEqual(lexer.TokNewline('\n'), tokens[3])