From 4f0ec2f749dc2b88e0f17dc37f3078836318473c Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 6 Dec 2012 22:42:58 +0100 Subject: Add selftests for eval(). --- kconfigtest.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/kconfigtest.py b/kconfigtest.py index 8f01402..3d1617b 100644 --- a/kconfigtest.py +++ b/kconfigtest.py @@ -41,6 +41,10 @@ def run_selftests(): print "Running selftests...\n" + # + # is_modifiable() + # + print "Testing is_modifiable()..." c = kconfiglib.Config("Kconfiglib/tests/Kmodifiable") for s in (c["VISIBLE"], @@ -59,6 +63,10 @@ def run_selftests(): assert_false(s.is_modifiable(), "{0} should not be modifiable".format(s.get_name())) + # + # get_lower/upper_bound() and get_assignable_values() + # + print "Testing get_lower/upper_bound() and get_assignable_values()..." c = kconfiglib.Config("Kconfiglib/tests/Kbounds") def assert_bounds(sym, lower, upper): @@ -100,6 +108,32 @@ def run_selftests(): assert_bounds("INT", None, None) assert_bounds("HEX", None, None) + # + # eval() (Already well exercised. Just test some basics.) + # + + # TODO: Stricter syntax checking? + + print "Testing eval()..." + c = kconfiglib.Config("Kconfiglib/tests/Keval") + def assert_val(expr, val): + res = c.eval(expr) + assert_true(res == val, + "'{0}' evaluated to {1}, expected {2}".\ + format(expr, res, val)) + # No modules + assert_val("n", "n") + assert_val("m", "n") + assert_val("y", "y") + assert_val("M", "y") + # Modules + c["MODULES"].set_value("y") + assert_val("n", "n") + assert_val("m", "m") + assert_val("y", "y") + assert_val("M", "m") + assert_val("(Y || N) && (m && y)", "m") + print def run_compatibility_tests(): -- cgit v1.2.3