diff options
author | Sebastian Luther <SebastianLuther@gmx.de> | 2010-08-18 15:19:24 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-08-18 06:42:32 -0700 |
commit | fa03825f2827dca33ab8241004b677942be4bf46 (patch) | |
tree | 7df2eb8c3e24b030c2fd257f5528603968552883 | |
parent | ebee561758d81d7f3376ce316ff2ea9b6ae13c77 (diff) | |
download | portage-fa03825f2827dca33ab8241004b677942be4bf46.tar.gz portage-fa03825f2827dca33ab8241004b677942be4bf46.tar.bz2 portage-fa03825f2827dca33ab8241004b677942be4bf46.zip |
Revert "Tests: Remove paren_reduce tests"
This reverts commit 67f3bef9efeff7061765edc9515a97143c2f2e55.
-rw-r--r-- | pym/portage/tests/dep/test_paren_reduce.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/pym/portage/tests/dep/test_paren_reduce.py b/pym/portage/tests/dep/test_paren_reduce.py new file mode 100644 index 000000000..bd5f42584 --- /dev/null +++ b/pym/portage/tests/dep/test_paren_reduce.py @@ -0,0 +1,60 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from portage.tests import TestCase +from portage.dep import paren_reduce +from portage.exception import InvalidDependString + +class TestParenReduce(TestCase): + + def testParenReduce(self): + + test_cases = ( + ( "A", ["A"]), + ( "( A )", ["A"]), + ( "|| ( A B )", [ "||", ["A", "B"] ]), + ( "|| ( A || ( B C ) )", [ "||", ["A", "||", ["B", "C"]]]), + ( "|| ( A || ( B C D ) )", [ "||", ["A", "||", ["B", "C", "D"]] ]), + ( "|| ( A || ( B || ( C D ) E ) )", [ "||", ["A", "||", ["B", "||", ["C", "D"], "E"]] ]), + ( "a? ( A )", ["a?", ["A"]]), + + ( "( || ( ( ( A ) B ) ) )", [ "||", ["A", "B"] ]), + ( "( || ( || ( ( A ) B ) ) )", [ "||", ["A", "B"] ]), + ( "( || ( || ( ( A ) B ) ) )", [ "||", ["A", "B"] ]), + ( "|| ( A )", ["A"]), + ( "( || ( || ( || ( A ) foo? ( B ) ) ) )", [ "||", ["A", "foo?", ["B"] ]]), + ( "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )", [ "||", ["bar?", ["A"], "foo?", ["B"] ]]), + ( "A || ( ) foo? ( ) B", ["A", "B"]), + + ( "|| ( A ) || ( B )", ["A", "B"]), + ( "foo? ( A ) foo? ( B )", ["foo?", ["A"], "foo?", ["B"]]), + ) + + test_cases_xfail = ( + "( A", + "A )", + + "||( A B )", + "|| (A B )", + "|| ( A B)", + "|| ( A B", + "|| A B )", + + "|| A B", + "|| ( A B ) )", + "|| || B C", + + "|| ( A B || )", + + "a? A", + + ( "( || ( || || ( A ) foo? ( B ) ) )"), + ( "( || ( || bar? ( A ) foo? ( B ) ) )"), + ) + + for dep_str, expected_result in test_cases: + self.assertEqual(paren_reduce(dep_str), expected_result) + + for dep_str in test_cases_xfail: + self.assertRaisesMsg(dep_str, + InvalidDependString, paren_reduce, dep_str) |