test_rules_sort.py 659 B

123456789101112131415161718
  1. from src.rules.sort import match_sort_multiplicants, move_constant
  2. from src.node import Scope
  3. from src.possibilities import Possibility as P
  4. from tests.rulestestcase import RulesTestCase, tree
  5. class TestRulesSort(RulesTestCase):
  6. def test_match_sort_multiplicants(self):
  7. x, l2 = root = tree('x * 2')
  8. possibilities = match_sort_multiplicants(root)
  9. self.assertEqualPos(possibilities,
  10. [P(root, move_constant, (Scope(root), l2, x))])
  11. def test_move_constant(self):
  12. x, l2 = root = tree('x * 2')
  13. self.assertEqualNodes(move_constant(root, (Scope(root), l2, x)),
  14. l2 * x)