revert yield-from test

Yield-from was introduced in 3.3, so we have to catch the compile error that's raise in 3.2. :(
This commit is contained in:
Allison Kaptur 2014-06-09 16:33:32 -04:00
parent a2f917aba3
commit b56a03750f
2 changed files with 18 additions and 9 deletions

View File

@ -1,6 +1,3 @@
(import [hy._compat [PY33]])
(import [hy.errors [HyCompileError]])
(defmacro rev [&rest body]
"Execute the `body` statements in reverse"
(quasiquote (do (unquote-splice (list (reversed body))))))

View File

@ -1,13 +1,25 @@
;; Tests where the emited code relies on Python 3.
;; Conditionally included in nosetests runs.
(import [hy._compat [PY33]])
(import [hy.errors [HyCompileError]])
(defn test-yield-from []
"NATIVE: testing yield from"
(do (defn yield-from-test []
(try
(eval
'(do (defn yield-from-test []
(for* [i (range 3)]
(yield i))
(yield-from [1 2 3]))
(assert (= (list (yield-from-test)) [0 1 2 1 2 3]))))
(catch [e HyCompileError]
;; Yield-from is supported in py3.3+ only
(assert (not PY33)))
(else (assert PY33))))
(defn test-exception-cause []
(try (raise ValueError :from NameError)