Update lispytest.py

This commit is contained in:
Peter Norvig 2018-10-24 15:08:42 -07:00 committed by GitHub
parent 192b0ec410
commit 68bda97dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,11 +104,11 @@ def test(tests, name=''):
for (x, expected) in tests:
try:
result = eval(parse(x))
print(x, '=>', to_string(result))
print(x, '=>', lispstr(result))
ok = (result == expected)
except Exception as e:
print(x, '=raises=>', type(e).__name__, e)
ok = issubclass(expected, Exception) and isinstance(e, expected)
ok = isinstance(expected, type) and issubclass(expected, Exception) and isinstance(e, expected)
if not ok:
fails += 1
print('FAIL!!! Expected', expected)
@ -116,7 +116,6 @@ def test(tests, name=''):
if __name__ == '__main__':
from lis import *
to_string = str
test(lis_tests, 'lis.py')
from lispy import *
test(lis_tests+lispy_tests, 'lispy.py')