Skip to content

Commit

Permalink
update stable b tree map to use testEquality
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jul 17, 2024
1 parent db16cf1 commit bed003a
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 139 deletions.
16 changes: 5 additions & 11 deletions property_tests/tests/stable_b_tree_map/test/contains_key.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -60,9 +60,7 @@ function generateTests(
keySampleAgentArgumentValue
);

return {
Ok: deepEqual(result, true)
};
return testEquality(result, true);
}
}
],
Expand All @@ -76,9 +74,7 @@ function generateTests(
keySampleAgentArgumentValue
);

return {
Ok: deepEqual(result, true)
};
return testEquality(result, true);
}
}
],
Expand All @@ -92,9 +88,7 @@ function generateTests(
keySampleAgentArgumentValue
);

return {
Ok: deepEqual(result, false)
};
return testEquality(result, false);
}
}
]
Expand Down
20 changes: 9 additions & 11 deletions property_tests/tests/stable_b_tree_map/test/get.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -70,9 +70,9 @@ function generateTests(
keySampleAgentArgumentValue
);

return {
Ok: deepEqual(result, [valueSampleAgentArgumentValue])
};
return testEquality(result, [
valueSampleAgentArgumentValue
]);
}
}
],
Expand All @@ -86,9 +86,9 @@ function generateTests(
keySampleAgentArgumentValue
);

return {
Ok: deepEqual(result, [valueSampleAgentArgumentValue])
};
return testEquality(result, [
valueSampleAgentArgumentValue
]);
}
}
],
Expand All @@ -102,9 +102,7 @@ function generateTests(
keySampleAgentArgumentValue
);

return {
Ok: deepEqual(result, [])
};
return testEquality(result, []);
}
}
]
Expand Down
8 changes: 3 additions & 5 deletions property_tests/tests/stable_b_tree_map/test/insert.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -72,9 +72,7 @@ function generateTests(
valueSampleAgentArgumentValue
);

return {
Ok: deepEqual(result, [])
};
return testEquality(result, []);
}
}
]
Expand Down
16 changes: 5 additions & 11 deletions property_tests/tests/stable_b_tree_map/test/is_empty.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -48,9 +48,7 @@ function generateTests(functionName: string): Test[][] {

const result = await actor[functionName]();

return {
Ok: deepEqual(result, true)
};
return testEquality(result, true);
}
}
],
Expand All @@ -62,9 +60,7 @@ function generateTests(functionName: string): Test[][] {

const result = await actor[functionName]();

return {
Ok: deepEqual(result, false)
};
return testEquality(result, false);
}
}
],
Expand All @@ -76,9 +72,7 @@ function generateTests(functionName: string): Test[][] {

const result = await actor[functionName]();

return {
Ok: deepEqual(result, true)
};
return testEquality(result, true);
}
}
]
Expand Down
36 changes: 15 additions & 21 deletions property_tests/tests/stable_b_tree_map/test/items.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -58,14 +58,12 @@ function generateTests(

const result = await actor[functionName]();

return {
Ok: deepEqual(result, [
[
keySampleAgentArgumentValue,
valueSampleAgentArgumentValue
]
])
};
return testEquality(result, [
[
keySampleAgentArgumentValue,
valueSampleAgentArgumentValue
]
]);
}
}
],
Expand All @@ -77,14 +75,12 @@ function generateTests(

const result = await actor[functionName]();

return {
Ok: deepEqual(result, [
[
keySampleAgentArgumentValue,
valueSampleAgentArgumentValue
]
])
};
return testEquality(result, [
[
keySampleAgentArgumentValue,
valueSampleAgentArgumentValue
]
]);
}
}
],
Expand All @@ -96,9 +92,7 @@ function generateTests(

const result = await actor[functionName]();

return {
Ok: deepEqual(result, [])
};
return testEquality(result, []);
}
}
]
Expand Down
58 changes: 26 additions & 32 deletions property_tests/tests/stable_b_tree_map/test/keys.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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])
);
}
}
],
Expand All @@ -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])
);
}
}
],
Expand All @@ -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([])
);
}
}
]
Expand Down
16 changes: 5 additions & 11 deletions property_tests/tests/stable_b_tree_map/test/len.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -49,9 +49,7 @@ function generateTests(functionName: string): Test[][] {

const result = await actor[functionName]();

return {
Ok: deepEqual(result, 1n)
};
return testEquality(result, 1n);
}
}
],
Expand All @@ -63,9 +61,7 @@ function generateTests(functionName: string): Test[][] {

const result = await actor[functionName]();

return {
Ok: deepEqual(result, 1n)
};
return testEquality(result, 1n);
}
}
],
Expand All @@ -77,9 +73,7 @@ function generateTests(functionName: string): Test[][] {

const result = await actor[functionName]();

return {
Ok: deepEqual(result, 0n)
};
return testEquality(result, 0n);
}
}
]
Expand Down
10 changes: 5 additions & 5 deletions property_tests/tests/stable_b_tree_map/test/remove.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -71,9 +71,9 @@ function generateTests(
keySampleAgentArgumentValue
);

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

0 comments on commit bed003a

Please sign in to comment.