Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register variable ASMSX for cross-assemblers #108

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/dura.y
Original file line number Diff line number Diff line change
Expand Up @@ -3770,9 +3770,10 @@ void register_label(char *name)
}

// Find if the label is already registered
i = search_label(id_list, name, 0, total_global);
if (i != -1) error_message(14, fname_src, lines); // If label found - Error, redefine, fname_src, linesd!

if (is_defined_symbol(name)) {
// If label found - Error, redefine, fname_src, linesd!
error_message(14, fname_src, lines);
}

if (++total_global == MAX_ID)
error_message(11, fname_src, lines);
Expand Down Expand Up @@ -3814,7 +3815,6 @@ void register_local(char *name)

void register_symbol(char *name, int n, int _rom_type)
{
int i;
char *_name;

if (pass == 2)
Expand All @@ -3825,9 +3825,9 @@ void register_symbol(char *name, int n, int _rom_type)
}

// Search if the symbol is defined. Error if found
i = search_label(id_list, name, 0, total_global);
if (i != -1) error_message(14, fname_src, lines);

if (is_defined_symbol(name)) {
error_message(14, fname_src, lines);
}

// If maximum number of label names is exceeded, crash!
if (++total_global == MAX_ID)
Expand Down Expand Up @@ -4597,6 +4597,7 @@ int main(int argc, char *argv[]) {
fname_msx = malloc(PATH_MAX);
fname_msx[0] = 0;
register_symbol("Eduardo_A_Robsy_Petrus_2007", 0, 0);
register_symbol("ASMSX", 0, 0);

fname_asm = malloc(PATH_MAX); assert(fname_asm != NULL);
fname_src = malloc(PATH_MAX); assert(fname_src != NULL);
Expand Down
14 changes: 14 additions & 0 deletions test/features/program.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ Feature: Test program functions
| name | expect |
| test2 | "test2 " |
| test1234 | "test12" |

Scenario: Test asMSX defined code
Given I write the code to test.asm
"""
IFDEF ASMSX
PRINTTEXT "Hello ASMSX!"
ELSE
PRINTTEXT "Hello unknown assembler!"
ENDIF
.db "HELLO"
"""
When I build test.asm
Then text file contains Hello ASMSX
And text file does not contain unknown assembler
26 changes: 23 additions & 3 deletions test/steps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def step_impl(context, file):
context.build_program = subprocess.run(
['asmsx', fullpath],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
check=True,
check=False,
env=env
)
assert context.build_program.returncode == 0, f"Program exited with code {context.build_program.returncode}"
context.build = True
context.build_file = file

Expand Down Expand Up @@ -81,9 +83,9 @@ def step_impl(context, should, output):
assert context.build_program, "Program did not run"
should = (not "no" in should)
if should:
assert output in context.build_program.stdout, "Output not found: {context.build_program.stdout}"
assert output in context.build_program.stdout, f"Output not found:\n{context.build_program.stdout}"
else:
assert output not in context.build_program.stdout, "Output found: {context.build_program.stdout}"
assert output not in context.build_program.stdout, f"Output found:\n{context.build_program.stdout}"

@then('{file} matches sha {expected_hash}')
def step_impl(context, file, expected_hash):
Expand All @@ -98,3 +100,21 @@ def step_impl(context, file, expected_hash):
sha1.update(data)

assert sha1.hexdigest() == expected_hash, f"Hash {sha1.hexdigest()} does not match"

@then('text file contains {text}')
def step_impl(context, text):
assert context.build_txt, "There's no output text file!"

with open(context.build_txt, 'r') as text_file:
if text in text_file.read():
return True
assert False, "Text not found in output text"

@then('text file does not contain {text}')
def step_impl(context, text):
assert context.build_txt, "There's no output text file!"

with open(context.build_txt, 'r') as text_file:
if text in text_file.read():
assert False, "Found text in output text"
return True