Commit 25bca7e8 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] Tests: Fix typos; add doc

parent df3be842
......@@ -497,11 +497,10 @@ def test_init_forward_unfolding_solution_1(feed_mclanalyser, textual_properties,
mcla = feed_mclanalyser
### Textual properties
# "M", "L", "C"
start, invariant, final = textual_properties[0]
query = MCLSimpleQuery(start, invariant, final)
mcla.unfolder.init_with_query(query)
init_forward_unfolding_solution_1(mcla)
## Search solutions
......@@ -511,6 +510,7 @@ def test_init_forward_unfolding_solution_1(feed_mclanalyser, textual_properties,
### DIMACS properties
query = MCLSimpleQuery(None, None, None)
# [[13]], [[12]], [[3]]
query.dim_start, query.dim_inv, query.dim_final = numeric_properties[0]
mcla.unfolder.init_with_query(query)
init_forward_unfolding_solution_1(mcla)
......@@ -705,7 +705,10 @@ def init_forward_unfolding_solution_1(mcla):
# [_h_0, A, B] [_h_1, N, N]
[-22, 1, 2], [-23, 14, 14]]]
# Crap
# No changes
assert unfolder.initial_constraints == expected_initial_constraints
# Crap dynamic_constraints test
assert unfolder.dynamic_constraints == expected
# L : 12 + 46 = 58
......@@ -749,7 +752,8 @@ def init_forward_unfolding_solution_2(mcla):
# assert unfolder.dynamic_constraints == []
# no frontiers + nothing (no start place)
assert unfolder.initial_constraints == [[-1], [-2], [-3], [-8], [-10], [-11], [-13], [-15]]
expected_initial_constraints = [[-1], [-2], [-3], [-8], [-10], [-11], [-13], [-15]]
assert unfolder.initial_constraints == expected_initial_constraints
# L
assert unfolder.invariant_constraints == [[[12]]]
......@@ -810,7 +814,10 @@ def init_forward_unfolding_solution_2(mcla):
[62, -38], [62, -15], [-18, 9], [-19, 10], [-20, 11], [-21, 7], [-16, 4],
[-17, 5], [-22, 1, 2], [-23, 14, 14]]]
# Crap
# No changes
assert unfolder.initial_constraints == expected_initial_constraints
# Crap dynamic_constraints test
assert unfolder.dynamic_constraints == expected
# L : 12 + shift_step (47) = 59
......@@ -834,6 +841,13 @@ def init_forward_unfolding_solution_3(mcla):
("", "L", "C and K") => [], [[12]], [[3, -47], [11, -47], [-3, -11, 47], [47]]
[[13]], [[12]], [[3]] <= ("M", "L", "C")
No solution
.. todo:: This test contains some stupid results from the generator of
clauses.
=> clauses redondantes en cas d'égalité des events entre l'attribut
au format texte et celui au format DIMACS.
(invariant_constraints)
"""
unfolder = mcla.unfolder
......@@ -949,11 +963,12 @@ def test_init_forward_unfolding_variant_constraints(feed_mclanalyser):
# Check copy of query attribute
assert unfolder._CLUnfolder__variant_property == query.variant_prop
# Check conversion of query attribute
# Check conversion of query attribute into literals
expected = [[[16]], [[22]]]
assert unfolder._CLUnfolder__precomputed_variant_constraints == expected
# Check merge of 2 equivalent attributes
# text ("_h2", "_h_0") + dimacs ([[[16]], [[22]]])
# TODO: => stupid result
query.dim_variant = [[[16]], [[22]]]
unfolder.init_with_query(query)
......@@ -962,15 +977,16 @@ def test_init_forward_unfolding_variant_constraints(feed_mclanalyser):
expected = [[[16], [16]], [[22], [22]]]
assert unfolder._CLUnfolder__precomputed_variant_constraints == expected
# Check merge of 2 different attributes
# Check merge of 2 different attributes (size is different)
query.dim_variant = [[[16]], [[22]], []]
unfolder.init_with_query(query)
# Exception is expected
# Exception is expected (must be the same size)
with pytest.raises(MCLException, match=r".*Incoherent variant properties.*"):
unfolder.init_forward_unfolding()
##
# Check the input of unknown DIMACS literals
# See the absence of check_query=False argument of init_with_query()
query.variant_prop = None
query.dim_variant = [[[16, -47], [17, -47], [-16, -17, 47], [47]], [[22]]]
# With check_query enabled
......@@ -978,7 +994,7 @@ def test_init_forward_unfolding_variant_constraints(feed_mclanalyser):
unfolder.init_with_query(query)
# With check_query disabled
# => this causes an incorrect initialization
# => this causes an incorrect initialization but without error
unfolder.init_with_query(query, check_query=False)
unfolder.init_forward_unfolding()
......@@ -1016,7 +1032,8 @@ def test_init_forward_unfolding_variant_constraints(feed_mclanalyser):
print(unfolder._CLUnfolder__aux_list)
print(unfolder._CLUnfolder__aux_code_table)
# It is important to test this, because an auxiliary variable was previously
# added and we check the full reset of the unfolder here...
# added in previous tests and we check here the full reset of the unfolder
# for a new query (see init_with_query()).
assert unfolder.shift_step == 47
assert unfolder._CLUnfolder__aux_list == ["_lit47"]
assert unfolder._CLUnfolder__aux_code_table == {"_lit47": 47}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment