From b56a03750f4161462cf4ea5ed1c5883871fb87a2 Mon Sep 17 00:00:00 2001 From: Allison Kaptur Date: Mon, 9 Jun 2014 16:33:32 -0400 Subject: [PATCH] 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. :( --- tests/native_tests/native_macros.hy | 3 --- tests/native_tests/py3_only_tests.hy | 24 ++++++++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy index 0fdd87e..ad76e34 100644 --- a/tests/native_tests/native_macros.hy +++ b/tests/native_tests/native_macros.hy @@ -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)))))) diff --git a/tests/native_tests/py3_only_tests.hy b/tests/native_tests/py3_only_tests.hy index ba3ecca..8bcc3c1 100644 --- a/tests/native_tests/py3_only_tests.hy +++ b/tests/native_tests/py3_only_tests.hy @@ -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 [] - (for* [i (range 3)] - (yield i)) - (yield-from [1 2 3])) - (assert (= (list (yield-from-test)) [0 1 2 1 2 3])))) + "NATIVE: testing yield from" + + (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)