From 0663d7fa100945f2c0bb52273eeb1370893b43dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 16 Feb 2018 18:27:02 +0100 Subject: [PATCH] Use shared tests repository instead of `src/tests` --- .gitmodules | 4 +- src/tests | 1 + src/tests/.gitignore | 4 -- src/tests/bool.exp | 20 -------- src/tests/bool.lambda | 88 --------------------------------- src/tests/church.exp | 1 - src/tests/church.lambda | 16 ------ src/tests/hello.exp | 1 - src/tests/hello.lambda | 1 - src/tests/if_fib.exp | 1 - src/tests/if_fib.lambda | 1 - src/tests/if_func.exp | 2 - src/tests/if_func.lambda | 26 ---------- src/tests/if_func_branch.exp | 2 - src/tests/if_func_branch.lambda | 8 --- src/tests/if_nested.exp | 1 - src/tests/if_nested.lambda | 1 - src/tests/loop/loop.lambda | 10 ---- src/tests/multi_args.exp | 1 - src/tests/multi_args.lambda | 2 - src/tests/multi_args_rec.exp | 10 ---- src/tests/multi_args_rec.lambda | 8 --- src/tests/partial_eval.exp | 2 - src/tests/partial_eval.lambda | 5 -- src/tests/printprint.exp | 2 - src/tests/printprint.lambda | 2 - src/tests/rec_factorial.exp | 1 - src/tests/rec_factorial.lambda | 9 ---- src/tests/rec_fibo.exp | 9 ---- src/tests/rec_fibo.lambda | 25 ---------- src/tests/redef.exp | 1 - src/tests/redef.lambda | 6 --- src/tests/ren.exp | 1 - src/tests/ren.lambda | 1 - src/tests/simple_call.exp | 1 - src/tests/simple_call.lambda | 2 - src/tests/simple_if.exp | 1 - src/tests/simple_if.lambda | 1 - src/tests_shared | 1 - 39 files changed, 3 insertions(+), 276 deletions(-) create mode 160000 src/tests delete mode 100644 src/tests/.gitignore delete mode 100644 src/tests/bool.exp delete mode 100644 src/tests/bool.lambda delete mode 100644 src/tests/church.exp delete mode 100644 src/tests/church.lambda delete mode 100644 src/tests/hello.exp delete mode 100644 src/tests/hello.lambda delete mode 120000 src/tests/if_fib.exp delete mode 120000 src/tests/if_fib.lambda delete mode 100644 src/tests/if_func.exp delete mode 100644 src/tests/if_func.lambda delete mode 100644 src/tests/if_func_branch.exp delete mode 100644 src/tests/if_func_branch.lambda delete mode 120000 src/tests/if_nested.exp delete mode 120000 src/tests/if_nested.lambda delete mode 100644 src/tests/loop/loop.lambda delete mode 100644 src/tests/multi_args.exp delete mode 100644 src/tests/multi_args.lambda delete mode 100644 src/tests/multi_args_rec.exp delete mode 100644 src/tests/multi_args_rec.lambda delete mode 100644 src/tests/partial_eval.exp delete mode 100644 src/tests/partial_eval.lambda delete mode 100644 src/tests/printprint.exp delete mode 100644 src/tests/printprint.lambda delete mode 100644 src/tests/rec_factorial.exp delete mode 100644 src/tests/rec_factorial.lambda delete mode 100644 src/tests/rec_fibo.exp delete mode 100644 src/tests/rec_fibo.lambda delete mode 100644 src/tests/redef.exp delete mode 100644 src/tests/redef.lambda delete mode 120000 src/tests/ren.exp delete mode 120000 src/tests/ren.lambda delete mode 100644 src/tests/simple_call.exp delete mode 100644 src/tests/simple_call.lambda delete mode 100644 src/tests/simple_if.exp delete mode 100644 src/tests/simple_if.lambda delete mode 160000 src/tests_shared diff --git a/.gitmodules b/.gitmodules index 862af46..bb6fac0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "src/tests_shared"] - path = src/tests_shared +[submodule "src/tests"] + path = src/tests url = git@github.com:tobast/mpri18-funcprog-tests.git diff --git a/src/tests b/src/tests new file mode 160000 index 0000000..99e0225 --- /dev/null +++ b/src/tests @@ -0,0 +1 @@ +Subproject commit 99e02259731e34422067235879d9f4698490466b diff --git a/src/tests/.gitignore b/src/tests/.gitignore deleted file mode 100644 index 9038d29..0000000 --- a/src/tests/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.err -*.out -*.exe -*.c diff --git a/src/tests/bool.exp b/src/tests/bool.exp deleted file mode 100644 index 829400e..0000000 --- a/src/tests/bool.exp +++ /dev/null @@ -1,20 +0,0 @@ -1 -0 -1 -0 -0 -24 -120 -8 -13 -5 -0 -1 -7 -1 -1 -2 -6 -24 -120 -42 diff --git a/src/tests/bool.lambda b/src/tests/bool.lambda deleted file mode 100644 index 6eaf5da..0000000 --- a/src/tests/bool.lambda +++ /dev/null @@ -1,88 +0,0 @@ -(* Thunks. *) -let force = fun x -> x 0 in -(* Church Booleans. *) -let false = fun x -> fun y -> y in -let true = fun x -> fun y -> x in -let k = true in -let cond = fun p -> fun x -> fun y -> p x y in -let forcecond = fun p -> fun x -> fun y -> force (p x y) in -let bool2int = fun b -> cond b 1 0 in -let _ = print (bool2int true) in -let _ = print (bool2int false) in -(* Church pairs. *) -let pair = fun x -> fun y -> fun p -> cond p x y in -let fst = fun p -> p true in -let snd = fun p -> p false in -(* Church naturals. *) -let zero = fun f -> fun x -> x in -let one = fun f -> fun x -> f x in -let plus = fun m -> fun n -> fun f -> fun x -> m f (n f x) in -let two = plus one one in -let three = plus one two in -let four = plus two two in -let five = plus four one in -let six = plus four two in -let succ = plus one in -let mult = fun m -> fun n -> fun f -> m (n f) in -let exp = fun m -> fun n -> n m in -let is_zero = fun n -> n (k false) true in -let convert = fun n -> n (fun x -> x + 1) 0 in -let _ = print (bool2int (is_zero zero)) in -let _ = print (bool2int (is_zero one)) in -let _ = print (bool2int (is_zero two)) in -(* Factorial, based on Church naturals. *) -let loop = fun p -> - let n = succ (fst p) in - pair n (mult n (snd p)) -in -let fact = fun n -> - snd (n loop (pair zero one)) -in -let _ = print (convert (fact four)) in -let _ = print (convert (fact five)) in -(* Fibonacci, based on Church naturals. *) -let loop = fun p -> - let fib1 = fst p in - pair (plus fib1 (snd p)) fib1 -in -let fib = fun n -> - snd (n loop (pair one one)) -in -let _ = print (convert (fib five)) in -let _ = print (convert (fib six)) in -(* Predecessor. *) -let loop = fun p -> - let pred = fst p in - pair (succ pred) pred -in -let pred = fun n -> - snd (n loop (pair zero zero)) -in -let _ = print (convert (pred six)) in -(* Comparison, yielding a Church Boolean. *) -let geq = fun m -> fun n -> - m pred n (k false) true -in -let _ = print (bool2int (geq four six)) in -let _ = print (bool2int (geq six one)) in -(* Iteration. *) -let iter = fun f -> fun n -> - n f (f one) -in -(* Ackermann's function. *) -let ack = fun n -> n iter succ n in -let _ = print (convert (ack two)) in -(* A fixpoint. *) -let fix = fun f -> (fun y -> f (fun z -> y y z)) (fun y -> f (fun z -> y y z)) in -(* Another version of fact. *) -let fact = fun n -> - fix (fun fact -> fun n -> forcecond (is_zero n) (fun _ -> one) (fun _ -> mult n (fact (pred n)))) n -in -let _ = print (convert (fact zero)) in -let _ = print (convert (fact one)) in -let _ = print (convert (fact two)) in -let _ = print (convert (fact three)) in -let _ = print (convert (fact four)) in -let _ = print (convert (fact five)) in - -print 42 diff --git a/src/tests/church.exp b/src/tests/church.exp deleted file mode 100644 index d81cc07..0000000 --- a/src/tests/church.exp +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/src/tests/church.lambda b/src/tests/church.lambda deleted file mode 100644 index 0cbd2e6..0000000 --- a/src/tests/church.lambda +++ /dev/null @@ -1,16 +0,0 @@ -let i = fun x -> x in -let k = fun x -> fun y -> x in -let zero = fun f -> i in -let one = fun f -> fun x -> f x in -let plus = fun m -> fun n -> fun f -> fun x -> m f (n f x) in -let succ = plus one in -let mult = fun m -> fun n -> fun f -> m (n f) in -let exp = fun m -> fun n -> n m in -let two = succ one in -let three = succ two in -let six = mult two three in -let seven = succ six in -let twenty_one = mult three seven in -let forty_two = mult two twenty_one in -let convert = fun n -> n (fun x -> x + 1) 0 in -print (convert forty_two) diff --git a/src/tests/hello.exp b/src/tests/hello.exp deleted file mode 100644 index d81cc07..0000000 --- a/src/tests/hello.exp +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/src/tests/hello.lambda b/src/tests/hello.lambda deleted file mode 100644 index 86f387e..0000000 --- a/src/tests/hello.lambda +++ /dev/null @@ -1 +0,0 @@ -print (21 + 21) diff --git a/src/tests/if_fib.exp b/src/tests/if_fib.exp deleted file mode 120000 index 9132c0e..0000000 --- a/src/tests/if_fib.exp +++ /dev/null @@ -1 +0,0 @@ -../tests_shared/if_fib.exp \ No newline at end of file diff --git a/src/tests/if_fib.lambda b/src/tests/if_fib.lambda deleted file mode 120000 index 900ee14..0000000 --- a/src/tests/if_fib.lambda +++ /dev/null @@ -1 +0,0 @@ -../tests_shared/if_fib.lambda \ No newline at end of file diff --git a/src/tests/if_func.exp b/src/tests/if_func.exp deleted file mode 100644 index 6ed281c..0000000 --- a/src/tests/if_func.exp +++ /dev/null @@ -1,2 +0,0 @@ -1 -1 diff --git a/src/tests/if_func.lambda b/src/tests/if_func.lambda deleted file mode 100644 index c236fe8..0000000 --- a/src/tests/if_func.lambda +++ /dev/null @@ -1,26 +0,0 @@ -let i = fun x -> x in -let k = fun x -> fun y -> x in -let zero = fun f -> i in -let one = fun f -> fun x -> f x in -let plus = fun m -> fun n -> fun f -> fun x -> m f (n f x) in -let succ = plus one in -let mult = fun m -> fun n -> fun f -> m (n f) in -let exp = fun m -> fun n -> n m in -let two = succ one in -let three = succ two in -let six = mult two three in -let seven = succ six in -let twenty_one = mult three seven in -let forty_two = mult two twenty_one in -let convert = fun n -> n (fun x -> x + 1) 0 in - -let nothing = - ifzero convert forty_two then - print 0 - else - print 1 - in -ifzero convert zero then - print 1 -else - print 0 diff --git a/src/tests/if_func_branch.exp b/src/tests/if_func_branch.exp deleted file mode 100644 index 6ed281c..0000000 --- a/src/tests/if_func_branch.exp +++ /dev/null @@ -1,2 +0,0 @@ -1 -1 diff --git a/src/tests/if_func_branch.lambda b/src/tests/if_func_branch.lambda deleted file mode 100644 index da08ade..0000000 --- a/src/tests/if_func_branch.lambda +++ /dev/null @@ -1,8 +0,0 @@ -let succeed = fun x -> print 1 in -let fail = fun x -> print 0 in - -let true = fun x -> 0 in -let false = fun x -> 1 in - -let nothing = ifzero true 0 then succeed 0 else fail 0 in -ifzero false 0 then fail 0 else succeed 0 diff --git a/src/tests/if_nested.exp b/src/tests/if_nested.exp deleted file mode 120000 index 0a6c5c1..0000000 --- a/src/tests/if_nested.exp +++ /dev/null @@ -1 +0,0 @@ -../tests_shared/if_nested.exp \ No newline at end of file diff --git a/src/tests/if_nested.lambda b/src/tests/if_nested.lambda deleted file mode 120000 index ae63410..0000000 --- a/src/tests/if_nested.lambda +++ /dev/null @@ -1 +0,0 @@ -../tests_shared/if_nested.lambda \ No newline at end of file diff --git a/src/tests/loop/loop.lambda b/src/tests/loop/loop.lambda deleted file mode 100644 index 0629593..0000000 --- a/src/tests/loop/loop.lambda +++ /dev/null @@ -1,10 +0,0 @@ -(* This program is supposed to never terminate. - This can actually work if the C compiler is - smart enough to recognize and optimize tail - calls. It works for me with clang but not with - gcc, for some reason. *) -let rec loop = fun x -> - let _ = print x in - loop (x + 1) -in -loop 0 diff --git a/src/tests/multi_args.exp b/src/tests/multi_args.exp deleted file mode 100644 index d81cc07..0000000 --- a/src/tests/multi_args.exp +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/src/tests/multi_args.lambda b/src/tests/multi_args.lambda deleted file mode 100644 index 4f8e1c0..0000000 --- a/src/tests/multi_args.lambda +++ /dev/null @@ -1,2 +0,0 @@ -let sum = fun x -> fun y -> x + y in -print(sum 40 2) diff --git a/src/tests/multi_args_rec.exp b/src/tests/multi_args_rec.exp deleted file mode 100644 index 4521d57..0000000 --- a/src/tests/multi_args_rec.exp +++ /dev/null @@ -1,10 +0,0 @@ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 diff --git a/src/tests/multi_args_rec.lambda b/src/tests/multi_args_rec.lambda deleted file mode 100644 index e9170fc..0000000 --- a/src/tests/multi_args_rec.lambda +++ /dev/null @@ -1,8 +0,0 @@ -let rec print_n = fun cur -> fun n -> - ifzero n - cur then - 0 - else - let x = print 0 in - print_n (cur + 1) n - in -print_n 0 10 diff --git a/src/tests/partial_eval.exp b/src/tests/partial_eval.exp deleted file mode 100644 index daaac9e..0000000 --- a/src/tests/partial_eval.exp +++ /dev/null @@ -1,2 +0,0 @@ -42 -42 diff --git a/src/tests/partial_eval.lambda b/src/tests/partial_eval.lambda deleted file mode 100644 index b0a6157..0000000 --- a/src/tests/partial_eval.lambda +++ /dev/null @@ -1,5 +0,0 @@ -let sum = fun x -> fun y -> fun z -> x + y + z in -let plus2 = sum 1 1 in - -let _ = print (sum 30 10 2) in -print (plus2 40) diff --git a/src/tests/printprint.exp b/src/tests/printprint.exp deleted file mode 100644 index daaac9e..0000000 --- a/src/tests/printprint.exp +++ /dev/null @@ -1,2 +0,0 @@ -42 -42 diff --git a/src/tests/printprint.lambda b/src/tests/printprint.lambda deleted file mode 100644 index f0501dd..0000000 --- a/src/tests/printprint.lambda +++ /dev/null @@ -1,2 +0,0 @@ -(* Because [print] returns its argument, this program should print 42 twice. *) -print (print 42) diff --git a/src/tests/rec_factorial.exp b/src/tests/rec_factorial.exp deleted file mode 100644 index 89810b1..0000000 --- a/src/tests/rec_factorial.exp +++ /dev/null @@ -1 +0,0 @@ -5040 diff --git a/src/tests/rec_factorial.lambda b/src/tests/rec_factorial.lambda deleted file mode 100644 index b47bfc2..0000000 --- a/src/tests/rec_factorial.lambda +++ /dev/null @@ -1,9 +0,0 @@ -let rec fact = fun n -> - ifzero n then - 1 - else - let sub_val = fact (n - 1) in - n * sub_val - in - -print (fact 7) diff --git a/src/tests/rec_fibo.exp b/src/tests/rec_fibo.exp deleted file mode 100644 index ef44016..0000000 --- a/src/tests/rec_fibo.exp +++ /dev/null @@ -1,9 +0,0 @@ -1 -1 -2 -3 -5 -8 -13 -21 -34 diff --git a/src/tests/rec_fibo.lambda b/src/tests/rec_fibo.lambda deleted file mode 100644 index 7e2f5db..0000000 --- a/src/tests/rec_fibo.lambda +++ /dev/null @@ -1,25 +0,0 @@ -let fibo = fun n -> - let rec fibo_inner = fun i -> fun last -> fun last_last -> - ifzero (n - i) then - last + last_last - else - fibo_inner (i+1) (last + last_last) last - in - - ifzero n then - 1 - else ifzero (n - 1) then - 1 - else - fibo_inner 2 1 1 - in - -let x = print (fibo 0) in -let x = print (fibo 1) in -let x = print (fibo 2) in -let x = print (fibo 3) in -let x = print (fibo 4) in -let x = print (fibo 5) in -let x = print (fibo 6) in -let x = print (fibo 7) in -print (fibo 8) diff --git a/src/tests/redef.exp b/src/tests/redef.exp deleted file mode 100644 index d81cc07..0000000 --- a/src/tests/redef.exp +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/src/tests/redef.lambda b/src/tests/redef.lambda deleted file mode 100644 index 7d6f1f8..0000000 --- a/src/tests/redef.lambda +++ /dev/null @@ -1,6 +0,0 @@ -let increase = fun x -> x + 1 in -let increase = fun x -> - let lop = (increase x) in - lop + 1 in - -print (increase 40) diff --git a/src/tests/ren.exp b/src/tests/ren.exp deleted file mode 120000 index 4d869b5..0000000 --- a/src/tests/ren.exp +++ /dev/null @@ -1 +0,0 @@ -../tests_shared/ren.exp \ No newline at end of file diff --git a/src/tests/ren.lambda b/src/tests/ren.lambda deleted file mode 120000 index d7f1801..0000000 --- a/src/tests/ren.lambda +++ /dev/null @@ -1 +0,0 @@ -../tests_shared/ren.lambda \ No newline at end of file diff --git a/src/tests/simple_call.exp b/src/tests/simple_call.exp deleted file mode 100644 index d81cc07..0000000 --- a/src/tests/simple_call.exp +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/src/tests/simple_call.lambda b/src/tests/simple_call.lambda deleted file mode 100644 index c7060d9..0000000 --- a/src/tests/simple_call.lambda +++ /dev/null @@ -1,2 +0,0 @@ -let id = fun x -> x in -print (id 42) diff --git a/src/tests/simple_if.exp b/src/tests/simple_if.exp deleted file mode 100644 index d00491f..0000000 --- a/src/tests/simple_if.exp +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/src/tests/simple_if.lambda b/src/tests/simple_if.lambda deleted file mode 100644 index 3727bf9..0000000 --- a/src/tests/simple_if.lambda +++ /dev/null @@ -1 +0,0 @@ -ifzero 42 then print 0 else print 1 diff --git a/src/tests_shared b/src/tests_shared deleted file mode 160000 index ab75493..0000000 --- a/src/tests_shared +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ab7549347e5b6b51183c5704048c6768aab23d86