Hi all, generating a property test and want to make sure that map_a and map_b are not equal, if they are then just pass :ok, and if not then assert.
Here is the code :
property "when a & b are arbitrary small json objects; patch(a, diff(a,b)) == b" do
primitive = one_of([string(:printable), integer()])
json_fragment_gen =
tree(primitive, fn child_gen ->
StreamData.one_of([
# A JSON array
list_of(child_gen),
# A JSON object. Only supports string keys.
map_of(string(:printable), child_gen)
])
end)
# Only valid top-level JSON are objects and arrays
json_gen = json_fragment_gen |> filter(fn val -> is_map(val) end, 100)
check all(
map_a <- json_gen,
map_b <- json_gen,
max_runs: 100,
initial_size: 1,
max_generation_size: 50
) do
assert map_b == js_patch(map_a, JsonDiffEx.diff(map_a, map_b))
So instead of checking before the assertion, is there a way to generate two unique maps that can never be equal to each other or if they are equal to each to just ignore it or pass :ok.
property "when a & b are arbitrary small json objects; patch(a, diff(a,b)) == b" do
primitive = one_of([string(:printable), integer()])
json_fragment_gen =
tree(primitive, fn child_gen ->
StreamData.one_of([
# A JSON array
list_of(child_gen),
# A JSON object. Only supports string keys.
map_of(string(:printable), child_gen)
])
end)
# Only valid top-level JSON are objects and arrays
json_gen = json_fragment_gen |> filter(fn val -> is_map(val) end, 100)
check all(
map_a <- json_gen,
map_b <- json_gen,
max_runs: 100,
initial_size: 1,
max_generation_size: 50
) do
if map_a == map_b do
:ok
else
assert map_b == js_patch(map_a, JsonDiffEx.diff(map_a, map_b))
Any help would be appreciated, thanks in advance.