From bed003a07d55275679bf3b084eaa5f3ff737d5dd Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Wed, 17 Jul 2024 16:58:15 -0600 Subject: [PATCH] update stable b tree map to use testEquality --- .../stable_b_tree_map/test/contains_key.ts | 16 ++--- .../tests/stable_b_tree_map/test/get.ts | 20 +++---- .../tests/stable_b_tree_map/test/insert.ts | 8 +-- .../tests/stable_b_tree_map/test/is_empty.ts | 16 ++--- .../tests/stable_b_tree_map/test/items.ts | 36 +++++------- .../tests/stable_b_tree_map/test/keys.ts | 58 +++++++++---------- .../tests/stable_b_tree_map/test/len.ts | 16 ++--- .../tests/stable_b_tree_map/test/remove.ts | 10 ++-- .../tests/stable_b_tree_map/test/values.ts | 58 +++++++++---------- 9 files changed, 99 insertions(+), 139 deletions(-) diff --git a/property_tests/tests/stable_b_tree_map/test/contains_key.ts b/property_tests/tests/stable_b_tree_map/test/contains_key.ts index 74dddc6234..07f0c8d297 100644 --- a/property_tests/tests/stable_b_tree_map/test/contains_key.ts +++ b/property_tests/tests/stable_b_tree_map/test/contains_key.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function ContainsKeyTestArb( @@ -60,9 +60,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ], @@ -76,9 +74,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ], @@ -92,9 +88,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, false) - }; + return testEquality(result, false); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/get.ts b/property_tests/tests/stable_b_tree_map/test/get.ts index 337c9f8f49..7ee9b60622 100644 --- a/property_tests/tests/stable_b_tree_map/test/get.ts +++ b/property_tests/tests/stable_b_tree_map/test/get.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function GetTestArb( @@ -70,9 +70,9 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, [valueSampleAgentArgumentValue]) - }; + return testEquality(result, [ + valueSampleAgentArgumentValue + ]); } } ], @@ -86,9 +86,9 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, [valueSampleAgentArgumentValue]) - }; + return testEquality(result, [ + valueSampleAgentArgumentValue + ]); } } ], @@ -102,9 +102,7 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, []) - }; + return testEquality(result, []); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/insert.ts b/property_tests/tests/stable_b_tree_map/test/insert.ts index 226f661b40..573aa8228e 100644 --- a/property_tests/tests/stable_b_tree_map/test/insert.ts +++ b/property_tests/tests/stable_b_tree_map/test/insert.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function InsertTestArb( @@ -72,9 +72,7 @@ function generateTests( valueSampleAgentArgumentValue ); - return { - Ok: deepEqual(result, []) - }; + return testEquality(result, []); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/is_empty.ts b/property_tests/tests/stable_b_tree_map/test/is_empty.ts index 5cfad8dda6..cee6467046 100644 --- a/property_tests/tests/stable_b_tree_map/test/is_empty.ts +++ b/property_tests/tests/stable_b_tree_map/test/is_empty.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function IsEmptyTestArb( @@ -48,9 +48,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ], @@ -62,9 +60,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, false) - }; + return testEquality(result, false); } } ], @@ -76,9 +72,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, true) - }; + return testEquality(result, true); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/items.ts b/property_tests/tests/stable_b_tree_map/test/items.ts index d05a6cb122..3948ffeb19 100644 --- a/property_tests/tests/stable_b_tree_map/test/items.ts +++ b/property_tests/tests/stable_b_tree_map/test/items.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function ItemsTestArb( @@ -58,14 +58,12 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual(result, [ - [ - keySampleAgentArgumentValue, - valueSampleAgentArgumentValue - ] - ]) - }; + return testEquality(result, [ + [ + keySampleAgentArgumentValue, + valueSampleAgentArgumentValue + ] + ]); } } ], @@ -77,14 +75,12 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual(result, [ - [ - keySampleAgentArgumentValue, - valueSampleAgentArgumentValue - ] - ]) - }; + return testEquality(result, [ + [ + keySampleAgentArgumentValue, + valueSampleAgentArgumentValue + ] + ]); } } ], @@ -96,9 +92,7 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual(result, []) - }; + return testEquality(result, []); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/keys.ts b/property_tests/tests/stable_b_tree_map/test/keys.ts index 8777f4f1f2..650b3295e1 100644 --- a/property_tests/tests/stable_b_tree_map/test/keys.ts +++ b/property_tests/tests/stable_b_tree_map/test/keys.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; import { getArrayForCandidType, getArrayStringForCandidType } from './utils'; @@ -62,16 +62,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from([keySample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from([keySample.value.agentArgumentValue]) + ); } } ], @@ -83,16 +81,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from([keySample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from([keySample.value.agentArgumentValue]) + ); } } ], @@ -104,16 +100,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - keySample.src.candidTypeAnnotation - ).from([]) - ) - }; + return testEquality( + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + keySample.src.candidTypeAnnotation + ).from([]) + ); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/len.ts b/property_tests/tests/stable_b_tree_map/test/len.ts index 5b69ee7bd8..8da1aa9d25 100644 --- a/property_tests/tests/stable_b_tree_map/test/len.ts +++ b/property_tests/tests/stable_b_tree_map/test/len.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function LenTestArb( @@ -49,9 +49,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, 1n) - }; + return testEquality(result, 1n); } } ], @@ -63,9 +61,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, 1n) - }; + return testEquality(result, 1n); } } ], @@ -77,9 +73,7 @@ function generateTests(functionName: string): Test[][] { const result = await actor[functionName](); - return { - Ok: deepEqual(result, 0n) - }; + return testEquality(result, 0n); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/remove.ts b/property_tests/tests/stable_b_tree_map/test/remove.ts index 2d43336bd4..b8c1d0390a 100644 --- a/property_tests/tests/stable_b_tree_map/test/remove.ts +++ b/property_tests/tests/stable_b_tree_map/test/remove.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; export function RemoveTestArb( @@ -71,9 +71,9 @@ function generateTests( keySampleAgentArgumentValue ); - return { - Ok: deepEqual(result, [valueSampleAgentArgumentValue]) - }; + return testEquality(result, [ + valueSampleAgentArgumentValue + ]); } } ] diff --git a/property_tests/tests/stable_b_tree_map/test/values.ts b/property_tests/tests/stable_b_tree_map/test/values.ts index bf0d75de62..b5dde34e39 100644 --- a/property_tests/tests/stable_b_tree_map/test/values.ts +++ b/property_tests/tests/stable_b_tree_map/test/values.ts @@ -1,8 +1,8 @@ -import { deepEqual, getActor } from 'azle/property_tests'; +import { getActor } from 'azle/property_tests'; import { QueryMethod } from 'azle/property_tests/arbitraries/canister_methods/query_method_arb'; import { StableBTreeMap } from 'azle/property_tests/arbitraries/stable_b_tree_map_arb'; import { UniqueIdentifierArb } from 'azle/property_tests/arbitraries/unique_identifier_arb'; -import { AzleResult, Test } from 'azle/property_tests/test'; +import { AzleResult, Test, testEquality } from 'azle/property_tests/test'; import fc from 'fast-check'; import { getArrayForCandidType, getArrayStringForCandidType } from './utils'; @@ -65,16 +65,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from([valueSample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from([valueSample.value.agentArgumentValue]) + ); } } ], @@ -86,16 +84,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from([valueSample.value.agentArgumentValue]) - ) - }; + return testEquality( + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from([valueSample.value.agentArgumentValue]) + ); } } ], @@ -107,16 +103,14 @@ function generateTests( const result = await actor[functionName](); - return { - Ok: deepEqual( - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from(result), - getArrayForCandidType( - valueSample.src.candidTypeAnnotation - ).from([]) - ) - }; + return testEquality( + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from(result), + getArrayForCandidType( + valueSample.src.candidTypeAnnotation + ).from([]) + ); } } ]