add spaceless things

This commit is contained in:
Paul Tagliamonte 2013-03-07 19:23:11 -05:00
parent d5de7a480b
commit 173598d055
3 changed files with 32 additions and 3 deletions

View File

@ -12,13 +12,20 @@ all:
@echo " - r" @echo " - r"
@echo "" @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 dev: test flake
test: test: venv
nosetests -sv nosetests -sv
tox: tox: venv
tox tox
flake: flake:

View File

@ -119,18 +119,22 @@ class ListeyThing(State):
def process(self, char): def process(self, char):
if char == "(": if char == "(":
self.commit()
self.machine.sub(Expression) self.machine.sub(Expression)
return return
if char == "{": if char == "{":
self.commit()
self.machine.sub(Dict) self.machine.sub(Dict)
return return
if char == "[": if char == "[":
self.commit()
self.machine.sub(List) self.machine.sub(List)
return return
if char == "\"": if char == "\"":
self.commit()
self.machine.sub(String) self.machine.sub(String)
return return

View File

@ -118,10 +118,28 @@ def test_lex_line_counting_multi_inner():
assert inner.start_column == 5 assert inner.start_column == 5
def tgest_dicts(): def test_dicts():
""" Ensure that we can tokenize a dict. """ """ Ensure that we can tokenize a dict. """
objs = tokenize("{foo bar bar baz}") objs = tokenize("{foo bar bar baz}")
assert objs == [HyDict({ assert objs == [HyDict({
"foo": "bar", "foo": "bar",
"bar": "baz" "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