on master help sign in
Merge pull request #3935 from rbarreiro/add_regression_test_js_unexpected_con_as_glob

Add regression test js unexpected con as glob

commit0f8b4ca114791ccbe4c591bb2d085f49cacbf2b4 authorNiklas Larsson <metaniklas@gmail.com> dateSun 23 Jul 2017, 01:25 (9 years ago) parent7a6226a243e02f
4 files changed+63−1
test/TestData.hs+2−1 test/regression003/expected+1 test/regression003/regression003.idr+56 test/regression003/run+4
test/TestData.hs+2−1
@@ -258,7 +258,8 @@ testFamiliesData = [
258258 ( 77, ANY )]),
259259 ("regression", "Regression",
260260 [ ( 1 , ANY ),
261− ( 2 , ANY )]),
261+ ( 2 , ANY ),
262+ ( 3 , ANY )]),
262263 ("sourceLocation", "Source location",
263264 [ ( 1 , ANY )]),
264265 ("sugar", "Syntactic sugar",
test/regression003/expectednew file+1
@@ -0,0 +1 @@
1+ola
test/regression003/regression003.idrnew file+56
@@ -0,0 +1,56 @@
1+module Main
2+
3+data Free : (f : Type -> Type) -> (a : Type) -> Type where
4+ Pure : a -> Free f a
5+ Bind : f (Free f a) -> Free f a
6+
7+Functor f => Functor (Free f) where
8+ map f m = assert_total $ case m of
9+ Pure x => Pure (f x)
10+ Bind x => Bind (map (map f) x)
11+
12+Functor f => Applicative (Free f) where
13+ pure = Pure
14+
15+ m <*> x = assert_total $ case m of
16+ Pure f => map f x
17+ Bind f => Bind (map (<*> x) f)
18+
19+Functor f => Monad (Free f) where
20+ m >>= f = assert_total $ case m of
21+ Pure x => f x
22+ Bind x => Bind (map (>>= f) x)
23+
24+liftFree : Functor f => f a -> Free f a
25+liftFree = assert_total $ Bind . map Pure
26+
27+foldFree : (Monad m, Functor f) => ({ a : Type } -> f a -> m a) -> Free f b -> m b
28+foldFree f m = assert_total $ case m of
29+ Pure x => pure x
30+ Bind x => f x >>= foldFree f
31+
32+data FileSystemF next
33+ = ReadFile (String -> next)
34+
35+FileSystem : Type -> Type
36+FileSystem = Free FileSystemF
37+
38+Functor FileSystemF where
39+ map f (ReadFile nextFn) = ReadFile (f . nextFn)
40+
41+readFileF : FileSystem String
42+readFileF = liftFree $ ReadFile id
43+
44+
45+
46+interpret2 : FileSystemF a -> IO a
47+interpret2 (ReadFile nextFn) = do
48+ contents <- pure "ola"
49+ pure (nextFn contents)
50+
51+main : IO ()
52+main =
53+ do
54+ c <- foldFree interpret2 readFileF
55+ putStrLn' c
56+
test/regression003/runnew file+4
@@ -0,0 +1,4 @@
1+#!/usr/bin/env bash
2+${IDRIS:-idris} $@ regression003.idr -o regression003
3+./regression003
4+rm -f regression003 *.ibc