Silence unit tests.

This commit is contained in:
Piotr Fusik 2019-10-06 17:24:59 +02:00
parent cb92f715a9
commit 99099938b5
1 changed files with 76 additions and 81 deletions

View File

@ -765,11 +765,10 @@ void readValue() {
valOpStack.length = 0; valOpStack.length = 0;
} }
debug int testValue(string l) { version (unittest) int testValue(string l) {
line = l; line = l;
column = 0; column = 0;
readValue(); readValue();
writefln("Value of %s is %x", l, value);
return value; return value;
} }
@ -1033,11 +1032,10 @@ void readAbsoluteAddrMode() {
addrMode = AddrMode.ABSOLUTE; addrMode = AddrMode.ABSOLUTE;
} }
debug AddrMode testAddrMode(string l) { version (unittest) AddrMode testAddrMode(string l) {
line = l; line = l;
column = 0; column = 0;
readAddrMode(); readAddrMode();
writefln("Addressing mode of \"%s\" is %x", l, addrMode);
return addrMode; return addrMode;
} }
@ -1175,10 +1173,10 @@ void listLabelTable() {
} }
} }
debug ubyte[] objectBuffer; version (unittest) ubyte[] objectBuffer;
void objectByte(ubyte b) { void objectByte(ubyte b) {
debug { version (unittest) {
objectBuffer ~= b; objectBuffer ~= b;
} else { } else {
assert(pass2); assert(pass2);
@ -1234,11 +1232,11 @@ void putByte(ubyte b) {
} }
} }
} }
debug { version (unittest) {
objectByte(b); objectByte(b);
} }
if (pass2) { if (pass2) {
debug { version (unittest) {
} else { } else {
objectByte(b); objectByte(b);
} }
@ -2639,15 +2637,11 @@ void assemblyInstruction(string instruction) {
skipping = false; skipping = false;
} }
debug ubyte[] testInstruction(string l) { version (unittest) ubyte[] testInstruction(string l) {
objectBuffer.length = 0; objectBuffer.length = 0;
line = l; line = l;
column = 0; column = 0;
assemblyInstruction(readInstruction()); assemblyInstruction(readInstruction());
write(line, " assembles to");
foreach (ubyte b; objectBuffer)
writef(" %02x", b);
writeln();
return objectBuffer; return objectBuffer;
} }
@ -2684,9 +2678,6 @@ void assemblyPair() {
} }
void assemblyLine() { void assemblyLine() {
debug {
writeln(line);
}
lineNo++; lineNo++;
totalLines++; totalLines++;
column = 0; column = 0;
@ -2940,12 +2931,15 @@ int main(string[] args) {
exitCode = 3; exitCode = 3;
sourceFilename = arg; sourceFilename = arg;
} }
if (sourceFilename is null) version (unittest)
exitCode = 3; return 0;
if (!getOption('q')) else {
writeln(TITLE); if (sourceFilename is null)
if (exitCode != 0) { exitCode = 3;
write( if (!getOption('q'))
writeln(TITLE);
if (exitCode != 0) {
write(
`Syntax: xasm source [options] `Syntax: xasm source [options]
/c Include false conditionals in listing /c Include false conditionals in listing
/d:label=value Define a label /d:label=value Define a label
@ -2958,65 +2952,66 @@ int main(string[] args) {
/t[:filename] List label table /t[:filename] List label table
/u Warn of unused labels /u Warn of unused labels
`); `);
return exitCode;
}
try {
assemblyPass();
pass2 = true;
assemblyPass();
if (getOption('t') && labelTable.length > 0)
listLabelTable();
} catch (AssemblyError e) {
warning(e.msg, true);
exitCode = 2;
}
listingStream.close();
objectStream.close();
if (exitCode <= 1) {
if (!getOption('q')) {
writefln("%d lines of source assembled", totalLines);
if (objectBytes > 0)
writefln("%d bytes written to the object file", objectBytes);
}
if (getOption('m')) {
writef("%s:", makeTarget);
foreach (filename; makeSources)
writef(" %s", makeEscape(filename));
write("\n\txasm");
for (int i = 1; i < args.length; i++) {
string arg = args[i];
if (isOption(arg)) {
char letter = arg[1];
if (letter >= 'A' && letter <= 'Z')
letter += 'a' - 'A';
switch (letter) {
case 'm':
break;
case 'o':
if (arg[0] == '/')
writef(" /%c:$@", arg[1]);
else {
writef(" -%c $@", arg[1]);
++i;
}
break;
default:
if (arg[0] == '-'
&& (letter == 'd' || letter == 'l' || letter == 't')
&& i + 1 < args.length && !isOption(args[i + 1])) {
writef(" %s %s", arg, makeEscape(args[++i]));
}
else {
writef(" %s", makeEscape(arg));
}
break;
}
continue;
}
write(" $<");
}
writeln();
}
}
return exitCode; return exitCode;
} }
try {
assemblyPass();
pass2 = true;
assemblyPass();
if (getOption('t') && labelTable.length > 0)
listLabelTable();
} catch (AssemblyError e) {
warning(e.msg, true);
exitCode = 2;
}
listingStream.close();
objectStream.close();
if (exitCode <= 1) {
if (!getOption('q')) {
writefln("%d lines of source assembled", totalLines);
if (objectBytes > 0)
writefln("%d bytes written to the object file", objectBytes);
}
if (getOption('m')) {
writef("%s:", makeTarget);
foreach (filename; makeSources)
writef(" %s", makeEscape(filename));
write("\n\txasm");
for (int i = 1; i < args.length; i++) {
string arg = args[i];
if (isOption(arg)) {
char letter = arg[1];
if (letter >= 'A' && letter <= 'Z')
letter += 'a' - 'A';
switch (letter) {
case 'm':
break;
case 'o':
if (arg[0] == '/')
writef(" /%c:$@", arg[1]);
else {
writef(" -%c $@", arg[1]);
++i;
}
break;
default:
if (arg[0] == '-'
&& (letter == 'd' || letter == 'l' || letter == 't')
&& i + 1 < args.length && !isOption(args[i + 1])) {
writef(" %s %s", arg, makeEscape(args[++i]));
}
else {
writef(" %s", makeEscape(arg));
}
break;
}
continue;
}
write(" $<");
}
writeln();
}
}
return exitCode;
} }