Skip to content

Commit

Permalink
Re-format and re-run all acceptance tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Jan 20, 2024
1 parent 9ee2d58 commit b50e4ab
Show file tree
Hide file tree
Showing 77 changed files with 462 additions and 843 deletions.
6 changes: 2 additions & 4 deletions examples/acceptance_tests/001/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub fn length(xs: List<a>) -> Int {
when xs is {
[] ->
0
[_, ..rest] ->
1 + length(rest)
[] -> 0
[_, ..rest] -> 1 + length(rest)
}
}

Expand Down
6 changes: 2 additions & 4 deletions examples/acceptance_tests/003/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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))
[] -> zero
[x, ..rest] -> f(x, foldr(rest, f, zero))
}
}

Expand Down
6 changes: 2 additions & 4 deletions examples/acceptance_tests/004/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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))
[] -> zero
[x, ..rest] -> f(x, foldr(rest, f, zero))
}
}

Expand Down
1 change: 0 additions & 1 deletion examples/acceptance_tests/006/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ test bar() {
False
}
}

3 changes: 2 additions & 1 deletion examples/acceptance_tests/007/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ pub fn unzip(xs: List<(a, b)>) -> (List<a>, List<b>) {
}

test unzip1() {
let x = [(3, #"55"), (4, #"7799")]
let x =
[(3, #"55"), (4, #"7799")]

unzip(x) == ([3, 4], [#"55", #"7799"])
}
6 changes: 2 additions & 4 deletions examples/acceptance_tests/010/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub fn map(opt: Option<a>, f: fn(a) -> b) -> Option<b> {
when opt is {
None ->
None
Some(a) ->
Some(f(a))
None -> None
Some(a) -> Some(f(a))
}
}

Expand Down
6 changes: 2 additions & 4 deletions examples/acceptance_tests/013/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
pub fn unzip(xs: List<(a, b)>) -> (List<a>, List<b>) {
when xs is {
[] ->
([], [])
[] -> ([], [])
[(a, b), ..rest] -> {
let (a_tail, b_tail) =
unzip(rest)
let (a_tail, b_tail) = unzip(rest)
([a, ..a_tail], [b, ..b_tail])
}
}
Expand Down
3 changes: 1 addition & 2 deletions examples/acceptance_tests/016/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn drop(bytes: ByteArray, n: Int) -> ByteArray {
}

test drop_1() {
let x =
#"01020304050607"
let x = #"01020304050607"
drop(x, 2) == #"0304050607"
}
6 changes: 2 additions & 4 deletions examples/acceptance_tests/018/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub fn or_else(opt: Option<a>, default: a) -> a {
when opt is {
None ->
default
Some(a) ->
a
None -> default
Some(a) -> a
}
}

Expand Down
6 changes: 2 additions & 4 deletions examples/acceptance_tests/019/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub fn map(opt: Option<a>, f: fn(a) -> result) -> Option<result> {
when opt is {
None ->
None
Some(a) ->
Some(f(a))
None -> None
Some(a) -> Some(f(a))
}
}

Expand Down
6 changes: 2 additions & 4 deletions examples/acceptance_tests/020/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub fn map(opt: Option<a>, f: fn(a) -> result) -> Option<result> {
when opt is {
None ->
None
Some(a) ->
Some(f(a))
None -> None
Some(a) -> Some(f(a))
}
}

Expand Down
9 changes: 3 additions & 6 deletions examples/acceptance_tests/022/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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))
[] -> zero
[x, ..rest] -> f(x, foldr(rest, f, zero))
}
}

Expand All @@ -12,8 +10,7 @@ pub fn filter_map(xs: List<a>, f: fn(a) -> Option<b>) -> List<b> {
xs,
fn(x, ys) {
when f(x) is {
None ->
ys
None -> ys
Some(y) ->
[y, ..ys]
}
Expand Down
9 changes: 3 additions & 6 deletions examples/acceptance_tests/024/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ pub fn map2(
f: fn(a, b) -> result,
) -> Option<result> {
when opt_a is {
None ->
None
None -> None
Some(a) ->
when opt_b is {
None ->
None
Some(b) ->
Some(f(a, b))
None -> None
Some(b) -> Some(f(a, b))
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions examples/acceptance_tests/026/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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))
[] -> zero
[x, ..rest] -> f(x, foldr(rest, f, zero))
}
}

Expand All @@ -15,8 +13,7 @@ pub fn flat_map(xs: List<a>, f: fn(a) -> List<b>) -> List<b> {
when xs is {
[] ->
[]
[x, ..rest] ->
concat(f(x), flat_map(rest, f))
[x, ..rest] -> concat(f(x), flat_map(rest, f))
}
}

Expand Down
9 changes: 3 additions & 6 deletions examples/acceptance_tests/029/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ fn do_from_list(xs: List<(key, value)>) -> List<(key, value)> {
when xs is {
[] ->
[]
[(k, v), ..rest] ->
do_insert(do_from_list(rest), k, v)
[(k, v), ..rest] -> do_insert(do_from_list(rest), k, v)
}
}

Expand Down Expand Up @@ -52,10 +51,8 @@ fn do_union(
right: List<(key, value)>,
) -> List<(key, value)> {
when left is {
[] ->
right
[(k, v), ..rest] ->
do_union(rest, do_insert(right, k, v))
[] -> right
[(k, v), ..rest] -> do_union(rest, do_insert(right, k, v))
}
}

Expand Down
3 changes: 1 addition & 2 deletions examples/acceptance_tests/033/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test tuple_1() {
let coordinates =
(14, 42)
let coordinates = (14, 42)
coordinates.1st == 14 && coordinates.2nd == 42
}
6 changes: 2 additions & 4 deletions examples/acceptance_tests/034/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub fn foldr(self: List<a>, with: fn(a, b) -> b, zero: b) -> b {
when self is {
[] ->
zero
[x, ..xs] ->
with(x, foldr(xs, with, zero))
[] -> zero
[x, ..xs] -> with(x, foldr(xs, with, zero))
}
}

Expand Down
6 changes: 2 additions & 4 deletions examples/acceptance_tests/035/lib/aiken/dict.ak
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ fn do_union_with(
with: fn(ByteArray, value, value) -> Option<value>,
) -> List<(ByteArray, value)> {
when left is {
[] ->
right
[] -> right
[(k, v), ..rest] ->
do_union_with(rest, do_insert_with(right, k, v, with), with)
}
Expand All @@ -58,8 +57,7 @@ fn do_insert_with(
when with(k, v, v2) is {
Some(combined) ->
[(k, combined), ..rest]
None ->
rest
None -> rest
}
} else {
[(k2, v2), ..do_insert_with(rest, k, v, with)]
Expand Down
15 changes: 5 additions & 10 deletions examples/acceptance_tests/035/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
a0,
a1,
fn(_, q0, q1) {
let q =
q0 + q1
let q = q0 + q1
if q == 0 {
None
} else {
Expand All @@ -46,19 +45,15 @@ pub fn add(left v0: Value, right v1: Value) -> Value {
)

when dict.toList(asset) is {
[] ->
None
_ ->
Some(asset)
[] -> None
_ -> Some(asset)
}
},
)
}

test add_1() {
let v1 =
from_lovelace(1)
let v2 =
from_lovelace(-1)
let v1 = from_lovelace(1)
let v2 = from_lovelace(-1)
add(v1, v2) == dict.new()
}
2 changes: 1 addition & 1 deletion examples/acceptance_tests/036/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705181051, nanos_since_epoch = 270212000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1705743641, nanos_since_epoch = 8357000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]
2 changes: 1 addition & 1 deletion examples/acceptance_tests/036/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.21-alpha+0161cf6"
"version": "v1.0.21-alpha+bf96c3a"
}
},
"validators": [
Expand Down
9 changes: 3 additions & 6 deletions examples/acceptance_tests/036/validators/spend.ak
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use aiken/list
use aiken/transaction.{Output, OutputReference, ScriptContext}
use aiken/transaction/value.{PolicyId}

const my_policy_id: PolicyId =
#"0000000000"
const my_policy_id: PolicyId = #"0000000000"

pub fn has_policy_id(self: Output, policy_id: PolicyId) -> Bool {
self.value
Expand All @@ -28,10 +27,8 @@ validator(output_reference: OutputReference) {
fn(input) { input.output_reference == output_reference },
)
is {
Some(_) ->
True
None ->
False
Some(_) -> True
None -> False
}
}
}
12 changes: 4 additions & 8 deletions examples/acceptance_tests/038/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub fn and_f(self: List<Bool>) -> Bool {
when self is {
[] ->
True
[x, ..xs] ->
x && and_f(xs)
[] -> True
[x, ..xs] -> x && and_f(xs)
}
}

Expand All @@ -13,10 +11,8 @@ test and_f_1() {

pub fn or_f(self: List<Bool>) -> Bool {
when self is {
[] ->
False
[x, ..xs] ->
x || or_f(xs)
[] -> False
[x, ..xs] -> x || or_f(xs)
}
}

Expand Down
18 changes: 6 additions & 12 deletions examples/acceptance_tests/044/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
test foo_1() {
let a =
False
let a = False
when a is {
True ->
False
False ->
True
True -> False
False -> True
}
}

test foo_2() {
let a =
False
let a = False
let b =
when a is {
True ->
14
False ->
42
True -> 14
False -> 42
}
b == 42
}
3 changes: 1 addition & 2 deletions examples/acceptance_tests/045/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fn fibonnaci(n) {
test foo() {
let right =
fn() { fibonnaci(15) == 610 }
let left =
False
let left = False
left || right()
}
12 changes: 4 additions & 8 deletions examples/acceptance_tests/046/lib/tests.ak
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ test sort_by_1() {
let xs =
[[4, 3, 2, 1], [2, 3, 4, 5]]
when xs is {
[[], ys] ->
False
[xs, []] ->
False
[[x, ..xs2], [y, ..ys2]] ->
True
_ ->
False
[[], ys] -> False
[xs, []] -> False
[[x, ..xs2], [y, ..ys2]] -> True
_ -> False
}
}
Loading

0 comments on commit b50e4ab

Please sign in to comment.