Skip to content

Commit 6ffa4d2

Browse files
committed
fix: IC representation
1 parent d7121f5 commit 6ffa4d2

6 files changed

Lines changed: 45 additions & 6 deletions

File tree

src/arch/interface/quad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, instr: str, *args) -> None:
2222

2323
def __str__(self) -> str:
2424
"""String representation"""
25-
return f"({self.instr} {', '.join(x for x in self.args)})"
25+
return str(tuple(self))
2626

2727
def __len__(self) -> int:
2828
"""Returns the number of arguments + 1 (the instruction)"""

tests/functional/test.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
reOPT = re.compile(r"^opt([0-9]+)_") # To detect -On tests
1717
reBIN = re.compile(r"^(?:.*/)?(tzx|tap)_.*") # To detect tzx / tap test
18+
reIC = re.compile(r"^.*_IC$") # To detect intermediate code tests
1819

1920
EXIT_CODE = 0
20-
FILTER = r"^(([ \t]*;)|(#[ \t]*line))"
21+
FILTER = r"^(([ \t]*;)|(#[ \t]*line))|^\('inline',[ \t]+'#[ \t]*line .*'\)"
2122
DEFAULT_ARCH = "zx48k" # Default testing architecture
2223

2324
# Global tests and failed counters
@@ -233,11 +234,16 @@ def _get_testbas_options(fname: str) -> tuple[list[str], str, str]:
233234
if match:
234235
options.append("-O" + match.groups()[0])
235236

236-
match = reBIN.match(getName(fname))
237-
if match and match.groups()[0].lower() in ("tzx", "tap"):
238-
ext = match.groups()[0].lower()
237+
match_bin = reBIN.match(getName(fname))
238+
match_ic = reIC.match(getName(fname))
239+
if match_bin and match_bin.groups()[0].lower() in ("tzx", "tap"):
240+
ext = match_bin.groups()[0].lower()
239241
tfname = os.path.join(TEMP_DIR, getName(fname) + os.extsep + ext)
240242
options.extend(["--%s" % ext, fname, "-o", tfname, "-a", "-B"] + prep)
243+
elif match_ic:
244+
ext = "ic"
245+
tfname = os.path.join(TEMP_DIR, "test" + getName(fname) + os.extsep + ext)
246+
options.extend(["-E", fname, "-o", tfname] + prep)
241247
else:
242248
ext = "asm"
243249
tfname = os.path.join(TEMP_DIR, "test" + getName(fname) + os.extsep + ext)
@@ -406,7 +412,12 @@ def testBAS(
406412
func = lambda: systemExec(syscmd)
407413

408414
with TempTestFile(func, tfname, keep_file=UPDATE):
409-
result: bool | None = is_same_file(okfile, tfname, filter_, is_binary=reBIN.match(fname) is not None)
415+
result: bool | None = is_same_file(
416+
okfile,
417+
tfname,
418+
filter_,
419+
is_binary=reBIN.match(fname) is not None,
420+
)
410421
if UPDATE:
411422
if not result: # File changed
412423
if os.path.exists(okfile):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
border 7
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
('fparamu8', '7')
2+
('call', '.core.BORDER', '0')
3+
('end', '0')
4+
('inline', ';; --- end of user code ---')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
function test(a as Float) as string
3+
if a then return "not zero"
4+
end function
5+
6+
test(0)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
('paramf', '0.0')
2+
('call', '_test', '0')
3+
('call', '.core.__MEM_FREE', '0')
4+
('end', '0')
5+
('label', '_test')
6+
('enter', '0')
7+
('ploadf', 't3', '0')
8+
('jzerof', 't3', '.LABEL.__LABEL1')
9+
('retstr', '#.LABEL.__LABEL2', '_test__leave')
10+
('label', '.LABEL.__LABEL1')
11+
('inline', '#line 3 "func_call_IC.bas"')
12+
('inline', '\nld hl, 0\n')
13+
('inline', '#line 6 "func_call_IC.bas"')
14+
('label', '_test__leave')
15+
('leave', '6')
16+
('vard', '.LABEL.__LABEL2', "['0008', '6E', '6F', '74', '20', '7A', '65', '72', '6F']")
17+
('inline', ';; --- end of user code ---')

0 commit comments

Comments
 (0)