automatic regressive testing
This commit is contained in:
@@ -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
|
||||
''')
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
''')
|
||||
|
||||
@@ -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
|
||||
''')
|
||||
|
||||
@@ -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"])
|
||||
Reference in New Issue
Block a user