Skip to content

Fix prelude head-or` #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions harness/test/051_head_or.eu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"Tests for prelude `head-or`"

head-or-tests: {
α: [] head-or(:none) //= :none
β: [:x, :y, :z] head-or(null) //= :x
ɣ: { colours: [:r, :o, :y, :g, :b, :i, :v] }.{ val: head-or(:x, colours) = head(colours) }.val
δ: [null] head //= [] head-or(null)
}

RESULT: head-or-tests values all-true? then(:PASS, :FAIL)
2 changes: 1 addition & 1 deletion lib/prelude.eu
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ head: __HEAD
nil?: = []

` "`head-or(xs, d)` - return the head item of list `xs` or default `d` if empty."
head-or(d, xs): xs nil? then(xs head, d)
head-or(d, xs): xs nil? then(d, xs head)

` "`tail(xs)` - return list `xs` without the head item. [] causes error."
tail: __TAIL
Expand Down
5 changes: 5 additions & 0 deletions tests/harness_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,8 @@ pub fn test_harness_049() {
pub fn test_harness_050() {
run_test(&opts("050_edn.edn"));
}

#[test]
pub fn test_harness_051() {
run_test(&opts("051_head_or.eu"));
}