-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ lexer | |
splc | ||
*.myout | ||
|
||
# phase4 | ||
*.s | ||
# pyinstaller in phase4 | ||
splc.spec | ||
build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
splc: splc.py | ||
pyinstaller --log-level WARN --distpath bin -F splc.py | ||
|
||
.PHONY: clean | ||
.PHONY: test clean | ||
test: splc test/test.py | ||
cd test && python3 test.py | ||
clean: | ||
@rm -rf __pycache__ build bin splc.spec | ||
@rm -rf __pycache__ build bin splc.spec test/*.s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# For automatic testing | ||
# This script should run in the `test/` directory | ||
import subprocess | ||
|
||
spim_header = """SPIM Version 8.0 of January 8, 2010 | ||
Copyright 1990-2010, James R. Larus. | ||
All Rights Reserved. | ||
See the file README for a full copyright notice. | ||
Loaded: /usr/lib/spim/exceptions.s | ||
""" | ||
|
||
for i in range(3): | ||
id = f'test_4_r{i:02}' | ||
with open(f'{id}.test', 'r') as tests: | ||
subprocess.run(f'../bin/splc {id}.ir > {id}.s', shell=True) | ||
for test in tests.read().split('\n\n'): | ||
input, expect_out = test.split('\n') | ||
res = subprocess.run(f'echo {input} | spim -file {id}.s', shell=True, capture_output=True, text=True) | ||
actual_out = res.stdout.replace(spim_header, '').strip() # remove SPIM's header | ||
if actual_out != expect_out: | ||
print(f'----------{id} failed----------') | ||
print(f'[input] {input}') | ||
print(f'[expect] {expect_out}') | ||
print(f'[actual] {actual_out}') | ||
exit(1) | ||
print('All tests passed!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
0 | ||
Enter an integer:1 | ||
|
||
1 | ||
Enter an integer:1 | ||
|
||
2 | ||
Enter an integer:2 | ||
|
||
3 | ||
Enter an integer:6 | ||
|
||
4 | ||
Enter an integer:24 | ||
|
||
5 | ||
Enter an integer:120 |