From 506e3fb211d22f62115ce83e9247266c5d87ea24 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 11 Jun 2018 17:49:49 +0200 Subject: Add a function for getting all items in an expression Handy e.g. when searching. --- testsuite.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'testsuite.py') 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): -- cgit v1.2.3