Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bob Tolbert 2013-06-23 23:09:30 -06:00
commit 1f977cae8d
2 changed files with 32 additions and 0 deletions

View File

@ -959,6 +959,20 @@ class HyASTCompiler(object):
return ret return ret
@builds("break")
def compile_break_expression(self, expr):
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=expr.start_line,
col_offset=expr.start_column)
return ret
@builds("assert") @builds("assert")
@checkargs(1) @checkargs(1)
def compile_assert_expression(self, expr): def compile_assert_expression(self, expr):

View File

@ -685,6 +685,7 @@
42 42
43)))) 43))))
(defn test-try-except-return [] (defn test-try-except-return []
"NATIVE: test we can return from in a try except" "NATIVE: test we can return from in a try except"
(assert (= ((fn [] (try xxx (except [NameError] (+ 1 1))))) 2)) (assert (= ((fn [] (try xxx (except [NameError] (+ 1 1))))) 2))
@ -729,6 +730,7 @@
"success") "success")
(except [NameError] "failure"))))) (except [NameError] "failure")))))
(defn test-encoding-nightmares [] (defn test-encoding-nightmares []
"NATIVE: test unicode encoding escaping crazybits" "NATIVE: test unicode encoding escaping crazybits"
(assert (= (len "ℵℵℵ♥♥♥\t♥♥\r\n") 11))) (assert (= (len "ℵℵℵ♥♥♥\t♥♥\r\n") 11)))
@ -737,3 +739,19 @@
(defn test-keyword-dict-access [] (defn test-keyword-dict-access []
"NATIVE: test keyword dict access" "NATIVE: test keyword dict access"
(assert (= "test" (:foo {:foo "test"})))) (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])))