chceckpoint
This commit is contained in:
parent
bb08fbe078
commit
6a91950d02
66
test.exs
66
test.exs
@ -89,6 +89,10 @@ defmodule Tdd do
|
|||||||
_otherwise, acc_set -> acc_set
|
_otherwise, acc_set -> acc_set
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
IO.inspect({assumptions_map, primary_true_predicates, MapSet.size(primary_true_predicates)},
|
||||||
|
label: "CheckConsistency"
|
||||||
|
)
|
||||||
|
|
||||||
if MapSet.size(primary_true_predicates) > 1 do
|
if MapSet.size(primary_true_predicates) > 1 do
|
||||||
:contradiction
|
:contradiction
|
||||||
else
|
else
|
||||||
@ -114,6 +118,8 @@ defmodule Tdd do
|
|||||||
|
|
||||||
check_assumptions_consistency(assumptions_map) == :contradiction ->
|
check_assumptions_consistency(assumptions_map) == :contradiction ->
|
||||||
# Path is semantically impossible
|
# Path is semantically impossible
|
||||||
|
# Important
|
||||||
|
IO.inspect({tdd_id, assumptions_map}, label: "SimplifyContradiction")
|
||||||
update_state(%{op_cache: Map.put(state.op_cache, cache_key, @false_node_id)})
|
update_state(%{op_cache: Map.put(state.op_cache, cache_key, @false_node_id)})
|
||||||
@false_node_id
|
@false_node_id
|
||||||
|
|
||||||
@ -144,6 +150,7 @@ defmodule Tdd do
|
|||||||
make_node_raw(var, simplified_y, simplified_n, simplified_d)
|
make_node_raw(var, simplified_y, simplified_n, simplified_d)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
IO.inspect({tdd_id, assumptions_map, result_id}, label: "SimplifyExit")
|
||||||
update_state(%{op_cache: Map.put(state.op_cache, cache_key, result_id)})
|
update_state(%{op_cache: Map.put(state.op_cache, cache_key, result_id)})
|
||||||
result_id
|
result_id
|
||||||
end
|
end
|
||||||
@ -402,6 +409,30 @@ tdd_empty_tuple = Tdd.type_empty_tuple()
|
|||||||
tdd_any = Tdd.type_any()
|
tdd_any = Tdd.type_any()
|
||||||
tdd_none = Tdd.type_none()
|
tdd_none = Tdd.type_none()
|
||||||
|
|
||||||
|
test = fn name, expected, result ->
|
||||||
|
current_failures = Process.get(:test_failures, [])
|
||||||
|
|
||||||
|
if expected != result do
|
||||||
|
Process.put(:test_failures, [name | current_failures])
|
||||||
|
end
|
||||||
|
|
||||||
|
status = if expected == result, do: "PASSED", else: "FAILED"
|
||||||
|
IO.puts("#{name} (Expected: #{expected}) -> Result: #{result} - #{status}")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Basic Types
|
||||||
|
tdd_foo = Tdd.type_atom_literal(:foo)
|
||||||
|
tdd_bar = Tdd.type_atom_literal(:bar)
|
||||||
|
tdd_baz = Tdd.type_atom_literal(:baz)
|
||||||
|
tdd_atom = Tdd.type_atom()
|
||||||
|
tdd_empty_tuple = Tdd.type_empty_tuple()
|
||||||
|
tdd_tuple = Tdd.type_tuple()
|
||||||
|
# Tuple of size 2, e.g. {any, any}
|
||||||
|
tdd_tuple_s2 = Tdd.type_tuple_sized_any(2)
|
||||||
|
tdd_any = Tdd.type_any()
|
||||||
|
tdd_none = Tdd.type_none()
|
||||||
|
|
||||||
|
test_all = fn ->
|
||||||
IO.puts("\n--- TDD for :foo ---")
|
IO.puts("\n--- TDD for :foo ---")
|
||||||
Tdd.print_tdd(tdd_foo)
|
Tdd.print_tdd(tdd_foo)
|
||||||
|
|
||||||
@ -426,30 +457,6 @@ IO.puts("\n--- TDD for :foo and atom (should be :foo) ---")
|
|||||||
tdd_foo_and_atom = Tdd.intersect(tdd_foo, tdd_atom)
|
tdd_foo_and_atom = Tdd.intersect(tdd_foo, tdd_atom)
|
||||||
# Expected to be structurally identical to tdd_foo
|
# Expected to be structurally identical to tdd_foo
|
||||||
Tdd.print_tdd(tdd_foo_and_atom)
|
Tdd.print_tdd(tdd_foo_and_atom)
|
||||||
|
|
||||||
test = fn name, expected, result ->
|
|
||||||
current_failures = Process.get(:test_failures, [])
|
|
||||||
|
|
||||||
if expected != result do
|
|
||||||
Process.put(:test_failures, [name | current_failures])
|
|
||||||
end
|
|
||||||
|
|
||||||
status = if expected == result, do: "PASSED", else: "FAILED"
|
|
||||||
IO.puts("#{name} (Expected: #{expected}) -> Result: #{result} - #{status}")
|
|
||||||
end
|
|
||||||
|
|
||||||
# Basic Types
|
|
||||||
tdd_foo = Tdd.type_atom_literal(:foo)
|
|
||||||
tdd_bar = Tdd.type_atom_literal(:bar)
|
|
||||||
tdd_baz = Tdd.type_atom_literal(:baz)
|
|
||||||
tdd_atom = Tdd.type_atom()
|
|
||||||
tdd_empty_tuple = Tdd.type_empty_tuple()
|
|
||||||
tdd_tuple = Tdd.type_tuple()
|
|
||||||
# Tuple of size 2, e.g. {any, any}
|
|
||||||
tdd_tuple_s2 = Tdd.type_tuple_sized_any(2)
|
|
||||||
tdd_any = Tdd.type_any()
|
|
||||||
tdd_none = Tdd.type_none()
|
|
||||||
|
|
||||||
IO.puts("\n--- Basic Subtyping Tests ---")
|
IO.puts("\n--- Basic Subtyping Tests ---")
|
||||||
test.(":foo <: atom", true, Tdd.is_subtype(tdd_foo, tdd_atom))
|
test.(":foo <: atom", true, Tdd.is_subtype(tdd_foo, tdd_atom))
|
||||||
test.("atom <: :foo", false, Tdd.is_subtype(tdd_atom, tdd_foo))
|
test.("atom <: :foo", false, Tdd.is_subtype(tdd_atom, tdd_foo))
|
||||||
@ -610,7 +617,11 @@ test.(
|
|||||||
Tdd.is_subtype(tdd_empty_or_s2, tdd_empty_or_s2)
|
Tdd.is_subtype(tdd_empty_or_s2, tdd_empty_or_s2)
|
||||||
)
|
)
|
||||||
|
|
||||||
test.("({} | tuple_size_2) <: tuple_size_2", false, Tdd.is_subtype(tdd_empty_or_s2, tdd_tuple_s2))
|
test.(
|
||||||
|
"({} | tuple_size_2) <: tuple_size_2",
|
||||||
|
false,
|
||||||
|
Tdd.is_subtype(tdd_empty_or_s2, tdd_tuple_s2)
|
||||||
|
)
|
||||||
|
|
||||||
IO.puts("\n--- TDD structure for (atom - :foo) ---")
|
IO.puts("\n--- TDD structure for (atom - :foo) ---")
|
||||||
Tdd.print_tdd(tdd_atom_minus_foo)
|
Tdd.print_tdd(tdd_atom_minus_foo)
|
||||||
@ -620,6 +631,11 @@ IO.puts("\n--- TDD structure for 'atom' for comparison ---")
|
|||||||
Tdd.print_tdd(tdd_atom)
|
Tdd.print_tdd(tdd_atom)
|
||||||
|
|
||||||
IO.inspect(Process.get(:test_failures, []))
|
IO.inspect(Process.get(:test_failures, []))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Should be tdd_none
|
||||||
|
tdd_atom_and_tuple = Tdd.intersect(tdd_atom, tdd_tuple)
|
||||||
|
test.("(atom & tuple) <: none", true, Tdd.is_subtype(tdd_atom_and_tuple, tdd_none))
|
||||||
IO.inspect("tdd_atom_and_tuple")
|
IO.inspect("tdd_atom_and_tuple")
|
||||||
Tdd.print_tdd(tdd_atom_and_tuple)
|
Tdd.print_tdd(tdd_atom_and_tuple)
|
||||||
IO.inspect("tdd_none")
|
IO.inspect("tdd_none")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user