Skip to content

Commit

Permalink
property tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed May 27, 2024
1 parent bd68b4c commit da2596f
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 111 deletions.
14 changes: 6 additions & 8 deletions property_tests/tests/func/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Func } from 'azle/property_tests/arbitraries/candid/reference/func_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -21,12 +21,10 @@ export function generateTests(
)
);

return {
Ok: deepEqual(
result,
returnFunc.value.agentResponseValue
)
};
return testEquality(
result,
returnFunc.value.agentResponseValue
);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/int/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -24,9 +24,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/int16/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -27,9 +27,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/int32/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -27,9 +27,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/int64/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -26,9 +26,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/int8/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -26,9 +26,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/nat/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -24,9 +24,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/nat16/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -27,9 +27,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/nat32/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -27,9 +27,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/nat64/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -26,9 +26,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/nat8/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -27,9 +27,7 @@ export function generateTests(

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

return {
Ok: deepEqual(result, expectedResult)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/null/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -20,9 +20,7 @@ export function generateTests(
)
);

return {
Ok: deepEqual(result, null)
};
return testEquality(result, null);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/opt/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Opt } from 'azle/property_tests/arbitraries/candid/constructed/opt_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -23,9 +23,7 @@ export function generateTests(

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

return {
Ok: deepEqual(expectedResult, result)
};
return testEquality(result, expectedResult);
}
}
]
Expand Down
6 changes: 3 additions & 3 deletions property_tests/tests/principal/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Principal } from '@dfinity/principal';
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -25,7 +25,7 @@ export function generateTests(
)
);

return { Ok: deepEqual(result, expectedResult) };
return testEquality(result, expectedResult);
}
}
]
Expand Down
14 changes: 6 additions & 8 deletions property_tests/tests/record/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Record } from 'azle/property_tests/arbitraries/candid/constructed/record_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -21,12 +21,10 @@ export function generateTests(
)
);

return {
Ok: deepEqual(
result,
returnRecord.value.agentResponseValue
)
};
return testEquality(
result,
returnRecord.value.agentResponseValue
);
}
}
]
Expand Down
14 changes: 6 additions & 8 deletions property_tests/tests/recursive/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Recursive } from 'azle/property_tests/arbitraries/candid/recursive';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -21,12 +21,10 @@ export function generateTests(

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

return {
Ok: deepEqual(
result,
returnRecursive.value.agentResponseValue
)
};
return testEquality(
result,
returnRecursive.value.agentResponseValue
);
}
}
]
Expand Down
11 changes: 5 additions & 6 deletions property_tests/tests/service/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Principal } from '@dfinity/principal';
import { Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';
import { execSync } from 'child_process';

export function generateTests(
Expand Down Expand Up @@ -31,11 +31,10 @@ export function generateTests(
.toString()
.trim();

return {
Ok:
result ===
`(service "${returnService.value.agentArgumentValue.toText()}")`
};
return testEquality(
result,
`(service "${returnService.value.agentArgumentValue.toText()}")`
);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/text/test/generate_tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepEqual, getActor, Named } from 'azle/property_tests';
import { getActor, Named } from 'azle/property_tests';
import { CandidValueAndMeta } from 'azle/property_tests/arbitraries/candid/candid_value_and_meta_arb';
import { Test } from 'azle/test';
import { Test, testEquality } from 'azle/test';

export function generateTests(
functionName: string,
Expand All @@ -24,9 +24,7 @@ export function generateTests(

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

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

0 comments on commit da2596f

Please sign in to comment.