/
python_transpiler_test.py
executable file
·51 lines (41 loc) · 1.11 KB
/
python_transpiler_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3
import python_transpiler
import unittest
class TestPythonTranspile(unittest.TestCase):
def setUp(self):
self.pt = python_transpiler.PythonTranspiler()
def test_print_float(self):
ret = self.pt.instrs([
{
'type': 'print',
'value': {
'type': 'float',
'value': 5.2,
},
},
])
self.assertEqual('print(5.2)\n', ret)
def test_print_int(self):
ret = self.pt.instrs([
{
'type': 'print',
'value': {
'type': 'int',
'value': 5,
},
},
])
self.assertEqual('print(5)\n', ret)
def test_print_string(self):
ret = self.pt.instrs([
{
'type': 'print',
'value': {
'type': 'string',
'value': 'foo',
},
},
])
self.assertEqual("print('foo')\n", ret)
if __name__ == '__main__':
unittest.main()