This commit is contained in:
blueloveTH 2024-01-19 14:18:23 +08:00
parent 3c6243cbc5
commit 96c926e4b3

View File

@ -60,11 +60,18 @@ else:
# test interactive mode # test interactive mode
print("[REPL Test Enabled]") print("[REPL Test Enabled]")
if sys.platform in ['linux', 'darwin']: if sys.platform in ['linux', 'darwin']:
res = subprocess.run(['./main'], encoding='utf-8', input=r''' cmd = './main'
def add(a, b): elif sys.platform == 'win32':
cmd = 'main.exe'
else:
cmd = None
if cmd is not None:
res = subprocess.run([cmd], encoding='utf-8', input=r'''
def add(a, b):
return a + b return a + b
class A: class A:
def __init__(self, x): def __init__(self, x):
self.x = x self.x = x
@ -72,10 +79,10 @@ class A:
return self.x return self.x
print(add(1, 2)) print(add(1, 2))
print(A('abc').get()) print(A('abc').get())
''', capture_output=True, check=True) ''', capture_output=True, check=True)
res.check_returncode() res.check_returncode()
assert res.stdout.endswith('>>> 3\n>>> abc\n>>> ') assert res.stdout.endswith('>>> 3\n>>> abc\n>>> ')
print("ALL TESTS PASSED") print("ALL TESTS PASSED")