Skip to content

Commit d21269b

Browse files
committed
fix: initialize global VM in tests to prevent segfaults
1 parent 85e0d86 commit d21269b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

tests/bytecode_tests.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include "../include/bytecode.h"
16+
#include "../include/vm.h"
1617
#include <stdio.h>
1718
#include <stdlib.h>
1819
#include <string.h>
@@ -26,6 +27,7 @@ void disasm_chunk(const Chunk *chunk);
2627
int vm_run_chunk_simple(const Chunk *chunk);
2728

2829
int main(void) {
30+
initVM(&vm);
2931
printf("ProXPL bytecode tests start\n");
3032
printf("OP_CONSTANT: %d, OP_NOP: %d\n", OP_CONSTANT, OP_NOP);
3133

tests/test_opcode_roundtrip.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <string.h>
1515
#include <assert.h>
1616
#include "bytecode.h"
17+
#include "../include/vm.h"
1718

1819
#include "../include/value.h"
1920
#include "../include/object.h"
@@ -22,6 +23,7 @@
2223
// So we need vm stub or link with vm_stub.o
2324

2425
int main(void) {
26+
initVM(&vm);
2527
const char *tmp = "tests/tmp_opcode_rt.proxbc";
2628

2729
Chunk c;

0 commit comments

Comments
 (0)