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

Struct Object Constructors #723

Merged
merged 19 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Making tests run
  • Loading branch information
ambiguousname committed Nov 6, 2024
commit d65b8f212feba30a26f08d063226c44cda99652e
10 changes: 9 additions & 1 deletion feature_tests/js/test/struct-ts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ test("Verify invariants of struct", t => {
t.is(s.intoA(), 17);
});
test("Test struct creation", t => {
const s = new MyStruct(17, true, 209, 1234n, 5991, '餐'.codePointAt(0), MyEnum.B);
const s = new MyStruct({
a: 17,
b: true,
c: 209,
d: 1234n,
e: 5991,
f: '餐'.codePointAt(0),
g: MyEnum.B
});
t.is(s.intoA(), 17);
});
10 changes: 9 additions & 1 deletion feature_tests/js/test/struct-ts.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ test("Verify invariants of struct", t => {
});

test("Test struct creation", t => {
const s = new MyStruct(17, true, 209, 1234n, 5991, '餐'.codePointAt(0), MyEnum.B);
const s = new MyStruct({
a: 17,
b: true,
c: 209,
d: 1234n,
e: 5991,
f: '餐'.codePointAt(0),
g: MyEnum.B
});
t.is(s.intoA(), 17);
});
23 changes: 20 additions & 3 deletions feature_tests/js/test/struct.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,35 @@ test("Verify invariants of struct", t => {
});

test("Test struct creation", t => {
const s = new MyStruct(17, true, 209, 1234n, 5991, '餐'.codePointAt(0), MyEnum.B);
const s = new MyStruct({
a: 17,
b: true,
c: 209,
d: 1234n,
e: 5991,
f: '餐'.codePointAt(0),
g: MyEnum.B
});
t.is(s.intoA(), 17);
});

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