fixed a bug and added tests

This commit is contained in:
Morten Linderud 2013-06-24 03:26:40 +02:00
parent a455800bc7
commit 73c1f218e2
2 changed files with 22 additions and 4 deletions

View File

@ -961,15 +961,15 @@ class HyASTCompiler(object):
@builds("break")
def compile_break_expression(self, expr):
ret = ast.Break(lineno=e.start_line,
col_offset=e.start_column)
ret = ast.Break(lineno=expr.start_line,
col_offset=expr.start_column)
return ret
@builds("continue")
def compile_continue_expression(self, expr):
ret = ast.Continue(lineno=e.start_line,
col_offset=e.start_column)
ret = ast.Continue(lineno=expr.start_line,
col_offset=expr.start_column)
return ret

View File

@ -685,6 +685,7 @@
42
43))))
(defn test-try-except-return []
"NATIVE: test we can return from in a try except"
(assert (= ((fn [] (try xxx (except [NameError] (+ 1 1))))) 2))
@ -729,6 +730,7 @@
"success")
(except [NameError] "failure")))))
(defn test-encoding-nightmares []
"NATIVE: test unicode encoding escaping crazybits"
(assert (= (len "ℵℵℵ♥♥♥\t♥♥\r\n") 11)))
@ -737,3 +739,19 @@
(defn test-keyword-dict-access []
"NATIVE: test keyword dict access"
(assert (= "test" (:foo {:foo "test"}))))
(defn test-break-breaking []
"NATIVE: test checking if break actually breaks"
(defn holy-grail [] (for [x (range 10)] (if (= x 5) (break))) x)
(assert (= (holy-grail) 5)))
(defn test-continue-continuation []
"NATIVE: test checking if continue actually continues"
(setv y [])
(for [x (range 10)]
(if (!= x 5)
(continue))
(.append y x))
(assert (= y [5])))