Add tests for zero arg cyclic functions and renamed function aliases

This commit is contained in:
microproofs
2024-03-09 13:23:27 -05:00
parent 22b86a5f82
commit c7dcb2c256
4 changed files with 105 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
use aiken/list.{count as my_count} as native_list
test thing_1() {
let x =
[1, 2, 3, 4, 5, 5]
my_count(x, fn(item) { item > 0 }) == 6
}
test thing_2() {
let x =
[1, 2, 3, 4, 5, 5]
native_list.count(x, fn(item) { item > 0 }) == 6
}
test thing_3() {
let x =
[1, 2, 3, 4, 5, 5]
let my_countx = my_count
my_countx(x, fn(item) { item > 0 }) == 6
}
test thing_4() {
let x =
[1, 2, 3, 4, 5, 5]
let my_countx = native_list.count
my_countx(x, fn(item) { item > 0 }) == 6
}

View File

@@ -0,0 +1,43 @@
fn countdown_1() {
fn(x) {
if x > 4 {
countdown_3()
} else {
x - countdown_2()
}
}
}
fn countdown_2() {
countdown_1()(5)
}
fn countdown_3() {
3
}
fn countdown_4() {
fn(x) {
if x > 4 {
countdown_6()
} else {
x - countdown_5(x + 1)
}
}
}
fn countdown_5(x: Int) {
countdown_4()(x)
}
fn countdown_6() {
3
}
test cycle_zero_arg_1() {
countdown_1()(3) == 0
}
test cycle_zero_arg_2() {
countdown_4()(3) == 2
}