From 7b97da6821a45ce34e731df68980dea0983cf18c Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 23 Jun 2019 02:29:14 +0200 Subject: Shorten __repr__() functions a bit Do 'add = fields.append'. Pointless as an optimization, but shaves some lines, and obvious in context. Also add test coverage for __repr__() for string symbols with user values. --- testsuite.py | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index 8e17d84..4bb1991 100644 --- a/testsuite.py +++ b/testsuite.py @@ -856,25 +856,30 @@ config DEP_REM_CORNER_CASES """) c.syms["VISIBLE"].set_value(2) + c.syms["STRING"].set_value("foo") verify_repr(c.syms["VISIBLE"], """ +""") + + verify_repr(c.syms["STRING"], """ + """) verify_repr(c.syms["DIR_DEP_N"], """ - + """) verify_repr(c.syms["OPTIONS"], """ - + """) verify_repr(c.syms["MULTI_DEF"], """ - + """) verify_repr(c.syms["CHOICE_1"], """ - + """) verify_repr(c.modules, """ @@ -885,29 +890,29 @@ config DEP_REM_CORNER_CASES print("Testing Choice.__repr__()") verify_repr(c.named_choices["CHOICE"], """ - + """) c.named_choices["CHOICE"].set_value(2) verify_repr(c.named_choices["CHOICE"], """ - + """) c.syms["CHOICE_2"].set_value(2) verify_repr(c.named_choices["CHOICE"], """ - + """) c.named_choices["CHOICE"].set_value(1) verify_repr(c.named_choices["CHOICE"], """ - + """) verify_repr(c.syms["CHOICE_HOOK"].nodes[0].next.item, """ - + """) @@ -918,46 +923,46 @@ config DEP_REM_CORNER_CASES """) verify_repr(c.syms["DIR_DEP_N"].nodes[0], """ - + """) verify_repr(c.syms["MULTI_DEF"].nodes[0], """ - + """) verify_repr(c.syms["MULTI_DEF"].nodes[1], """ - + """) verify_repr(c.syms["MENUCONFIG"].nodes[0], """ - + """) verify_repr(c.named_choices["CHOICE"].nodes[0], """ - + """) verify_repr(c.syms["CHOICE_HOOK"].nodes[0].next, """ - + """) verify_repr(c.syms["NO_VISIBLE_IF_HOOK"].nodes[0].next, """ - + """) verify_repr(c.syms["VISIBLE_IF_HOOK"].nodes[0].next, """ - + """) verify_repr(c.syms["COMMENT_HOOK"].nodes[0].next, """ - + """) print("Testing Kconfig.__repr__()") verify_repr(c, """ - + """) os.environ["srctree"] = "Kconfiglib" @@ -971,7 +976,7 @@ config DEP_REM_CORNER_CASES c.warn_assign_undef = True verify_repr(c, """ - + """) os.environ.pop("srctree", None) -- cgit v1.2.3