From e49ad3b3d5c53f236db6c8f747a4c64424104f89 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 13 Jan 2014 22:27:44 +0100 Subject: [PATCH] tests/lex/test_lex.py: Add a few tests to cover identifier mangling Signed-off-by: Gergely Nagy --- tests/lex/test_lex.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/lex/test_lex.py b/tests/lex/test_lex.py index af9f286..e8b7a9c 100644 --- a/tests/lex/test_lex.py +++ b/tests/lex/test_lex.py @@ -266,3 +266,31 @@ def test_lex_comment_382(): """Ensure that we can tokenize sources with a comment at the end""" entry = tokenize("foo ;bar\n;baz") assert entry == [HySymbol("foo")] + + +def test_lex_mangling_star(): + """Ensure that mangling starred identifiers works according to plan""" + entry = tokenize("*foo*") + assert entry == [HySymbol("FOO")] + entry = tokenize("*") + assert entry == [HySymbol("*")] + entry = tokenize("*foo") + assert entry == [HySymbol("*foo")] + + +def test_lex_mangling_hyphen(): + """Ensure that hyphens get translated to underscores during mangling""" + entry = tokenize("foo-bar") + assert entry == [HySymbol("foo_bar")] + entry = tokenize("-") + assert entry == [HySymbol("-")] + + +def test_lex_mangling_qmark(): + """Ensure that identifiers ending with a question mark get mangled ok""" + entry = tokenize("foo?") + assert entry == [HySymbol("is_foo")] + entry = tokenize("?") + assert entry == [HySymbol("?")] + entry = tokenize("im?foo") + assert entry == [HySymbol("im?foo")]