rename examples/tests/{a,b,c,d,e,f} into examples/acceptance_tests/00{1,2,3,4,5,6}
Also added a little Makefile to run them all in one go.
This commit is contained in:
2
examples/acceptance_tests/001/aiken.toml
Normal file
2
examples/acceptance_tests/001/aiken.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
name = "acceptance_test_001"
|
||||
version = "0.0.0"
|
||||
14
examples/acceptance_tests/001/lib/test.ak
Normal file
14
examples/acceptance_tests/001/lib/test.ak
Normal file
@@ -0,0 +1,14 @@
|
||||
pub fn length(xs: List<a>) -> Int {
|
||||
when xs is {
|
||||
[] -> 0
|
||||
[_, ..rest] -> 1 + length(rest)
|
||||
}
|
||||
}
|
||||
|
||||
test length_1() {
|
||||
length([1, 2, 3]) == 3
|
||||
}
|
||||
|
||||
test length_2() {
|
||||
length([]) == 0
|
||||
}
|
||||
2
examples/acceptance_tests/002/aiken.toml
Normal file
2
examples/acceptance_tests/002/aiken.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
name = "acceptance_test_002"
|
||||
version = "0.0.0"
|
||||
11
examples/acceptance_tests/002/lib/test.ak
Normal file
11
examples/acceptance_tests/002/lib/test.ak
Normal file
@@ -0,0 +1,11 @@
|
||||
pub fn repeat(x: a, n: Int) -> List<a> {
|
||||
if n <= 0 {
|
||||
[]
|
||||
} else {
|
||||
[x, ..repeat(x, n - 1)]
|
||||
}
|
||||
}
|
||||
|
||||
test repeat_1() {
|
||||
repeat("aiken", 2) == ["aiken", "aiken"]
|
||||
}
|
||||
2
examples/acceptance_tests/003/aiken.toml
Normal file
2
examples/acceptance_tests/003/aiken.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
name = "acceptance_test_003"
|
||||
version = "0.0.0"
|
||||
14
examples/acceptance_tests/003/lib/test.ak
Normal file
14
examples/acceptance_tests/003/lib/test.ak
Normal file
@@ -0,0 +1,14 @@
|
||||
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
|
||||
when xs is {
|
||||
[] -> zero
|
||||
[x, ..rest] -> f(x, foldr(rest, f, zero))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn concat(left: List<a>, right: List<a>) -> List<a> {
|
||||
foldr(left, fn(x, xs) { [x, ..xs] }, right)
|
||||
}
|
||||
|
||||
test concat_1() {
|
||||
concat([1, 2, 3], [4, 5, 6]) == [1, 2, 3, 4, 5, 6]
|
||||
}
|
||||
2
examples/acceptance_tests/004/aiken.toml
Normal file
2
examples/acceptance_tests/004/aiken.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
name = "acceptance_test_004"
|
||||
version = "0.0.0"
|
||||
18
examples/acceptance_tests/004/lib/test.ak
Normal file
18
examples/acceptance_tests/004/lib/test.ak
Normal file
@@ -0,0 +1,18 @@
|
||||
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
|
||||
when xs is {
|
||||
[] -> zero
|
||||
[x, ..rest] -> f(x, foldr(rest, f, zero))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prepend(x: a, xs: List<a>) -> List<a> {
|
||||
[x, ..xs]
|
||||
}
|
||||
|
||||
pub fn concat(left: List<a>, right: List<a>) -> List<a> {
|
||||
foldr(left, prepend, right)
|
||||
}
|
||||
|
||||
test concat_1() {
|
||||
concat([1, 2, 3], [4, 5, 6]) == [1, 2, 3, 4, 5, 6]
|
||||
}
|
||||
2
examples/acceptance_tests/005/aiken.toml
Normal file
2
examples/acceptance_tests/005/aiken.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
name = "acceptance_test_005"
|
||||
version = "0.0.0"
|
||||
16
examples/acceptance_tests/005/lib/test.ak
Normal file
16
examples/acceptance_tests/005/lib/test.ak
Normal file
@@ -0,0 +1,16 @@
|
||||
use aiken/builtin.{head_list}
|
||||
|
||||
pub fn head(xs: List<a>) -> Option<a> {
|
||||
when xs is {
|
||||
[] -> None
|
||||
_ -> Some(head_list(xs))
|
||||
}
|
||||
}
|
||||
|
||||
test head_1() {
|
||||
head([1, 2, 3]) == Some(1)
|
||||
}
|
||||
|
||||
test head_2() {
|
||||
head([]) == None
|
||||
}
|
||||
2
examples/acceptance_tests/006/aiken.toml
Normal file
2
examples/acceptance_tests/006/aiken.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
name = "acceptance_test_006"
|
||||
version = "0.0.0"
|
||||
3
examples/acceptance_tests/006/lib/test.ak
Normal file
3
examples/acceptance_tests/006/lib/test.ak
Normal file
@@ -0,0 +1,3 @@
|
||||
test foo() {
|
||||
(1, []) == (1, [])
|
||||
}
|
||||
5
examples/acceptance_tests/Makefile
Normal file
5
examples/acceptance_tests/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
all:
|
||||
@for t in $(shell find . -regex ".*[0-9]\{3\}" -type d | sort); do \
|
||||
aiken check -d $${t}; \
|
||||
echo ""; \
|
||||
done
|
||||
Reference in New Issue
Block a user