From 173598d055e021aed24c76913acd870aacddabc0 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Thu, 7 Mar 2013 19:23:11 -0500 Subject: [PATCH] add spaceless things --- Makefile | 11 +++++++++-- hy/lex/states.py | 4 ++++ tests/lex/test_lex.py | 20 +++++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e604e1f..c9e52b8 100644 --- a/Makefile +++ b/Makefile @@ -12,13 +12,20 @@ all: @echo " - r" @echo "" +venv: +ifeq (,$(findstring hy,$(VIRTUAL_ENV))) + @echo "You're not in a Hy virtualenv. FOR SHAME" + exit 1 +else + @echo "We're properly in a virtualenv. Going ahead." +endif dev: test flake -test: +test: venv nosetests -sv -tox: +tox: venv tox flake: diff --git a/hy/lex/states.py b/hy/lex/states.py index d6b06bc..8793be7 100644 --- a/hy/lex/states.py +++ b/hy/lex/states.py @@ -119,18 +119,22 @@ class ListeyThing(State): def process(self, char): if char == "(": + self.commit() self.machine.sub(Expression) return if char == "{": + self.commit() self.machine.sub(Dict) return if char == "[": + self.commit() self.machine.sub(List) return if char == "\"": + self.commit() self.machine.sub(String) return diff --git a/tests/lex/test_lex.py b/tests/lex/test_lex.py index 0fd33e2..b20ef22 100644 --- a/tests/lex/test_lex.py +++ b/tests/lex/test_lex.py @@ -118,10 +118,28 @@ def test_lex_line_counting_multi_inner(): assert inner.start_column == 5 -def tgest_dicts(): +def test_dicts(): """ Ensure that we can tokenize a dict. """ objs = tokenize("{foo bar bar baz}") assert objs == [HyDict({ "foo": "bar", "bar": "baz" })] + + +def test_nospace(): + """ Ensure we can tokenize without spaces if we have to """ + entry = tokenize("(foo(one two))")[0] + + assert entry.start_line == 1 + assert entry.start_column == 1 + + assert entry.end_line == 1 + assert entry.end_column == 14 + + entry = entry[1] + assert entry.start_line == 1 + assert entry.start_column == 5 + + assert entry.end_line == 1 + assert entry.end_column == 13