From 9a62bf9e2b23168f35cefdd558bfc61f554458e2 Mon Sep 17 00:00:00 2001 From: Paul Chiusano Date: Mon, 25 Mar 2019 14:13:01 -0400 Subject: [PATCH] add pending test for runtime error --- unison-src/tests/runtime-crash.uu | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 unison-src/tests/runtime-crash.uu diff --git a/unison-src/tests/runtime-crash.uu b/unison-src/tests/runtime-crash.uu new file mode 100644 index 000000000..c2f4b42ca --- /dev/null +++ b/unison-src/tests/runtime-crash.uu @@ -0,0 +1,28 @@ + +use Optional None Some + +namespace Sequence where + + iterateWhile : (a -> Boolean) -> (a -> a) -> a -> [a] + iterateWhile p f a = + unfold a (a -> if p a then Some (a, f a) else None) + + unfold : s -> (s -> Optional (a, s)) -> [a] + unfold s f = + go acc s f = case f s of + None -> acc + Some (a,s) -> go (acc `snoc` a) s f + go [] s f + +sliding : Nat -> Text -> [Text] +sliding k t = + use Nat.>= + iterateWhile (t -> Text.size t >= k) (Text.drop 1) t + +> sliding 2 "Unison" + +--- + +gives a runtime error - + +unison: user error (type error, expecting N, got True)