Skip to content

Commit 697b07d

Browse files
authored
test: Testing vectors for structural differences (#1208)
1 parent a09cbbf commit 697b07d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

packages/typegpu/tests/vector.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,24 @@ describe('vec2h', () => {
562562
});
563563
});
564564

565+
describe('v2f', () => {
566+
it('differs structurally from other vector instances', () => {
567+
expect(d.vec2f(1, 2)).toStrictEqual(d.vec2f(1, 2));
568+
expect(d.vec2f(1, 2)).not.toStrictEqual(d.vec2h(1, 2));
569+
expect(d.vec2f(1, 2)).not.toStrictEqual(d.vec2i(1, 2));
570+
expect(d.vec2f(1, 2)).not.toStrictEqual(d.vec2u(1, 2));
571+
});
572+
});
573+
574+
describe('v2i', () => {
575+
it('differs structurally from other vector instances', () => {
576+
expect(d.vec2i(1, 2)).toStrictEqual(d.vec2i(1, 2));
577+
expect(d.vec2i(1, 2)).not.toStrictEqual(d.vec2f(1, 2));
578+
expect(d.vec2i(1, 2)).not.toStrictEqual(d.vec2h(1, 2));
579+
expect(d.vec2i(1, 2)).not.toStrictEqual(d.vec2u(1, 2));
580+
});
581+
});
582+
565583
describe('v3f', () => {
566584
describe('(v2f, number) constructor', () => {
567585
it('works in JS', () => {
@@ -596,6 +614,22 @@ describe('v3f', () => {
596614
);
597615
});
598616
});
617+
618+
it('differs structurally from other vector instances', () => {
619+
expect(d.vec3f(1, 2, 3)).toStrictEqual(d.vec3f(1, 2, 3));
620+
expect(d.vec3f(1, 2, 3)).not.toStrictEqual(d.vec3h(1, 2, 3));
621+
expect(d.vec3f(1, 2, 3)).not.toStrictEqual(d.vec3i(1, 2, 3));
622+
expect(d.vec3f(1, 2, 3)).not.toStrictEqual(d.vec3u(1, 2, 3));
623+
});
624+
});
625+
626+
describe('v3i', () => {
627+
it('differs structurally from other vector instances', () => {
628+
expect(d.vec3i(1, 2, 3)).toStrictEqual(d.vec3i(1, 2, 3));
629+
expect(d.vec3i(1, 2, 3)).not.toStrictEqual(d.vec3f(1, 2, 3));
630+
expect(d.vec3i(1, 2, 3)).not.toStrictEqual(d.vec3h(1, 2, 3));
631+
expect(d.vec3i(1, 2, 3)).not.toStrictEqual(d.vec3u(1, 2, 3));
632+
});
599633
});
600634

601635
describe('v4f', () => {
@@ -666,6 +700,13 @@ describe('v4f', () => {
666700
);
667701
});
668702
});
703+
704+
it('differs structurally from other vector instances', () => {
705+
expect(d.vec4f(1, 2, 3, 4)).toStrictEqual(d.vec4f(1, 2, 3, 4));
706+
expect(d.vec4f(1, 2, 3, 4)).not.toStrictEqual(d.vec4h(1, 2, 3, 4));
707+
expect(d.vec4f(1, 2, 3, 4)).not.toStrictEqual(d.vec4i(1, 2, 3, 4));
708+
expect(d.vec4f(1, 2, 3, 4)).not.toStrictEqual(d.vec4u(1, 2, 3, 4));
709+
});
669710
});
670711

671712
describe('v4b', () => {

0 commit comments

Comments
 (0)