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:
KtorZ
2022-12-13 14:09:17 +01:00
parent b294063097
commit a62fb1905e
20 changed files with 25 additions and 16 deletions

View File

@@ -0,0 +1,2 @@
name = "acceptance_test_001"
version = "0.0.0"

View 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
}

View File

@@ -0,0 +1,2 @@
name = "acceptance_test_002"
version = "0.0.0"

View 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"]
}

View File

@@ -0,0 +1,2 @@
name = "acceptance_test_003"
version = "0.0.0"

View 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]
}

View File

@@ -0,0 +1,2 @@
name = "acceptance_test_004"
version = "0.0.0"

View 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]
}

View File

@@ -0,0 +1,2 @@
name = "acceptance_test_005"
version = "0.0.0"

View 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
}

View File

@@ -0,0 +1,2 @@
name = "acceptance_test_006"
version = "0.0.0"

View File

@@ -0,0 +1,3 @@
test foo() {
(1, []) == (1, [])
}

View 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