Reworked unit tests for machine and renamed test_programs directory

This commit is contained in:
François Autin
2023-03-12 00:22:16 +01:00
parent 177abfe846
commit c75e2995e7
29 changed files with 24 additions and 48 deletions

View File

@ -0,0 +1,9 @@
TOPDIR = ../..
include $(TOPDIR)/Makefile.tests
dumps: comparisons.dump if.dump switch.dump
tests: comparisons.guac if.guac switch.guac
# Dependances
$(PROGRAMS): % : $(USERLIB)/sys.o $(USERLIB)/libnachos.o %.o

View File

@ -0,0 +1,15 @@
int main() {
int x = 0;
int y = 1;
while (x <= y) {
if (x > y) {
x += 1;
} else if (x == y) {
x += y;
} else if (x < y) {
y += 1;
} else {
return 0;
}
}
}

View File

@ -0,0 +1,10 @@
int main() {
int x = 1;
if (x == 1 && x > 0) {
x = 2;
} else if (x || x == 0 ) {
x = 3;
} else {
x = 0;
}
}

View File

@ -0,0 +1,17 @@
int main() {
int x = 0;
int y = 1;
while (x <= y) {
if (x > y) {
y += 1;
}
if (x == y) {
x += y;
}
if (x < y) {
x += 1;
} else {
return 0;
}
}
}

View File

@ -0,0 +1,7 @@
int main() {
int x = 0;
switch(x) {
case 1: x = 1; break;
default: return 0;
}
}