test_strategy.py 1.3 KB

1234567891011121314151617181920212223242526272829
  1. # This file is part of TRS (http://math.kompiler.org)
  2. #
  3. # TRS is free software: you can redistribute it and/or modify it under the
  4. # terms of the GNU Affero General Public License as published by the Free
  5. # Software Foundation, either version 3 of the License, or (at your option) any
  6. # later version.
  7. #
  8. # TRS is distributed in the hope that it will be useful, but WITHOUT ANY
  9. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  10. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  11. # details.
  12. #
  13. # You should have received a copy of the GNU Affero General Public License
  14. # along with TRS. If not, see <http://www.gnu.org/licenses/>.
  15. from src.rules.factors import expand_double, expand_single
  16. from src.node import Scope
  17. from src.possibilities import Possibility as P
  18. from src.strategy import find_possibilities
  19. from tests.rulestestcase import RulesTestCase, tree
  20. class TestStrategy(RulesTestCase):
  21. def test_find_possibilities_sort(self):
  22. (ab, cd), e = root = tree('(a + b)(c + d)e')
  23. self.assertEqualPos(find_possibilities(root),
  24. [P(root, expand_single, (Scope(root), cd, e)),
  25. P(root, expand_single, (Scope(root), ab, e)),
  26. P(root, expand_double, (Scope(root), ab, cd))])