summaryrefslogtreecommitdiff
path: root/testsuite.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-08-21 19:48:22 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-08-21 20:45:27 +0200
commit67e890cc9d926213fbec93afb3ee14e6c24f9a50 (patch)
treed7f4c2cb945079eb92d7a8e0bff19e3681050558 /testsuite.py
parent5a9c3573460e4003bde46efa0edc2e0fb627a1fe (diff)
Handle multiple definition locations in a nicer way
Instead of precalculating a set() to get unique symbols, precalculate a list with any duplicates from multiple definition locations removed, and preserve the order of the symbols within it. This makes it possible to get rid of the Symbol._written shenanigans in functions that only need to iterate through unique symbols in sorted order, which is all of them except write_config() (because it needs to walk the entire menu tree).
Diffstat (limited to 'testsuite.py')
-rw-r--r--testsuite.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite.py b/testsuite.py
index 143f6c8..7f1ccfe 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -40,6 +40,7 @@ from kconfiglib import Kconfig, Symbol, Choice, COMMENT, MENU, MenuNode, \
TRI_TO_STR, \
escape, unescape, \
expr_str, expr_value, expr_items, split_expr, \
+ _ordered_unique, \
OR, AND, \
KconfigError
import difflib
@@ -254,6 +255,19 @@ def run_selftests():
verify_equal(unescape(r"\afoo\b\c\\d\\\e\\\\f"), r"afoobc\d\e\\f")
+ print("Testing _ordered_unique()")
+
+ verify_equal(_ordered_unique([]), [])
+ verify_equal(_ordered_unique([1]), [1])
+ verify_equal(_ordered_unique([1, 2]), [1, 2])
+ verify_equal(_ordered_unique([1, 1]), [1])
+ verify_equal(_ordered_unique([1, 1, 2]), [1, 2])
+ verify_equal(_ordered_unique([1, 2, 1]), [1, 2])
+ verify_equal(_ordered_unique([1, 2, 2]), [1, 2])
+ verify_equal(_ordered_unique([1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 0]),
+ [1, 2, 3, 4, 0])
+
+
print("Testing expression evaluation")
c = Kconfig("Kconfiglib/tests/Keval", warn=False)