Files
dolt/nomdl/codegen/test/ref-test.js
Erik Arvidsson b79d89963f JS codegen: Add tests and make more things work (#1182)
Now the generated code is tested and most things work.



To generate a .noms.js file use the codegen go binary



Things that are not complete/needs improvements include:

- Recursive structs

- Structs with annonymous unions

- Enum -- constants for the values



Issue #1081
2016-04-07 14:11:40 -07:00

23 lines
720 B
JavaScript

// @flow
import {assert} from 'chai';
import {suite, test} from 'mocha';
import {newSet, RefValue, makeSetType, float32Type, DataStore, MemoryStore} from '@attic/noms';
import type {NomsSet, float32} from '@attic/noms';
import {StructWithRef} from './gen/ref.noms.js';
suite('ref.noms', () => {
test('constructor', async () => {
const ds = new DataStore(new MemoryStore());
const set: NomsSet<float32> = await newSet([0, 1, 2, 3], makeSetType(float32Type));
const ref = ds.writeValue(set);
const r = new RefValue(ref);
const struct = new StructWithRef({r});
assert.isTrue(struct.r.equals(r));
const set2 = await ds.readValue(r.targetRef);
assert.isTrue(set.equals(set2));
});
});