Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove .mjs tests in feature_tests/js, use only .mts files #750

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions feature_tests/js/api/OptionInputStruct.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions feature_tests/js/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mjs
10 changes: 0 additions & 10 deletions feature_tests/js/test/attrs-ts.mjs

This file was deleted.

13 changes: 0 additions & 13 deletions feature_tests/js/test/attrs.mjs

This file was deleted.

10 changes: 0 additions & 10 deletions feature_tests/js/test/lifetimes-ts.mjs

This file was deleted.

13 changes: 0 additions & 13 deletions feature_tests/js/test/lifetimes.mjs

This file was deleted.

18 changes: 0 additions & 18 deletions feature_tests/js/test/option-ts.mjs

This file was deleted.

35 changes: 28 additions & 7 deletions feature_tests/js/test/option-ts.mts
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
import test from 'ava';

import { OptionOpaque } from "diplomat-wasm-js-feature-tests";
import { OptionOpaque, OptionEnum, OptionInputStruct } from "diplomat-wasm-js-feature-tests";

test("Verify option methods", t => {
const o = OptionOpaque.new_(5);
o!.assertInteger(5);
o.assertInteger(5);

const on = OptionOpaque.newNone();
t.assert(on === null);
t.assert(!on);

const s = OptionOpaque.newStruct();

s.a!.assertInteger(101);
s.b!.assertChar('餐'.codePointAt(0));
t.is(s.c!, 904);
s.d!.assertInteger(926535);
s.a.assertInteger(101);
s.b.assertChar('餐'.codePointAt(0));
t.is(s.c, 904);
s.d.assertInteger(926535);

const sn = OptionOpaque.newStructNones();
t.assert(!sn.a);
t.assert(!sn.b);
t.is(sn.c, 908);
t.assert(!sn.d);
});

test("DiplomatOption tests", t => {
let maybeU8 = OptionOpaque.acceptsOptionU8(null);
t.assert(maybeU8 === null);
maybeU8 = OptionOpaque.acceptsOptionU8(47);
t.is(maybeU8, 47);

let maybeStruct = OptionOpaque.acceptsOptionInputStruct(null);
t.assert(maybeStruct === null);
maybeStruct = OptionOpaque.acceptsOptionInputStruct(new OptionInputStruct({a: 7, c: OptionEnum.Bar}));
t.is(maybeStruct.a, 7);
t.assert(maybeStruct.b === null);
t.is(maybeStruct.c.value, OptionEnum.Bar.value);


let struct = OptionOpaque.returnsOptionInputStruct();
t.is(struct.a, 6);
t.assert(struct.b === null);
t.is(struct.c.value, OptionEnum.Bar.value);

});
45 changes: 0 additions & 45 deletions feature_tests/js/test/option.mjs

This file was deleted.

24 changes: 0 additions & 24 deletions feature_tests/js/test/result-ts.mjs

This file was deleted.

33 changes: 0 additions & 33 deletions feature_tests/js/test/result.mjs

This file was deleted.

19 changes: 0 additions & 19 deletions feature_tests/js/test/slices-ts.mjs

This file was deleted.

1 change: 0 additions & 1 deletion feature_tests/js/test/slices-ts.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import test from "ava";
import { MyString, Float64Vec } from "diplomat-wasm-js-feature-tests";
import wasm from "../api/diplomat-wasm.mjs";

test("MyString functionality", (t) => {
let str = MyString.new_("This is a test value.");
Expand Down
23 changes: 0 additions & 23 deletions feature_tests/js/test/slices.mjs

This file was deleted.

33 changes: 0 additions & 33 deletions feature_tests/js/test/struct-ts.mjs

This file was deleted.

25 changes: 23 additions & 2 deletions feature_tests/js/test/struct-ts.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import { MyEnum, MyStruct, CyclicStructB } from "diplomat-wasm-js-feature-tests";
import { MyEnum, MyStruct, CyclicStructB, ScalarPairWithPadding, BigStructWithStuff } from "diplomat-wasm-js-feature-tests";

test("Verify invariants of struct", t => {
const s = MyStruct.new_();
Expand All @@ -26,7 +26,28 @@ test("Test struct creation", t => {
t.is(s.intoA(), 17);
});

test("Function Returning Nested Struct of One Field", t => {
test("Test struct layout: scalar pair layout", t => {
const s = new ScalarPairWithPadding({
first: 122,
second: 414
});
s.assertValue();
t.is(true, true); // Ava doesn't like tests without assertions
});

test("Test struct layout: complex struct with multiple padding types and contained scalar pair", t => {
const s = new BigStructWithStuff({
first: 101,
second: 505,
third: 9345,
fourth: new ScalarPairWithPadding({first: 122, second: 414}),
fifth: 99
});
s.assertValue(853);
t.is(true, true); // Ava doesn't like tests without assertions
});

test("Function Returning Nested Struct of One Primitive", t => {
const a = CyclicStructB.getA();
t.is(a.cyclicOut(), "0");
});
Expand Down
Loading
Loading