automatic regressive testing

This commit is contained in:
Yuyao Huang
2024-04-19 14:54:32 +08:00
parent 3879263121
commit 5017ce2736
8 changed files with 57 additions and 12 deletions
+6 -3
View File
@@ -1,4 +1,4 @@
from trace_commentor import Commentor
from test_utils import *
def test_function_def():
@@ -6,5 +6,8 @@ def test_function_def():
@Commentor()
def target():
pass
print(target())
asserteq_or_print(target(), '''
def target():
pass
''')
+27 -2
View File
@@ -1,4 +1,5 @@
from trace_commentor import Commentor
from test_utils import asserteq_or_print
def test_binop():
@@ -6,5 +7,29 @@ def test_binop():
@Commentor()
def target():
1 + 1
print(target())
asserteq_or_print(
target(), '''
def target():
1 + 1
"""
2 : 1 + 1
"""
''')
def test_binop_cascade():
@Commentor()
def target():
1 + 1 + 1
asserteq_or_print(
target(), '''
def target():
1 + 1 + 1
"""
2 : 1 + 1
3 : 1 + 1 + 1
"""
''')
+6 -2
View File
@@ -1,4 +1,4 @@
from trace_commentor import Commentor
from test_utils import *
def test_constant():
@@ -7,4 +7,8 @@ def test_constant():
def target():
1
print(target())
asserteq_or_print(target(),
'''
def target():
1
''')
+7
View File
@@ -0,0 +1,7 @@
from trace_commentor import flags, Commentor
def asserteq_or_print(value, ground_truth):
if flags.DEBUG or flags.PRINT:
print(value)
else:
assert value == ground_truth.strip("\n"), "\n".join(["\n\n<<<<<<<< VALUE", value, "========================", ground_truth.strip("\n"), ">>>>>>>> GROUND\n"])