Skip to content

Commit

Permalink
Correctly handle padding in JS2 (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth authored Aug 27, 2024
1 parent 0183677 commit f6cb561
Show file tree
Hide file tree
Showing 19 changed files with 528 additions and 85 deletions.
8 changes: 6 additions & 2 deletions example/js/lib/api/FixedDecimalFormatterOptions.mjs

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

12 changes: 12 additions & 0 deletions example/js/lib/api/diplomat-runtime.mjs

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

27 changes: 27 additions & 0 deletions feature_tests/js/api/BigStructWithStuff.d.ts

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

101 changes: 101 additions & 0 deletions feature_tests/js/api/BigStructWithStuff.mjs

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

8 changes: 6 additions & 2 deletions feature_tests/js/api/ImportedStruct.mjs

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

2 changes: 1 addition & 1 deletion feature_tests/js/api/MyStruct.mjs

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

17 changes: 17 additions & 0 deletions feature_tests/js/api/ScalarPairWithPadding.d.ts

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

71 changes: 71 additions & 0 deletions feature_tests/js/api/ScalarPairWithPadding.mjs

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

12 changes: 12 additions & 0 deletions feature_tests/js/api/diplomat-runtime.mjs

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

4 changes: 4 additions & 0 deletions feature_tests/js/api/index.d.ts

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

4 changes: 4 additions & 0 deletions feature_tests/js/api/index.mjs

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

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

test("Verify invariants of struct", t => {
const s = MyStruct.new_("hello");
Expand All @@ -16,4 +16,16 @@ test("Verify invariants of struct", t => {
test("Test struct creation", t => {
const s = new MyStruct(17, true, 209, 1234n, 5991, '餐'.codePointAt(0), MyEnum.B);
t.is(s.intoA(), 17);
});
});

test("Test struct layout: scalar pair layout", t => {
const s = new ScalarPairWithPadding(122, 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(101, 505, 9345, new ScalarPairWithPadding(122, 414), 99);
s.assertValue(853);
t.is(true, true); // Ava doesn't like tests without assertions
});
Loading

0 comments on commit f6cb561

Please sign in to comment.