diff options
Diffstat (limited to 'src/List.gleam')
-rw-r--r-- | src/List.gleam | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/List.gleam b/src/List.gleam index acd349c..f249234 100644 --- a/src/List.gleam +++ b/src/List.gleam @@ -10,10 +10,10 @@ pub type Err = pub external fn length(List(a)) { Int } = 'erlang' 'length' test length { - length([]) |> Assert.equal(_, 0) - length([1]) |> Assert.equal(_, 1) - length([1, 1]) |> Assert.equal(_, 2) - length([1, 1, 1]) |> Assert.equal(_, 3) + length([]) |> Assert:equal(_, 0) + length([1]) |> Assert:equal(_, 1) + length([1, 1]) |> Assert:equal(_, 2) + length([1, 1, 1]) |> Assert:equal(_, 3) } // Using the Erlang C BIF implementation. @@ -21,8 +21,8 @@ test length { pub external fn reverse(List(a)) { List(a) } = 'erlang' 'reverse' test reverse { - length([]) |> Assert.equal(_, []) - length([1, 2, 3, 4, 5]) |> Assert.equal(_, [5, 4, 3, 2, 1]) + length([]) |> Assert:equal(_, []) + length([1, 2, 3, 4, 5]) |> Assert:equal(_, [5, 4, 3, 2, 1]) } pub fn is_empty(list) { @@ -30,8 +30,8 @@ pub fn is_empty(list) { } test is_empty { - is_empty([]) |> Assert.true - is_empty([1]) |> Assert.false + is_empty([]) |> Assert:true + is_empty([1]) |> Assert:false } pub fn member(list, elem) { @@ -43,9 +43,9 @@ pub fn member(list, elem) { } test is_member { - is_member([0, 4, 5, 1], 1) |> Assert.true - is_member([0, 4, 5, 7], 1) |> Assert.false - is_member([], 1) |> Assert.false + is_member([0, 4, 5, 1], 1) |> Assert:true + is_member([0, 4, 5, 7], 1) |> Assert:false + is_member([], 1) |> Assert:false } pub fn head(list) { @@ -57,10 +57,10 @@ pub fn head(list) { test head { head([0, 4, 5, 7]) - |> Assert.equal(_, Ok(0)) + |> Assert:equal(_, Ok(0)) head([]) - |> Assert.equal(_, Error(Err:Empty)) + |> Assert:equal(_, Error(Err:Empty)) } pub fn tail(list) { @@ -72,13 +72,13 @@ pub fn tail(list) { test tail { tail([0, 4, 5, 7]) - |> Assert.equal(_, Ok([4, 5, 7])) + |> Assert:equal(_, Ok([4, 5, 7])) tail([0]) - |> Assert.equal(_, Ok([])) + |> Assert:equal(_, Ok([])) tail([]) - |> Assert.equal(_, Error(Err:Empty)) + |> Assert:equal(_, Error(Err:Empty)) } pub fn filter(list, fun) { @@ -88,19 +88,19 @@ pub fn filter(list, fun) { test filter { [] |> filter(_, fn(x) { True }) - |> Assert.equal(_, []) + |> Assert:equal(_, []) [0, 4, 5, 7, 3] |> filter(_, fn(x) { True }) - |> Assert.equal(_, [0, 4, 5, 7, 3]) + |> Assert:equal(_, [0, 4, 5, 7, 3]) [0, 4, 5, 7, 3] |> filter(_, fn(x) { x > 4 }) - |> Assert.equal(_, [5, 7]) + |> Assert:equal(_, [5, 7]) [0, 4, 5, 7, 3] |> filter(_, fn(x) { x < 4 }) - |> Assert.equal(_, [0, 3]) + |> Assert:equal(_, [0, 3]) } fn do_filter(list, fun, acc) { @@ -123,11 +123,11 @@ pub fn map(list, fun) { test map { [] |> map(_, fn(x) { x * 2 }) - |> Assert.equal(_, []) + |> Assert:equal(_, []) [0, 4, 5, 7, 3] |> map(_, fn(x) { x * 2 }) - |> Assert.equal(_, [0, 8, 10, 14, 6]) + |> Assert:equal(_, [0, 8, 10, 14, 6]) } fn do_map(list, fun, acc) { @@ -151,11 +151,11 @@ pub fn drop(list, n) { test drop/2 { [] |> drop(_, 5) - |> Assert.equal(_, []) + |> Assert:equal(_, []) [1, 2, 3, 4, 5, 6, 7, 8] |> drop(_, 5) - |> Assert.equal(_, [6, 7, 8]) + |> Assert:equal(_, [6, 7, 8]) } pub fn take(list, n) { @@ -176,10 +176,10 @@ fn do_take(list, n, acc) { test take { [] |> take(_, 5) - |> Assert.equal(_, []) + |> Assert:equal(_, []) [1, 2, 3, 4, 5, 6, 7, 8] |> take(_, 5) - |> Assert.equal(_, [1, 2, 3, 4, 5]) + |> Assert:equal(_, [1, 2, 3, 4, 5]) } pub fn of(x) { @@ -187,8 +187,8 @@ pub fn of(x) { } test of() { - of([]) |> Assert.equal(_, [[]]) - of(1) |> Assert.equal(_, [1]) + of([]) |> Assert:equal(_, [[]]) + of(1) |> Assert:equal(_, [1]) } pub fn new() { @@ -196,7 +196,7 @@ pub fn new() { } test new() { - new() |> Assert.equal(_, []) + new() |> Assert:equal(_, []) } pub fn flatten(lists) { @@ -205,16 +205,16 @@ pub fn flatten(lists) { test flatten() { flatten([]) - |> Assert.equal(_, []) + |> Assert:equal(_, []) flatten([[]]) - |> Assert.equal(_, []) + |> Assert:equal(_, []) flatten([[], [], []]) - |> Assert.equal(_, []) + |> Assert:equal(_, []) flatten([[1, 2], [], [3, 4]]) - |> Assert.equal(_, [1, 2, 3, 4]) + |> Assert:equal(_, [1, 2, 3, 4]) } fn do_flatten(lists, acc) { @@ -234,7 +234,7 @@ pub fn foldl(list, acc, fun) { test foldl() { [1, 2, 3] |> foldl(_, [], fn(x, acc) { x :: acc }) - |> Assert.equal(_, [3, 2, 1]) + |> Assert:equal(_, [3, 2, 1]) } pub fn foldr(list, acc, fun) { @@ -247,5 +247,5 @@ pub fn foldr(list, acc, fun) { test foldr() { [1, 2, 3] |> foldr(_, [], fn(x, acc) { x :: acc }) - |> Assert.equal(_, [1, 2, 3]) + |> Assert:equal(_, [1, 2, 3]) } |