summaryrefslogtreecommitdiff
path: root/testsuite.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-06-11 17:49:49 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-06-11 18:30:51 +0200
commit506e3fb211d22f62115ce83e9247266c5d87ea24 (patch)
tree86b41a341b3da5d527c5a85583cc9d46daebe294 /testsuite.py
parent330017a99cd7619c9eb1fe5fccbb02f5d9e7f6c5 (diff)
Add a function for getting all items in an expression
Handy e.g. when searching.
Diffstat (limited to 'testsuite.py')
-rw-r--r--testsuite.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/testsuite.py b/testsuite.py
index d976c12..1f1bc32 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -45,7 +45,7 @@ from kconfiglib import Kconfig, Symbol, Choice, COMMENT, MENU, MenuNode, \
BOOL, TRISTATE, HEX, STRING, \
TRI_TO_STR, \
escape, unescape, \
- expr_str, expr_value, split_expr, \
+ expr_str, expr_value, expr_items, split_expr, \
OR, AND, \
KconfigSyntaxError
import difflib
@@ -990,6 +990,25 @@ g
"A || B || C")
+ print("Testing expr_items()")
+
+ c = Kconfig("Kconfiglib/tests/Kexpr_items")
+
+ def verify_expr_items(expr, *sym_names):
+ verify_equal(tuple(sorted(item.name for item in expr_items(expr))),
+ sym_names)
+
+ verify_expr_items(
+ c.syms["TEST"].defaults[0][0],
+ "A", "B", "C", "D", "E", "F", "G", "H"
+ )
+
+ verify_expr_items(
+ c.syms["TEST_CHOICE"].nodes[0].prompt[1],
+ "A", "CHOICE"
+ )
+
+
print("Testing split_expr()")
def verify_split(to_split, op, operand_strs):