From 917ba9fce59b5bc242035a355a724185f0bf4540 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Thu, 20 Nov 2014 20:40:22 -0600 Subject: [PATCH] Test to ensure exception handling in yield-from works right --- tests/native_tests/native_macros.hy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy index 33e7637..9066f9b 100644 --- a/tests/native_tests/native_macros.hy +++ b/tests/native_tests/native_macros.hy @@ -241,5 +241,21 @@ (yield-from [1 2 3])) (assert (= (list (yield-from-test)) [0 1 2 1 2 3]))) +(defn test-yield-from-exception-handling [] + "NATIVE: Ensure exception handling in yield from works right" + (defn yield-from-subgenerator-test [] + (yield 1) + (yield 2) + (yield 3) + (assert 0)) + (defn yield-from-test [] + (for* [i (range 3)] + (yield i)) + (try + (yield-from (yield-from-subgenerator-test)) + (catch [e AssertionError] + (yield 4)))) + (assert (= (list (yield-from-test)) [0 1 2 1 2 3 4]))) + (defn test-botsbuildbots [] (assert (> (len (first (Botsbuildbots))) 50)))