-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_translator.py
31 lines (24 loc) · 987 Bytes
/
test_translator.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
from translator import translator
import unittest
import filecmp
class TranslatorTest(unittest.TestCase):
""" 翻译测试 """
def setUp(self) -> None:
print("Test of translator beginning:")
def tearDown(self) -> None:
print("Test of translator finished.")
def test_hello(self):
print("Testing hello")
translator.translate("./forth/hello.fth", "./tmp/result.tmp")
status = filecmp.cmp('./tmp/result.tmp', './target/hello')
self.assertEqual(status, True)
def test_cat(self):
print("Testing cat")
translator.translate("./forth/cat.fth", "./tmp/result.tmp")
status = filecmp.cmp('./tmp/result.tmp', './target/cat')
self.assertEqual(status, True)
def test_prob2(self):
print("Testing problem2")
translator.translate("./forth/prob2.fth", "./tmp/result.tmp")
status = filecmp.cmp('./tmp/result.tmp', 'target/problem2')
self.assertEqual(status, True)