diff --git a/library/cadbiom/models/clause_constraints/mcl/TestMCLTranslators.py b/library/cadbiom/models/clause_constraints/mcl/TestMCLTranslators.py index 5d7ce40f239572c32a49b4c66cff7cb6ab7d781d..c5d6ecac3a349b353ca7a1d66a1a61731ff37246 100644 --- a/library/cadbiom/models/clause_constraints/mcl/TestMCLTranslators.py +++ b/library/cadbiom/models/clause_constraints/mcl/TestMCLTranslators.py @@ -43,6 +43,7 @@ Unitary tests for the translators """ from __future__ import print_function +import pkg_resources import unittest import sys @@ -770,21 +771,37 @@ class TestFull(unittest.TestCase): TRACE_FILE.write( 'place_clocks'+ cl_ds.place_clocks.__str__()+'\n') TRACE_FILE.write( 'inputs'+ cl_ds.inputs.__str__()+'\n') - @unittest.skip("Test files not provided") - def test_tgf_no_clock(self): - """ - optimisation gain comparison + def test_antlr_optimization(self): + """Optimization gain comparison when using MCLTranslator optimizations + for ANTLR translation (subexpression elimination) + + .. note:: Use test file instead of not provided: + "../ucl/examples/test_tgfb_ref_300511.bcx" """ rep = ErrorRep() + mcla = MCLAnalyser(rep) - mcla.opti = False - mcla.build_from_chart_file("../ucl/examples/test_tgfb_ref_300511.bcx") - mess = '\n- NB Clauses:' + str(len(mcla.dynamical_system.list_clauses)) - TRACE_FILE.write(mess) + mcla.translator_opti = False + filename = pkg_resources.resource_filename( + __name__, # package name + "../../guard_transitions/translators/tests/tgf_cano_noclock_cmp.cal" + ) + mcla.build_from_cadlang(filename) + nb_clauses_without_opti = len(mcla.dynamic_system.list_clauses) + TRACE_FILE.write('\n- NB Clauses:' + str(nb_clauses_without_opti)) + mcla = MCLAnalyser(rep) - mcla.build_from_chart_file("../ucl/examples/test_tgfb_ref_300511.bcx") - mess = '\n- NB Clauses:' + str(len(mcla.dynamical_system.list_clauses)) - TRACE_FILE.write(mess) + filename = pkg_resources.resource_filename( + __name__, # package name + "../../guard_transitions/translators/tests/tgf_cano_noclock_cmp.cal" + ) + mcla.build_from_cadlang(filename) + nb_clauses_with_opti = len(mcla.dynamic_system.list_clauses) + TRACE_FILE.write('\n- NB Clauses:' + str(nb_clauses_with_opti)) + + assert nb_clauses_with_opti < nb_clauses_without_opti + assert nb_clauses_with_opti == 1573 + assert nb_clauses_without_opti == 1909 class TestMCLSigExprVisitor (unittest.TestCase): """