Skip to content

Commit 1c58301

Browse files
committed
Update tests and tester
Now blank lines can be ignored for ASM and BASIC test. Also updates test for Preprocessor
1 parent 15e99c9 commit 1c58301

2 files changed

Lines changed: 46 additions & 14 deletions

File tree

tests/functional/prepro71.out

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,34 @@ end function
4949

5050

5151

52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
function FASTCALL callocate(byval n as uinteger) as uinteger
62+
63+
64+
65+
66+
asm
67+
ld b, h
68+
ld c, l
69+
jp __MEM_CALLOC
70+
end asm
71+
end function
72+
73+
74+
75+
76+
77+
78+
79+
5280
sub FASTCALL deallocate(byval addr as integer)
5381

5482

@@ -195,8 +223,9 @@ end function
195223
#require "alloc.asm"
196224
#require "free.asm"
197225
#require "realloc.asm"
226+
#require "calloc.asm"
198227

199-
#line 198 "/zxbasic/library/alloc.bas"
228+
#line 227 "/zxbasic/library/alloc.bas"
200229

201230
#line 2 "prepro71.bi"
202231

tests/functional/test.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,30 @@ def _msg(msg, force=False):
102102

103103

104104
def get_file_lines(filename, ignore_regexp=None, replace_regexp=None,
105-
replace_what='.', replace_with='.'):
105+
replace_what='.', replace_with='.', strip_blanks=True):
106106
""" Opens source file <filename> and load its lines,
107107
discarding those not important for comparison.
108108
"""
109109
from api.utils import open_file
110110
with open_file(filename, 'rt', 'utf-8') as f:
111111
lines = [x for x in f]
112112

113-
if ignore_regexp is not None:
114-
r = re.compile(ignore_regexp)
115-
lines = [x for x in lines if not r.search(x)]
113+
if ignore_regexp is not None:
114+
r = re.compile(ignore_regexp)
115+
lines = [x for x in lines if not r.search(x)]
116116

117-
if replace_regexp is not None and replace_what and replace_with is not None:
118-
r = re.compile(replace_regexp)
119-
lines = [x.replace(replace_what, replace_with, 1) if r.search(x) else x for x in lines]
117+
if replace_regexp is not None and replace_what and replace_with is not None:
118+
r = re.compile(replace_regexp)
119+
lines = [x.replace(replace_what, replace_with, 1) if r.search(x) else x for x in lines]
120+
121+
if strip_blanks:
122+
lines = [x.rstrip() for x in lines if x.rstrip()]
120123

121124
return lines
122125

123126

124-
def is_same_file(fname1, fname2, ignore_regexp=None,
125-
replace_regexp=None, replace_what='.', replace_with='.', diff=None, is_binary=False):
127+
def is_same_file(fname1, fname2, ignore_regexp=None, replace_regexp=None, replace_what='.', replace_with='.',
128+
diff=None, is_binary=False, strip_blanks=True):
126129
""" Test if two files are the same.
127130
128131
If ignore_regexp is passed, it must be a Regular Expression
@@ -143,8 +146,8 @@ def is_same_file(fname1, fname2, ignore_regexp=None,
143146
if is_binary:
144147
return open(fname1, 'rb').read() == open(fname2, 'rb').read()
145148

146-
r1 = get_file_lines(fname1, ignore_regexp, replace_regexp, replace_what, replace_with)
147-
r2 = get_file_lines(fname2, ignore_regexp, replace_regexp, replace_what, replace_with)
149+
r1 = get_file_lines(fname1, ignore_regexp, replace_regexp, replace_what, replace_with, strip_blanks)
150+
r2 = get_file_lines(fname2, ignore_regexp, replace_regexp, replace_what, replace_with, strip_blanks)
148151
result = (r1 == r2)
149152

150153
if not result:
@@ -278,8 +281,8 @@ def testPREPRO(fname, pattern_=None, inline=None):
278281

279282
with TempTestFile(func, tfname, UPDATE):
280283
if not UPDATE:
281-
result = is_same_file(okfile, tfname, replace_regexp=pattern_,
282-
replace_what=ZXBASIC_ROOT, replace_with=_original_root)
284+
result = is_same_file(okfile, tfname, replace_regexp=pattern_, replace_what=ZXBASIC_ROOT,
285+
replace_with=_original_root, strip_blanks=True)
283286
else:
284287
updateTest(tfname, pattern_)
285288
finally:

0 commit comments

Comments
 (0)