From 67e890cc9d926213fbec93afb3ee14e6c24f9a50 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 21 Aug 2018 19:48:22 +0200 Subject: 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). --- testsuite.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'testsuite.py') 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) -- cgit v1.2.3