Fix a couple things
This commit is contained in:
30
test/test.c
30
test/test.c
@@ -1,15 +1,29 @@
|
||||
#include <ground.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
GroundProgram program = Ground.New.Program();
|
||||
printf(Ground.Flags.error ? "true\n" : "false\n");
|
||||
GroundState state = {NULL, NULL, NULL};
|
||||
GroundInstruction instruction = Ground.New.Instruction(GroundInstruction_ADD);
|
||||
printf(Ground.Flags.error ? "true\n" : "false\n");
|
||||
Ground.Instruction.append(&instruction, Ground.New.Arg.Value(Ground.New.Value.Int(2)));
|
||||
printf(Ground.Flags.error ? "true\n" : "false\n");
|
||||
Ground.Instruction.append(&instruction, Ground.New.Arg.Value(Ground.New.Value.Int(2)));
|
||||
printf(Ground.Flags.error ? "true\n" : "false\n");
|
||||
|
||||
// Instruction 1: CREATELABEL start
|
||||
GroundInstruction label_inst = Ground.New.Instruction(GroundInstruction_CREATELABEL);
|
||||
Ground.Instruction.append(&label_inst, Ground.New.Arg.LabelRef("start"));
|
||||
Ground.Program.append(&program, label_inst);
|
||||
|
||||
// Instruction 2: JUMP start
|
||||
GroundInstruction jump_inst = Ground.New.Instruction(GroundInstruction_JUMP);
|
||||
Ground.Instruction.append(&jump_inst, Ground.New.Arg.LabelRef("start"));
|
||||
Ground.Program.append(&program, jump_inst);
|
||||
|
||||
// Execute program
|
||||
Ground.Program.execute(&program, &state);
|
||||
printf(Ground.Flags.error ? "true\n" : "false\n");
|
||||
|
||||
if (Ground.Flags.error) {
|
||||
printf("Error set during execution!\n");
|
||||
Ground.Log.printErrors();
|
||||
return 1;
|
||||
} else {
|
||||
printf("Success!\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user