Offload functions to worker threads with shared memory primitives for Node.js.
1import { describe, it } from 'node:test';
2import assert from 'node:assert/strict';
3import { bool } from 'moroutine';
4
5describe('Bool', () => {
6 it('self-allocates and initializes to false', () => {
7 const v = bool();
8 assert.equal(v.load(), false);
9 });
10
11 it('stores and loads true', () => {
12 const v = bool();
13 v.store(true);
14 assert.equal(v.load(), true);
15 });
16
17 it('stores and loads false', () => {
18 const v = bool();
19 v.store(true);
20 v.store(false);
21 assert.equal(v.load(), false);
22 });
23
24 it('round-trips true/false', () => {
25 const v = bool();
26 v.store(true);
27 assert.equal(v.load(), true);
28 v.store(false);
29 assert.equal(v.load(), false);
30 });
31
32 it('exposes byteSize of 1', () => {
33 assert.equal(bool.byteSize, 1);
34 });
35
36 it('exposes byteAlignment of 1', () => {
37 assert.equal(bool.byteAlignment, 1);
38 });
39});