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

Property tests foundation #1389

Merged
merged 49 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
987311e
first property tests
lastmjs Oct 19, 2023
025fdc3
delete unnecessary stuff
lastmjs Oct 19, 2023
895e542
adding gitkeep and module to tsconfig
lastmjs Oct 19, 2023
da0992a
organize arbitraries better
lastmjs Oct 19, 2023
d4d2a45
fix dependencies
lastmjs Oct 20, 2023
e5ebc59
nat test nearing plateau
lastmjs Oct 20, 2023
9c8f5d7
adding nat arbitraries, generalizing canister and query method arbitr…
lastmjs Oct 20, 2023
ced744b
add nat property tests
lastmjs Oct 20, 2023
2329584
add all int property tests
lastmjs Oct 20, 2023
b0ace52
fix test.yml
lastmjs Oct 20, 2023
7a601ce
add vec property tests
lastmjs Oct 20, 2023
327198b
fix issue with multiple property test runs and the require cache
lastmjs Oct 20, 2023
0ab41fd
add gitkeep for vec
lastmjs Oct 20, 2023
f6a8632
add blob tests, fix test.yml
lastmjs Oct 20, 2023
8ee906a
Merge pull request #1405 from demergent-labs/multiple_property_test_r…
lastmjs Oct 20, 2023
b9f4cda
Merge pull request #1407 from demergent-labs/property_tests_blob
lastmjs Oct 20, 2023
f10f211
add property tests for opt
lastmjs Oct 20, 2023
7b9c07f
Merge pull request #1410 from demergent-labs/property_tests_opt
lastmjs Oct 20, 2023
84d59cb
Merge branch 'main' into property_tests
lastmjs Oct 23, 2023
eba5eed
add boolean test
bdemann Oct 20, 2023
9eb8c99
pr fixes
bdemann Oct 20, 2023
e25d143
add float32 example
bdemann Oct 20, 2023
36fd17b
pr fixes
bdemann Oct 20, 2023
105fde1
add float64 test
bdemann Oct 20, 2023
b833356
add null example
bdemann Oct 20, 2023
9f167ab
add string test
bdemann Oct 20, 2023
2d72f7a
Merge branch 'main' into property_test_num_runs
lastmjs Oct 23, 2023
08ea6f5
fix env var typo
lastmjs Oct 23, 2023
cbdd59c
Merge branch 'main' into property_tests
lastmjs Oct 23, 2023
988b186
Merge branch 'property_tests' of github.com:demergent-labs/azle into …
lastmjs Oct 23, 2023
f53b401
Merge branch 'property_tests' into property_test_num_runs
lastmjs Oct 23, 2023
460fcda
cache abstraction
bdemann Oct 23, 2023
01a9b8d
pr_fixes
bdemann Oct 23, 2023
2151d0d
pr fix
bdemann Oct 23, 2023
bc6c5b7
Merge pull request #1408 from demergent-labs/property_tests_boolean
lastmjs Oct 23, 2023
e45adaa
Merge pull request #1409 from demergent-labs/property_tests_float32
lastmjs Oct 23, 2023
15a1d1f
Merge pull request #1411 from demergent-labs/property_tests_float64
lastmjs Oct 23, 2023
36a3243
Merge pull request #1413 from demergent-labs/property_tests_null
lastmjs Oct 23, 2023
ede8b1d
Merge pull request #1412 from demergent-labs/property_tests_string
lastmjs Oct 23, 2023
4e72491
Merge branch 'property_tests' of github.com:demergent-labs/azle into …
lastmjs Oct 23, 2023
088ef15
turn off shrinking
lastmjs Oct 23, 2023
9dc0aa6
filter Rust keywords out of the js function names
lastmjs Oct 23, 2023
5878bb4
Merge pull request #1418 from demergent-labs/property_test_num_runs
lastmjs Oct 23, 2023
08807da
update runTests to return a boolean and not exit the process
lastmjs Oct 23, 2023
9b21a5b
add test support for NaNs and infinities
bdemann Oct 23, 2023
7f9b587
fixup
bdemann Oct 23, 2023
583f193
Merge pull request #1419 from demergent-labs/property_tests_more_erro…
lastmjs Oct 23, 2023
08d689f
pr fixes
bdemann Oct 23, 2023
ab55f50
Merge pull request #1420 from demergent-labs/property_tests_nan_error
lastmjs Oct 23, 2023
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
29 changes: 27 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,24 @@ jobs:
"examples/timers",
"examples/tuple_types",
"examples/update",
"examples/vanilla_js"
"examples/vanilla_js",
"property_tests/tests/blob",
"property_tests/tests/bool",
"property_tests/tests/float32",
"property_tests/tests/float64",
"property_tests/tests/int",
"property_tests/tests/int8",
"property_tests/tests/int16",
"property_tests/tests/int32",
"property_tests/tests/int64",
"property_tests/tests/nat",
"property_tests/tests/nat8",
"property_tests/tests/nat16",
"property_tests/tests/nat32",
"property_tests/tests/nat64",
"property_tests/tests/null",
"property_tests/tests/text",
"property_tests/tests/vec"
]
END
)
Expand Down Expand Up @@ -201,7 +218,15 @@ jobs:
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests }}
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: npm test
run: AZLE_NUM_PROPTEST_RUNS=10 npm test
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && contains(github.head_ref, 'release--') }}
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: AZLE_NUM_PROPTEST_RUNS=100 npm test
- if: ${{ needs.release-candidate-deploy.outputs.should_run_tests && (github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'demergent-labs/release--')) }}
shell: bash -l {0}
working-directory: ${{ matrix.example_directories }}
run: AZLE_NUM_PROPTEST_RUNS=100 npm test

check-basic-integration-tests-success:
needs: basic-integration-tests
Expand Down
60 changes: 30 additions & 30 deletions examples/primitive_types/src/index.did
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
service: () -> {
getBool: () -> (bool) query;
getEmpty: () -> (empty) query;
getFloat32: () -> (float32) query;
getFloat64: () -> (float64) query;
getInt: () -> (int) query;
getInt16: () -> (int16) query;
getInt32: () -> (int32) query;
getInt64: () -> (int64) query;
getInt8: () -> (int8) query;
getNat: () -> (nat) query;
getNat16: () -> (nat16) query;
getNat32: () -> (nat32) query;
getNat64: () -> (nat64) query;
getNat8: () -> (nat8) query;
getNull: () -> (null) query;
getNumber: () -> (float64) query;
getPrincipal: () -> (principal) query;
getReserved: () -> (reserved) query;
getString: () -> (text) query;
printString: (text) -> (text) query;
getText: () -> (text) query;
printText: (text) -> (text) query;
getNumber: () -> (float64) query;
printNumber: (float64) -> (float64) query;
getInt: () -> (int) query;
printBool: (bool) -> (bool) query;
printEmpty: (empty) -> (empty) query;
printFloat32: (float32) -> (float32) query;
printFloat64: (float64) -> (float64) query;
printInt: (int) -> (int) query;
getInt64: () -> (int64) query;
printInt64: (int64) -> (int64) query;
getInt32: () -> (int32) query;
printInt32: (int32) -> (int32) query;
getInt16: () -> (int16) query;
printInt16: (int16) -> (int16) query;
getInt8: () -> (int8) query;
printInt32: (int32) -> (int32) query;
printInt64: (int64) -> (int64) query;
printInt8: (int8) -> (int8) query;
getNat: () -> (nat) query;
printNat: (nat) -> (nat) query;
getNat64: () -> (nat64) query;
printNat64: (nat64) -> (nat64) query;
getNat32: () -> (nat32) query;
printNat32: (nat32) -> (nat32) query;
getNat16: () -> (nat16) query;
printNat16: (nat16) -> (nat16) query;
getNat8: () -> (nat8) query;
printNat32: (nat32) -> (nat32) query;
printNat64: (nat64) -> (nat64) query;
printNat8: (nat8) -> (nat8) query;
getFloat64: () -> (float64) query;
printFloat64: (float64) -> (float64) query;
getFloat32: () -> (float32) query;
printFloat32: (float32) -> (float32) query;
getBool: () -> (bool) query;
printBool: (bool) -> (bool) query;
getPrincipal: () -> (principal) query;
printPrincipal: (principal) -> (principal) query;
getNull: () -> (null) query;
printNull: (null) -> (null) query;
getReserved: () -> (reserved) query;
printNumber: (float64) -> (float64) query;
printPrincipal: (principal) -> (principal) query;
printReserved: (reserved) -> (reserved) query;
getEmpty: () -> (empty) query;
printEmpty: (empty) -> (empty) query;
printString: (text) -> (text) query;
printText: (text) -> (text) query;
}
130 changes: 101 additions & 29 deletions examples/primitive_types/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ export function getTests(
{
name: 'printString',
test: async () => {
const result = await primitiveTypesCanister.printString(
'string'
);
const result =
await primitiveTypesCanister.printString('string');

return {
Ok: result === 'string'
Expand Down Expand Up @@ -62,9 +61,8 @@ export function getTests(
{
name: 'printNumber',
test: async () => {
const result = await primitiveTypesCanister.printNumber(
90071992547409.05
);
const result =
await primitiveTypesCanister.printNumber(90071992547409.05);

return {
Ok: result.toString() === '90071992547409.05'
Expand All @@ -86,9 +84,10 @@ export function getTests(
{
name: 'printInt',
test: async () => {
const result = await primitiveTypesCanister.printInt(
170_141_183_460_469_231_731_687_303_715_884_105_727n
);
const result =
await primitiveTypesCanister.printInt(
170_141_183_460_469_231_731_687_303_715_884_105_727n
);

return {
Ok:
Expand All @@ -110,9 +109,10 @@ export function getTests(
{
name: 'printInt64',
test: async () => {
const result = await primitiveTypesCanister.printInt(
9_223_372_036_854_775_807n
);
const result =
await primitiveTypesCanister.printInt(
9_223_372_036_854_775_807n
);

return {
Ok: result === 9_223_372_036_854_775_807n
Expand All @@ -132,9 +132,8 @@ export function getTests(
{
name: 'printInt32',
test: async () => {
const result = await primitiveTypesCanister.printInt32(
2_147_483_647
);
const result =
await primitiveTypesCanister.printInt32(2_147_483_647);

return {
Ok: result === 2_147_483_647
Expand Down Expand Up @@ -196,9 +195,10 @@ export function getTests(
{
name: 'printNat',
test: async () => {
const result = await primitiveTypesCanister.printNat(
340_282_366_920_938_463_463_374_607_431_768_211_455n
);
const result =
await primitiveTypesCanister.printNat(
340_282_366_920_938_463_463_374_607_431_768_211_455n
);

return {
Ok:
Expand All @@ -220,9 +220,10 @@ export function getTests(
{
name: 'printNat64',
test: async () => {
const result = await primitiveTypesCanister.printNat64(
18_446_744_073_709_551_615n
);
const result =
await primitiveTypesCanister.printNat64(
18_446_744_073_709_551_615n
);

return {
Ok: result === 18_446_744_073_709_551_615n
Expand All @@ -242,9 +243,8 @@ export function getTests(
{
name: 'printNat32',
test: async () => {
const result = await primitiveTypesCanister.printNat32(
4_294_967_295
);
const result =
await primitiveTypesCanister.printNat32(4_294_967_295);

return {
Ok: result === 4_294_967_295
Expand Down Expand Up @@ -303,13 +303,50 @@ export function getTests(
},
{
name: 'printFloat64',
test: async () => {
const result =
await primitiveTypesCanister.printFloat64(
2.718281828459045
);

return {
Ok: result.toString() === '2.718281828459045'
};
}
},
{
name: 'print Float64.Nan',
test: async () => {
const result = await primitiveTypesCanister.printFloat64(
2.718281828459045
Number.NaN
);

return {
Ok: result.toString() === '2.718281828459045'
Ok: Number.isNaN(result)
};
}
},
{
name: 'print positive Float64.Infinity',
test: async () => {
const result = await primitiveTypesCanister.printFloat64(
Number.POSITIVE_INFINITY
);

return {
Ok: !Number.isFinite(result)
};
}
},
{
name: 'print negative Float64.Infinity',
test: async () => {
const result = await primitiveTypesCanister.printFloat64(
Number.NEGATIVE_INFINITY
);

return {
Ok: !Number.isFinite(result)
};
}
},
Expand All @@ -327,16 +364,51 @@ export function getTests(
{
name: 'printFloat32',
test: async () => {
const result = await primitiveTypesCanister.printFloat32(
3.1415927
);
const result =
await primitiveTypesCanister.printFloat32(3.1415927);

return {
// Ok: result.toString() === '3.1415927' // TODO on the command line this is returned
Ok: result.toString() === '3.1415927410125732'
};
}
},
{
name: 'print Float32.Nan',
test: async () => {
const result = await primitiveTypesCanister.printFloat32(
Number.NaN
);

return {
Ok: Number.isNaN(result)
};
}
},
{
name: 'print positive Float32.Infinity',
test: async () => {
const result = await primitiveTypesCanister.printFloat32(
Number.POSITIVE_INFINITY
);

return {
Ok: !Number.isFinite(result)
};
}
},
{
name: 'print negative Float32.Infinity',
test: async () => {
const result = await primitiveTypesCanister.printFloat32(
Number.NEGATIVE_INFINITY
);

return {
Ok: !Number.isFinite(result)
};
}
},
{
name: 'getBool',
test: async () => {
Expand Down
39 changes: 39 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@types/fs-extra": "9.0.13",
"eslint": "8.11.0",
"eslint-config-prettier": "8.5.0",
"fast-check": "^3.13.1",
"husky": "7.0.4",
"lint-staged": "12.3.7",
"prettier": "^3.0.3"
Expand Down
Loading