Another test, and fix bugs

This commit is contained in:
Smaug123
2017-08-06 09:33:14 +01:00
parent a32223cd56
commit 70f86ae20f
3 changed files with 12 additions and 3 deletions

View File

@@ -5,6 +5,9 @@ HVM_SUBFOLDER=hvm
hvm: $(HVM_SUBFOLDER)/hvm.o
$(CC) -o hvm_execute $(HVM_SUBFOLDER)/main.c $(HVM_SUBFOLDER)/hvm.c $(CFLAGS)
debug: $(HVM_SUBFOLDER)/hvm.o
$(CC) -o hvm_execute $(HVM_SUBFOLDER)/main.c $(HVM_SUBFOLDER)/hvm.c $(CFLAGS) -ggdb
clean:
rm -f $(HVM_SUBFOLDER)/*.o

View File

@@ -159,7 +159,7 @@ push (int val,
/*
* More storage required for the stack, since it's full at the moment
*/
*stack = realloc(*stack, 2*curr_allocated);
*stack = realloc(*stack, 2*curr_allocated*sizeof(int));
if (*stack == NULL) {
rc = ERR_OTHER;
}
@@ -172,7 +172,6 @@ push (int val,
if (rc == ERR_IS_OK) {
(*stack)[stack_depth] = val;
stack_depth++;
}
return (rc);
@@ -209,6 +208,11 @@ int_geq_sizet (int a,
result = false;
} else if ((size_t)(a) >= b) {
result = true;
} else {
/*
* a and b are nonnegative and a < b
*/
result = false;
}
return (result);

View File

@@ -2,4 +2,6 @@
set -e
[ $(./hvm_execute "123451^2v5:4?9p2g8pppppp" "") == "945321" ]
[ "$(./hvm_execute "123451^2v5:4?9p2g8pppppp" "")" = "945321" ]
[ "$(./hvm_execute "123451v2vppppp" "")" = "34521" ]
[ "$(./hvm_execute '0924809693937820909181938+68283390909580634**+P01^:87+*g' '')" = 'Hello, Small World!' ]