mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 03:50:16 +00:00
add REPL test
This commit is contained in:
parent
8f3c3b446e
commit
3c6243cbc5
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import subprocess
|
||||||
|
|
||||||
class WorkDir:
|
class WorkDir:
|
||||||
def __init__(self, next):
|
def __init__(self, next):
|
||||||
@ -52,8 +53,29 @@ print('System:', '64-bit' if sys.maxsize > 2**32 else '32-bit')
|
|||||||
|
|
||||||
if len(sys.argv) == 2:
|
if len(sys.argv) == 2:
|
||||||
assert 'benchmark' in sys.argv[1]
|
assert 'benchmark' in sys.argv[1]
|
||||||
d = 'benchmarks/'
|
test_dir('benchmarks/')
|
||||||
else:
|
else:
|
||||||
d = 'tests/'
|
test_dir('tests/')
|
||||||
test_dir(d)
|
|
||||||
|
# test interactive mode
|
||||||
|
print("[REPL Test Enabled]")
|
||||||
|
if sys.platform in ['linux', 'darwin']:
|
||||||
|
res = subprocess.run(['./main'], encoding='utf-8', input=r'''
|
||||||
|
def add(a, b):
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
class A:
|
||||||
|
def __init__(self, x):
|
||||||
|
self.x = x
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return self.x
|
||||||
|
|
||||||
|
|
||||||
|
print(add(1, 2))
|
||||||
|
print(A('abc').get())
|
||||||
|
''', capture_output=True, check=True)
|
||||||
|
res.check_returncode()
|
||||||
|
assert res.stdout.endswith('>>> 3\n>>> abc\n>>> ')
|
||||||
|
|
||||||
print("ALL TESTS PASSED")
|
print("ALL TESTS PASSED")
|
Loading…
x
Reference in New Issue
Block a user