Skip to content

Commit

Permalink
update the rest of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Dec 7, 2023
1 parent 0d49c40 commit dbf014f
Show file tree
Hide file tree
Showing 26 changed files with 360 additions and 308 deletions.
26 changes: 14 additions & 12 deletions property_tests/tests/blob/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
paramBlobs: Named<CandidValueAndMeta<Uint8Array>>[],
returnBlob: CandidValueAndMeta<Uint8Array>
): Test[] {
): Test[][] {
const expectedResult = Uint8Array.from(
paramBlobs
.map((blob) => blob.el.agentResponseValue)
Expand All @@ -19,19 +19,21 @@ export function generateTests(
);

return [
{
name: `blob ${functionName}`,
test: async () => {
const actor = getActor('./tests/blob/test');
[
{
name: `blob ${functionName}`,
test: async () => {
const actor = getActor('./tests/blob/test');

const result = await actor[functionName](
...paramBlobs.map((blob) => blob.el.agentArgumentValue)
);
const result = await actor[functionName](
...paramBlobs.map((blob) => blob.el.agentArgumentValue)
);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/bool/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamBools: Named<CandidValueAndMeta<boolean>>[],
returnBool: CandidValueAndMeta<boolean>
): Test[] {
): Test[][] {
const expectedResult = namedParamBools.reduce(
(acc, param) => acc && param.el.agentResponseValue,
returnBool.agentResponseValue
Expand All @@ -18,17 +18,19 @@ export function generateTests(
);

return [
{
name: `bool ${functionName}`,
test: async () => {
const actor = getActor('./tests/bool/test');
[
{
name: `bool ${functionName}`,
test: async () => {
const actor = getActor('./tests/bool/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/float32/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamFloat32s: Named<CandidValueAndMeta<number>>[],
returnFloat32: CandidValueAndMeta<number>
): Test[] {
): Test[][] {
const expectedResult =
namedParamFloat32s.length === 0
? returnFloat32.agentResponseValue
Expand All @@ -17,17 +17,19 @@ export function generateTests(
(paramFloats) => paramFloats.el.agentArgumentValue
);
return [
{
name: `float32 ${functionName}`,
test: async () => {
const actor = getActor('./tests/float32/test');
[
{
name: `float32 ${functionName}`,
test: async () => {
const actor = getActor('./tests/float32/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/float64/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamFloat64s: Named<CandidValueAndMeta<number>>[],
returnFloat64: CandidValueAndMeta<number>
): Test[] {
): Test[][] {
const count = namedParamFloat64s.length + 1;
const expectedResult =
namedParamFloat64s.reduce(
Expand All @@ -21,17 +21,19 @@ export function generateTests(
);

return [
{
name: `float64 ${functionName}`,
test: async () => {
const actor = getActor('./tests/float64/test');
[
{
name: `float64 ${functionName}`,
test: async () => {
const actor = getActor('./tests/float64/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
30 changes: 16 additions & 14 deletions property_tests/tests/func/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ export function generateTests(
functionName: string,
namedParamFuncs: Named<CandidValueAndMeta<Func>>[],
returnFunc: CandidValueAndMeta<Func>
): Test[] {
): Test[][] {
return [
{
name: `func ${functionName}`,
test: async () => {
const actor = getActor('./tests/func/test');
[
{
name: `func ${functionName}`,
test: async () => {
const actor = getActor('./tests/func/test');

const result = await actor[functionName](
...namedParamFuncs.map(
(param) => param.el.agentArgumentValue
)
);
const result = await actor[functionName](
...namedParamFuncs.map(
(param) => param.el.agentArgumentValue
)
);

return {
Ok: deepEqual(result, returnFunc.agentResponseValue)
};
return {
Ok: deepEqual(result, returnFunc.agentResponseValue)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/int/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamInts: Named<CandidValueAndMeta<bigint>>[],
returnInt: CandidValueAndMeta<bigint>
): Test[] {
): Test[][] {
const expectedResult = namedParamInts.reduce(
(acc, param) => acc + param.el.agentResponseValue,
returnInt.agentResponseValue
Expand All @@ -18,17 +18,19 @@ export function generateTests(
);

return [
{
name: `int ${functionName}`,
test: async () => {
const actor = getActor('./tests/int/test');
[
{
name: `int ${functionName}`,
test: async () => {
const actor = getActor('./tests/int/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/int16/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamInt16s: Named<CandidValueAndMeta<number>>[],
returnInt16: CandidValueAndMeta<number>
): Test[] {
): Test[][] {
const count = namedParamInt16s.length + 1;
const expectedResult = Math.floor(
namedParamInt16s.reduce(
Expand All @@ -21,17 +21,19 @@ export function generateTests(
);

return [
{
name: `int16 ${functionName}`,
test: async () => {
const actor = getActor('./tests/int16/test');
[
{
name: `int16 ${functionName}`,
test: async () => {
const actor = getActor('./tests/int16/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/int32/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamInt32s: Named<CandidValueAndMeta<number>>[],
returnInt32: CandidValueAndMeta<number>
): Test[] {
): Test[][] {
const count = namedParamInt32s.length + 1;
const expectedResult = Math.floor(
namedParamInt32s.reduce(
Expand All @@ -21,17 +21,19 @@ export function generateTests(
);

return [
{
name: `int32 ${functionName}`,
test: async () => {
const actor = getActor('./tests/int32/test');
[
{
name: `int32 ${functionName}`,
test: async () => {
const actor = getActor('./tests/int32/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/int64/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamInt64s: Named<CandidValueAndMeta<bigint>>[],
returnInt64: CandidValueAndMeta<bigint>
): Test[] {
): Test[][] {
const count = namedParamInt64s.length + 1;
const expectedResult =
namedParamInt64s.reduce(
Expand All @@ -20,17 +20,19 @@ export function generateTests(
(param) => param.el.agentArgumentValue
);
return [
{
name: `int64 ${functionName}`,
test: async () => {
const actor = getActor('./tests/int64/test');
[
{
name: `int64 ${functionName}`,
test: async () => {
const actor = getActor('./tests/int64/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
22 changes: 12 additions & 10 deletions property_tests/tests/int8/test/generate_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTests(
functionName: string,
namedParamInt8s: Named<CandidValueAndMeta<number>>[],
returnInt8: CandidValueAndMeta<number>
): Test[] {
): Test[][] {
const count = namedParamInt8s.length + 1;
const expectedResult = Math.floor(
namedParamInt8s.reduce(
Expand All @@ -20,17 +20,19 @@ export function generateTests(
(param) => param.el.agentArgumentValue
);
return [
{
name: `test ${functionName}`,
test: async () => {
const actor = getActor('./tests/int8/test');
[
{
name: `test ${functionName}`,
test: async () => {
const actor = getActor('./tests/int8/test');

const result = await actor[functionName](...paramValues);
const result = await actor[functionName](...paramValues);

return {
Ok: deepEqual(result, expectedResult)
};
return {
Ok: deepEqual(result, expectedResult)
};
}
}
}
]
];
}
Loading

0 comments on commit dbf014f

Please sign in to comment.