diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..429067c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Perform unit tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout branch + uses: actions/checkout@v4 + - name: Install Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.44.4 + - name: Run tests + run: ./test.sh diff --git a/dist/libvoxel.h b/dist/libvoxel.h index 47a51c2..edd52cc 100644 --- a/dist/libvoxel.h +++ b/dist/libvoxel.h @@ -883,10 +883,9 @@ void voxel_builtins_core_fillBuffer(voxel_Executor* executor) { writeCount++; } + voxel_unreferenceThing(executor->context, byteThing); voxel_unreferenceThing(executor->context, bufferThing); - byteThing->referenceCount++; - voxel_push(executor, voxel_newNumberInt(executor->context, start)); } diff --git a/src/builtins/core/buffers.h b/src/builtins/core/buffers.h index 662231a..f8279f3 100644 --- a/src/builtins/core/buffers.h +++ b/src/builtins/core/buffers.h @@ -141,10 +141,9 @@ void voxel_builtins_core_fillBuffer(voxel_Executor* executor) { writeCount++; } + voxel_unreferenceThing(executor->context, byteThing); voxel_unreferenceThing(executor->context, bufferThing); - byteThing->referenceCount++; - voxel_push(executor, voxel_newNumberInt(executor->context, start)); } diff --git a/test/buffers/main.vxl b/test/buffers/main.vxl index 2ef3033..074840c 100644 --- a/test/buffers/main.vxl +++ b/test/buffers/main.vxl @@ -1,5 +1,6 @@ import buffers; + var byte1 = Byte(0x41); var byte2 = Byte("B"); @@ -31,8 +32,10 @@ syscall log("Set byte at index 1 in buffer: "); syscall log(buffer[1]); syscall log("\n"); + var bigBuffer = buffers.create(65536 * 4, Byte(".")); + syscall log("Section of big buffer: "); syscall log(bigBuffer.section((65536 * 2) + 4, (65536 * 2) + 12)); syscall log("\n"); diff --git a/test/test.js b/test/test.js index 20cfe10..b1c74d3 100644 --- a/test/test.js +++ b/test/test.js @@ -122,11 +122,11 @@ for await (var entry of Deno.readDir(TEST_DIR)) { var command = new Deno.Command(VOXEL_FILE, {args: [path.join(TEST_PATH, "main.loop.vxc")], stdout: "null"}); var process = command.spawn(); - await delay(1_000); + await delay(4_000); var before = await measureMemoryUsage(process.pid); - await delay(4_000); + await delay(8_000); var after = await measureMemoryUsage(process.pid);