diff options
28 files changed, 1 insertions, 2468 deletions
@@ -11,6 +11,7 @@ ebin log erl_crash.dump .rebar +gen logs _build .idea diff --git a/gen/src/gleam@atom.erl b/gen/src/gleam@atom.erl deleted file mode 100644 index 1150544..0000000 --- a/gen/src/gleam@atom.erl +++ /dev/null @@ -1,13 +0,0 @@ --module(gleam@atom). --compile(no_auto_import). - --export([from_string/1, create_from_string/1, to_string/1]). - -from_string(A) -> - gleam_stdlib:atom_from_string(A). - -create_from_string(A) -> - gleam_stdlib:atom_create_from_string(A). - -to_string(A) -> - gleam_stdlib:atom_to_string(A). diff --git a/gen/src/gleam@bool.erl b/gen/src/gleam@bool.erl deleted file mode 100644 index 6714261..0000000 --- a/gen/src/gleam@bool.erl +++ /dev/null @@ -1,55 +0,0 @@ --module(gleam@bool). --compile(no_auto_import). - --export([negate/1, compare/2, max/2, min/2, to_int/1]). - -negate(Bool) -> - case Bool of - true -> - false; - - false -> - true - end. - -compare(A, B) -> - case {A, B} of - {true, true} -> - eq; - - {true, false} -> - gt; - - {false, false} -> - eq; - - {false, true} -> - lt - end. - -max(A, B) -> - case A of - true -> - true; - - false -> - B - end. - -min(A, B) -> - case A of - false -> - false; - - true -> - B - end. - -to_int(Bool) -> - case Bool of - false -> - 0; - - true -> - 1 - end. diff --git a/gen/src/gleam@dynamic.erl b/gen/src/gleam@dynamic.erl deleted file mode 100644 index d467820..0000000 --- a/gen/src/gleam@dynamic.erl +++ /dev/null @@ -1,45 +0,0 @@ --module(gleam@dynamic). --compile(no_auto_import). - --export([from/1, unsafe_coerce/1, string/1, int/1, float/1, atom/1, bool/1, thunk/1, list/2, field/2, element/2]). - -from(A) -> - gleam_stdlib:identity(A). - -unsafe_coerce(A) -> - gleam_stdlib:identity(A). - -string(A) -> - gleam_stdlib:decode_string(A). - -int(A) -> - gleam_stdlib:decode_int(A). - -float(A) -> - gleam_stdlib:decode_float(A). - -atom(A) -> - gleam_stdlib:decode_atom(A). - -bool(A) -> - gleam_stdlib:decode_bool(A). - -thunk(A) -> - gleam_stdlib:decode_thunk(A). - -list_dynamic(A) -> - gleam_stdlib:decode_list(A). - -list(Dynamic, DecoderType) -> - gleam@result:then( - list_dynamic(Dynamic), - fun(GleamCaptureVariable) -> - gleam@list:traverse(GleamCaptureVariable, DecoderType) - end - ). - -field(A, B) -> - gleam_stdlib:decode_field(A, B). - -element(A, B) -> - gleam_stdlib:decode_element(A, B). diff --git a/gen/src/gleam@float.erl b/gen/src/gleam@float.erl deleted file mode 100644 index 7eb18cf..0000000 --- a/gen/src/gleam@float.erl +++ /dev/null @@ -1,55 +0,0 @@ --module(gleam@float). --compile(no_auto_import). - --export([parse/1, to_string/1, compare/2, min/2, max/2, ceiling/1, floor/1, round/1, truncate/1]). - -parse(A) -> - gleam_stdlib:parse_float(A). - -to_string(F) -> - gleam@iodata:to_string(gleam@iodata:from_float(F)). - -compare(A, B) -> - case A =:= B of - true -> - eq; - - false -> - case A < B of - true -> - lt; - - false -> - gt - end - end. - -min(A, B) -> - case A < B of - true -> - A; - - false -> - B - end. - -max(A, B) -> - case A > B of - true -> - A; - - false -> - B - end. - -ceiling(A) -> - math:ceil(A). - -floor(A) -> - math:floor(A). - -round(A) -> - erlang:round(A). - -truncate(A) -> - erlang:trunc(A). diff --git a/gen/src/gleam@function.erl b/gen/src/gleam@function.erl deleted file mode 100644 index b376ed0..0000000 --- a/gen/src/gleam@function.erl +++ /dev/null @@ -1,13 +0,0 @@ --module(gleam@function). --compile(no_auto_import). - --export([compose/2, flip/1, identity/1]). - -compose(Fun1, Fun2) -> - fun(A) -> Fun2(Fun1(A)) end. - -flip(Fun) -> - fun(B, A) -> Fun(A, B) end. - -identity(X) -> - X. diff --git a/gen/src/gleam@int.erl b/gen/src/gleam@int.erl deleted file mode 100644 index f256d0f..0000000 --- a/gen/src/gleam@int.erl +++ /dev/null @@ -1,52 +0,0 @@ --module(gleam@int). --compile(no_auto_import). - --export([parse/1, to_string/1, to_base_string/2, compare/2, min/2, max/2, is_even/1, is_odd/1]). - -parse(A) -> - gleam_stdlib:parse_int(A). - -to_string(A) -> - erlang:integer_to_binary(A). - -to_base_string(A, B) -> - erlang:integer_to_binary(A, B). - -compare(A, B) -> - case A =:= B of - true -> - eq; - - false -> - case A < B of - true -> - lt; - - false -> - gt - end - end. - -min(A, B) -> - case A < B of - true -> - A; - - false -> - B - end. - -max(A, B) -> - case A > B of - true -> - A; - - false -> - B - end. - -is_even(X) -> - X rem 2 =:= 0. - -is_odd(X) -> - X rem 2 /= 0. diff --git a/gen/src/gleam@iodata.erl b/gen/src/gleam@iodata.erl deleted file mode 100644 index 5d0c434..0000000 --- a/gen/src/gleam@iodata.erl +++ /dev/null @@ -1,61 +0,0 @@ --module(gleam@iodata). --compile(no_auto_import). - --export([prepend/2, append/2, prepend_iodata/2, append_iodata/2, from_strings/1, concat/1, new/1, to_string/1, byte_size/1, from_float/1, lowercase/1, uppercase/1, reverse/1, split/2, replace/3, is_equal/2, is_empty/1]). - -prepend(A, B) -> - gleam_stdlib:iodata_prepend(A, B). - -append(A, B) -> - gleam_stdlib:iodata_append(A, B). - -prepend_iodata(A, B) -> - gleam_stdlib:iodata_prepend(A, B). - -append_iodata(A, B) -> - gleam_stdlib:iodata_append(A, B). - -from_strings(A) -> - gleam_stdlib:identity(A). - -concat(A) -> - gleam_stdlib:identity(A). - -new(A) -> - gleam_stdlib:identity(A). - -to_string(A) -> - erlang:iolist_to_binary(A). - -byte_size(A) -> - erlang:iolist_size(A). - -from_float(A) -> - io_lib_format:fwrite_g(A). - -lowercase(A) -> - string:lowercase(A). - -uppercase(A) -> - string:uppercase(A). - -reverse(A) -> - string:reverse(A). - -erl_split(A, B, C) -> - string:split(A, B, C). - -split(Iodata, Pattern) -> - erl_split(Iodata, Pattern, all). - -erl_replace(A, B, C, D) -> - string:replace(A, B, C, D). - -replace(Iodata, Pattern, Substitute) -> - erl_replace(Iodata, Pattern, Substitute, all). - -is_equal(A, B) -> - string:equal(A, B). - -is_empty(A) -> - string:is_empty(A). diff --git a/gen/src/gleam@list.erl b/gen/src/gleam@list.erl deleted file mode 100644 index 57789ff..0000000 --- a/gen/src/gleam@list.erl +++ /dev/null @@ -1,400 +0,0 @@ --module(gleam@list). --compile(no_auto_import). - --export([length/1, reverse/1, is_empty/1, contains/2, head/1, tail/1, filter/2, map/2, index_map/2, traverse/2, drop/2, take/2, new/0, append/2, flatten/1, fold/3, fold_right/3, find/2, find_map/2, all/2, any/2, zip/2, strict_zip/2, intersperse/2, at/2, unique/1, sort/2, range/2, repeat/2, split/2, split_while/2, key_find/2]). - -length(A) -> - erlang:length(A). - -reverse(A) -> - lists:reverse(A). - -is_empty(List) -> - List =:= []. - -contains(List, Elem) -> - case List of - [] -> - false; - - [Head | Rest] -> - Head =:= Elem orelse contains(Rest, Elem) - end. - -head(List) -> - case List of - [] -> - gleam@result:none(); - - [X | _] -> - {ok, X} - end. - -tail(List) -> - case List of - [] -> - gleam@result:none(); - - [_ | Xs] -> - {ok, Xs} - end. - -do_filter(List, Fun, Acc) -> - case List of - [] -> - reverse(Acc); - - [X | Xs] -> - NewAcc = case Fun(X) of - true -> - [X | Acc]; - - false -> - Acc - end, - do_filter(Xs, Fun, NewAcc) - end. - -filter(List, Predicate) -> - do_filter(List, Predicate, []). - -do_map(List, Fun, Acc) -> - case List of - [] -> - reverse(Acc); - - [X | Xs] -> - do_map(Xs, Fun, [Fun(X) | Acc]) - end. - -map(List, Fun) -> - do_map(List, Fun, []). - -do_index_map(List, Fun, Index, Acc) -> - case List of - [] -> - reverse(Acc); - - [X | Xs] -> - do_index_map(Xs, Fun, Index + 1, [Fun(Index, X) | Acc]) - end. - -index_map(List, Fun) -> - do_index_map(List, Fun, 0, []). - -do_traverse(List, Fun, Acc) -> - case List of - [] -> - {ok, reverse(Acc)}; - - [X | Xs] -> - case Fun(X) of - {ok, Y} -> - do_traverse(Xs, Fun, [Y | Acc]); - - {error, Error} -> - {error, Error} - end - end. - -traverse(List, Fun) -> - do_traverse(List, Fun, []). - -drop(List, N) -> - case N =< 0 of - true -> - List; - - false -> - case List of - [] -> - []; - - [_ | Xs] -> - drop(Xs, N - 1) - end - end. - -do_take(List, N, Acc) -> - case N =< 0 of - true -> - reverse(Acc); - - false -> - case List of - [] -> - reverse(Acc); - - [X | Xs] -> - do_take(Xs, N - 1, [X | Acc]) - end - end. - -take(List, N) -> - do_take(List, N, []). - -new() -> - []. - -append(A, B) -> - lists:append(A, B). - -do_flatten(Lists, Acc) -> - case Lists of - [] -> - Acc; - - [L | Rest] -> - do_flatten(Rest, append(Acc, L)) - end. - -flatten(Lists) -> - do_flatten(Lists, []). - -fold(List, Initial, Fun) -> - case List of - [] -> - Initial; - - [X | Rest] -> - fold(Rest, Fun(X, Initial), Fun) - end. - -fold_right(List, Initial, Fun) -> - case List of - [] -> - Initial; - - [X | Rest] -> - Fun(X, fold_right(Rest, Initial, Fun)) - end. - -find(Haystack, IsDesired) -> - case Haystack of - [] -> - gleam@result:none(); - - [X | Rest] -> - case IsDesired(X) of - true -> - {ok, X}; - - _ -> - find(Rest, IsDesired) - end - end. - -find_map(Haystack, Fun) -> - case Haystack of - [] -> - gleam@result:none(); - - [X | Rest] -> - case Fun(X) of - {ok, X1} -> - {ok, X1}; - - _ -> - find_map(Rest, Fun) - end - end. - -all(List, Predicate) -> - case List of - [] -> - true; - - [X | Rest] -> - case Predicate(X) of - true -> - all(Rest, Predicate); - - _ -> - false - end - end. - -any(List, Predicate) -> - case List of - [] -> - false; - - [X | Rest] -> - case Predicate(X) of - false -> - any(Rest, Predicate); - - _ -> - true - end - end. - -zip(Xs, Ys) -> - case {Xs, Ys} of - {[], _} -> - []; - - {_, []} -> - []; - - {[X | Xs1], [Y | Ys1]} -> - [{X, Y} | zip(Xs1, Ys1)] - end. - -strict_zip(L1, L2) -> - case length(L1) =:= length(L2) of - true -> - {ok, zip(L1, L2)}; - - false -> - {error, length_mismatch} - end. - -intersperse(List, Elem) -> - case List of - [] -> - List; - - [_] -> - List; - - [X | Rest] -> - [X, Elem | intersperse(Rest, Elem)] - end. - -at(List, Index) -> - case Index < 0 of - true -> - gleam@result:none(); - - false -> - case List of - [] -> - gleam@result:none(); - - [X | Rest] -> - case Index =:= 0 of - true -> - {ok, X}; - - false -> - at(Rest, Index - 1) - end - end - end. - -unique(List) -> - case List of - [] -> - []; - - [X | Rest] -> - [X | unique(filter(Rest, fun(Y) -> Y /= X end))] - end. - -merge_sort(A, B, Compare) -> - case {A, B} of - {[], _} -> - B; - - {_, []} -> - A; - - {[Ax | Ar], [Bx | Br]} -> - case Compare(Ax, Bx) of - lt -> - [Ax | merge_sort(Ar, B, Compare)]; - - _ -> - [Bx | merge_sort(A, Br, Compare)] - end - end. - -do_sort(List, Compare, ListLength) -> - case ListLength < 2 of - true -> - List; - - false -> - SplitLength = ListLength div 2, - AList = take(List, SplitLength), - BList = drop(List, SplitLength), - merge_sort( - do_sort(AList, Compare, SplitLength), - do_sort(BList, Compare, ListLength - SplitLength), - Compare - ) - end. - -sort(List, Compare) -> - do_sort(List, Compare, length(List)). - -range(Start, Stop) -> - case gleam@int:compare(Start, Stop) of - eq -> - []; - - gt -> - [Start | range(Start - 1, Stop)]; - - lt -> - [Start | range(Start + 1, Stop)] - end. - -do_repeat(A, Times, Acc) -> - case Times =< 0 of - true -> - Acc; - - false -> - do_repeat(A, Times - 1, [A | Acc]) - end. - -repeat(A, Times) -> - do_repeat(A, Times, []). - -do_split(List, N, Taken) -> - case N =< 0 of - true -> - {reverse(Taken), List}; - - false -> - case List of - [] -> - {reverse(Taken), []}; - - [X | Xs] -> - do_split(Xs, N - 1, [X | Taken]) - end - end. - -split(List, Index) -> - do_split(List, Index, []). - -do_split_while(List, F, Acc) -> - case List of - [] -> - {reverse(Acc), []}; - - [X | Xs] -> - case F(X) of - false -> - {reverse(Acc), List}; - - _ -> - do_split_while(Xs, F, [X | Acc]) - end - end. - -split_while(List, Predicate) -> - do_split_while(List, Predicate, []). - -key_find(KeywordList, DesiredKey) -> - find_map(KeywordList, fun(Keyword) -> {Key, Value} = Keyword, - case Key =:= DesiredKey of - true -> - {ok, Value}; - - false -> - gleam@result:none() - end end). diff --git a/gen/src/gleam@map.erl b/gen/src/gleam@map.erl deleted file mode 100644 index 66b4feb..0000000 --- a/gen/src/gleam@map.erl +++ /dev/null @@ -1,82 +0,0 @@ --module(gleam@map). --compile(no_auto_import). - --export([size/1, to_list/1, from_list/1, has_key/2, new/0, get/2, insert/3, map_values/2, keys/1, values/1, filter/2, take/2, merge/2, delete/2, drop/2, update/3, fold/3]). - -size(A) -> - maps:size(A). - -to_list(A) -> - maps:to_list(A). - -from_list(A) -> - maps:from_list(A). - -is_key(A, B) -> - maps:is_key(A, B). - -has_key(Map, Key) -> - is_key(Key, Map). - -new() -> - maps:new(). - -get(A, B) -> - gleam_stdlib:map_get(A, B). - -erl_insert(A, B, C) -> - maps:put(A, B, C). - -insert(Map, Key, Value) -> - erl_insert(Key, Value, Map). - -erl_map_values(A, B) -> - maps:map(A, B). - -map_values(Map, Fun) -> - erl_map_values(Fun, Map). - -keys(A) -> - maps:keys(A). - -values(A) -> - maps:values(A). - -erl_filter(A, B) -> - maps:filter(A, B). - -filter(Map, Predicate) -> - erl_filter(Predicate, Map). - -erl_take(A, B) -> - maps:with(A, B). - -take(Map, DesiredKeys) -> - erl_take(DesiredKeys, Map). - -merge(A, B) -> - maps:merge(A, B). - -erl_delete(A, B) -> - maps:remove(A, B). - -delete(Map, Key) -> - erl_delete(Key, Map). - -drop(Map, DisallowedKeys) -> - gleam@list:fold(DisallowedKeys, Map, fun(Key, Acc) -> delete(Acc, Key) end). - -update(Map, Key, Fun) -> - insert(Map, Key, Fun(get(Map, Key))). - -do_fold(List, Initial, Fun) -> - case List of - [] -> - Initial; - - [{K, V} | Tail] -> - do_fold(Tail, Fun(K, V, Initial), Fun) - end. - -fold(Map, Initial, Fun) -> - do_fold(to_list(Map), Initial, Fun). diff --git a/gen/src/gleam@order.erl b/gen/src/gleam@order.erl deleted file mode 100644 index 6306636..0000000 --- a/gen/src/gleam@order.erl +++ /dev/null @@ -1,67 +0,0 @@ --module(gleam@order). --compile(no_auto_import). - --export([reverse/1, to_int/1, compare/2, max/2, min/2]). - -reverse(Order) -> - case Order of - lt -> - gt; - - eq -> - eq; - - gt -> - lt - end. - -to_int(Order) -> - case Order of - lt -> - -1; - - eq -> - 0; - - gt -> - 1 - end. - -compare(A, B) -> - case {A, B} of - {X, Y} when X =:= Y -> - eq; - - {lt, _} -> - lt; - - {eq, gt} -> - lt; - - {_, _} -> - gt - end. - -max(A, B) -> - case {A, B} of - {gt, _} -> - gt; - - {eq, lt} -> - eq; - - {_, _} -> - B - end. - -min(A, B) -> - case {A, B} of - {lt, _} -> - lt; - - {eq, gt} -> - eq; - - {_, _} -> - B - end. diff --git a/gen/src/gleam@pair.erl b/gen/src/gleam@pair.erl deleted file mode 100644 index 3c07918..0000000 --- a/gen/src/gleam@pair.erl +++ /dev/null @@ -1,24 +0,0 @@ --module(gleam@pair). --compile(no_auto_import). - --export([first/1, second/1, swap/1, map_first/2, map_second/2]). - -first(Pair) -> - {A, _} = Pair, - A. - -second(Pair) -> - {_, A} = Pair, - A. - -swap(Pair) -> - {A, B} = Pair, - {B, A}. - -map_first(Pair, Fun) -> - {A, B} = Pair, - {Fun(A), B}. - -map_second(Pair, Fun) -> - {A, B} = Pair, - {A, Fun(B)}. diff --git a/gen/src/gleam@result.erl b/gen/src/gleam@result.erl deleted file mode 100644 index 2484f56..0000000 --- a/gen/src/gleam@result.erl +++ /dev/null @@ -1,70 +0,0 @@ --module(gleam@result). --compile(no_auto_import). - --export([is_ok/1, is_error/1, map/2, map_error/2, flatten/1, then/2, unwrap/2, none/0]). - -is_ok(Result) -> - case Result of - {error, _} -> - false; - - {ok, _} -> - true - end. - -is_error(Result) -> - case Result of - {ok, _} -> - false; - - {error, _} -> - true - end. - -map(Result, Fun) -> - case Result of - {ok, X} -> - {ok, Fun(X)}; - - {error, E} -> - {error, E} - end. - -map_error(Result, Fun) -> - case Result of - {ok, X} -> - {ok, X}; - - {error, Error} -> - {error, Fun(Error)} - end. - -flatten(Result) -> - case Result of - {ok, X} -> - X; - - {error, Error} -> - {error, Error} - end. - -then(Result, Fun) -> - case Result of - {ok, X} -> - Fun(X); - - {error, E} -> - {error, E} - end. - -unwrap(Result, Default) -> - case Result of - {ok, V} -> - V; - - {error, _} -> - Default - end. - -none() -> - {error, nil}. diff --git a/gen/src/gleam@should.erl b/gen/src/gleam@should.erl deleted file mode 100644 index 21acbdf..0000000 --- a/gen/src/gleam@should.erl +++ /dev/null @@ -1,25 +0,0 @@ --module(gleam@should). --compile(no_auto_import). - --export([equal/2, not_equal/2, be_true/1, be_false/1, be_ok/1, be_error/1, fail/0]). - -equal(A, B) -> - gleam_stdlib:should_equal(A, B). - -not_equal(A, B) -> - gleam_stdlib:should_not_equal(A, B). - -be_true(A) -> - gleam_stdlib:should_be_true(A). - -be_false(A) -> - gleam_stdlib:should_be_false(A). - -be_ok(A) -> - gleam_stdlib:should_be_ok(A). - -be_error(A) -> - gleam_stdlib:should_be_error(A). - -fail() -> - be_true(false). diff --git a/gen/src/gleam@string.erl b/gen/src/gleam@string.erl deleted file mode 100644 index 86b1f79..0000000 --- a/gen/src/gleam@string.erl +++ /dev/null @@ -1,110 +0,0 @@ --module(gleam@string). --compile(no_auto_import). - --export([is_empty/1, length/1, reverse/1, replace/3, lowercase/1, uppercase/1, compare/2, slice/3, contains/2, starts_with/2, ends_with/2, split/2, append/2, concat/1, repeat/2, join/2, pad_left/3, pad_right/3, trim/1, trim_left/1, trim_right/1]). - -is_empty(Str) -> - Str =:= <<""/utf8>>. - -length(A) -> - string:length(A). - -reverse(String) -> - gleam@iodata:to_string(gleam@iodata:reverse(gleam@iodata:new(String))). - -replace(String, Pattern, Substitute) -> - gleam@iodata:to_string( - gleam@iodata:replace(gleam@iodata:new(String), Pattern, Substitute) - ). - -lowercase(A) -> - string:lowercase(A). - -uppercase(A) -> - string:uppercase(A). - -compare(A, B) -> - gleam_stdlib:compare_strings(A, B). - -erl_slice(A, B, C) -> - string:slice(A, B, C). - -slice(String, Idx, Len) -> - case Idx < 0 of - true -> - TranslatedIdx = length(String) + Idx, - case TranslatedIdx < 0 of - true -> - <<""/utf8>>; - - false -> - erl_slice(String, TranslatedIdx, Len) - end; - - false -> - erl_slice(String, Idx, Len) - end. - -erl_contains(A, B) -> - gleam_stdlib:string_contains(A, B). - -contains(Haystack, Needle) -> - erl_contains(Haystack, Needle). - -starts_with(A, B) -> - gleam_stdlib:string_starts_with(A, B). - -ends_with(A, B) -> - gleam_stdlib:string_ends_with(A, B). - -split(X, Substring) -> - gleam@list:map( - gleam@iodata:split(gleam@iodata:new(X), Substring), - fun gleam@iodata:to_string/1 - ). - -append(First, Second) -> - gleam@iodata:to_string( - gleam@iodata:append(gleam@iodata:new(First), Second) - ). - -concat(Strings) -> - gleam@iodata:to_string(gleam@iodata:from_strings(Strings)). - -repeat_help(Chunk, Result, Repeats) -> - case Repeats =< 0 of - true -> - concat(Result); - - false -> - repeat_help(Chunk, [Chunk | Result], Repeats - 1) - end. - -repeat(String, Times) -> - repeat_help(String, [], Times). - -join(Strings, Separator) -> - gleam@iodata:to_string( - gleam@iodata:from_strings(gleam@list:intersperse(Strings, Separator)) - ). - -erl_pad(A, B, C, D) -> - gleam_stdlib:string_pad(A, B, C, D). - -pad_left(String, Length, PadString) -> - erl_pad(String, Length, leading, PadString). - -pad_right(String, Length, PadString) -> - erl_pad(String, Length, trailing, PadString). - -erl_trim(A, B) -> - string:trim(A, B). - -trim(String) -> - erl_trim(String, both). - -trim_left(String) -> - erl_trim(String, leading). - -trim_right(String) -> - erl_trim(String, trailing). diff --git a/gen/test/gleam@atom_test.erl b/gen/test/gleam@atom_test.erl deleted file mode 100644 index 91a16bd..0000000 --- a/gen/test/gleam@atom_test.erl +++ /dev/null @@ -1,43 +0,0 @@ --module(gleam@atom_test). --compile(no_auto_import). - --export([from_string_test/0, create_from_string_test/0, to_string_test/0]). - -from_string_test() -> - gleam@should:be_ok(gleam@atom:from_string(<<"ok"/utf8>>)), - gleam@should:be_ok(gleam@atom:from_string(<<"expect"/utf8>>)), - gleam@should:equal( - gleam@atom:from_string( - <<"this is not an atom we have seen before"/utf8>> - ), - {error, atom_not_loaded} - ). - -create_from_string_test() -> - gleam@should:equal( - {ok, gleam@atom:create_from_string(<<"ok"/utf8>>)}, - gleam@atom:from_string(<<"ok"/utf8>>) - ), - gleam@should:equal( - {ok, gleam@atom:create_from_string(<<"expect"/utf8>>)}, - gleam@atom:from_string(<<"expect"/utf8>>) - ), - gleam@should:equal( - {ok, - gleam@atom:create_from_string( - <<"this is another atom we have not seen before"/utf8>> - )}, - gleam@atom:from_string( - <<"this is another atom we have not seen before"/utf8>> - ) - ). - -to_string_test() -> - gleam@should:equal( - gleam@atom:to_string(gleam@atom:create_from_string(<<"ok"/utf8>>)), - <<"ok"/utf8>> - ), - gleam@should:equal( - gleam@atom:to_string(gleam@atom:create_from_string(<<"expect"/utf8>>)), - <<"expect"/utf8>> - ). diff --git a/gen/test/gleam@bool_test.erl b/gen/test/gleam@bool_test.erl deleted file mode 100644 index 8f31a9d..0000000 --- a/gen/test/gleam@bool_test.erl +++ /dev/null @@ -1,30 +0,0 @@ --module(gleam@bool_test). --compile(no_auto_import). - --export([negate_test/0, compare_test/0, max_test/0, min_test/0, to_int_test/0]). - -negate_test() -> - gleam@should:be_false(gleam@bool:negate(true)), - gleam@should:be_true(gleam@bool:negate(false)). - -compare_test() -> - gleam@should:equal(gleam@bool:compare(true, true), eq), - gleam@should:equal(gleam@bool:compare(true, false), gt), - gleam@should:equal(gleam@bool:compare(false, false), eq), - gleam@should:equal(gleam@bool:compare(false, true), lt). - -max_test() -> - gleam@should:equal(gleam@bool:max(true, true), true), - gleam@should:equal(gleam@bool:max(true, false), true), - gleam@should:equal(gleam@bool:max(false, false), false), - gleam@should:equal(gleam@bool:max(false, true), true). - -min_test() -> - gleam@should:equal(gleam@bool:min(true, true), true), - gleam@should:equal(gleam@bool:min(true, false), false), - gleam@should:equal(gleam@bool:min(false, false), false), - gleam@should:equal(gleam@bool:min(false, true), false). - -to_int_test() -> - gleam@should:equal(gleam@bool:to_int(true), 1), - gleam@should:equal(gleam@bool:to_int(false), 0). diff --git a/gen/test/gleam@dynamic_test.erl b/gen/test/gleam@dynamic_test.erl deleted file mode 100644 index 785af15..0000000 --- a/gen/test/gleam@dynamic_test.erl +++ /dev/null @@ -1,199 +0,0 @@ --module(gleam@dynamic_test). --compile(no_auto_import). - --export([string_test/0, int_test/0, float_test/0, thunk_test/0, bool_test/0, atom_test/0, list_test/0, field_test/0, element_test/0]). - -string_test() -> - gleam@should:equal( - gleam@dynamic:string(gleam@dynamic:from(<<""/utf8>>)), - {ok, <<""/utf8>>} - ), - gleam@should:equal( - gleam@dynamic:string(gleam@dynamic:from(<<"Hello"/utf8>>)), - {ok, <<"Hello"/utf8>>} - ), - gleam@should:equal( - gleam@dynamic:string(gleam@dynamic:from(1)), - {error, <<"Expected a string, got an int"/utf8>>} - ), - gleam@should:equal( - gleam@dynamic:string(gleam@dynamic:from([])), - {error, <<"Expected a string, got a list"/utf8>>} - ). - -int_test() -> - gleam@should:equal(gleam@dynamic:int(gleam@dynamic:from(1)), {ok, 1}), - gleam@should:equal(gleam@dynamic:int(gleam@dynamic:from(2)), {ok, 2}), - gleam@should:equal( - gleam@dynamic:int(gleam@dynamic:from(1.0)), - {error, <<"Expected an int, got a float"/utf8>>} - ), - gleam@should:equal( - gleam@dynamic:int(gleam@dynamic:from([])), - {error, <<"Expected an int, got a list"/utf8>>} - ). - -float_test() -> - gleam@should:equal(gleam@dynamic:float(gleam@dynamic:from(1.0)), {ok, 1.0}), - gleam@should:equal(gleam@dynamic:float(gleam@dynamic:from(2.2)), {ok, 2.2}), - gleam@should:equal( - gleam@dynamic:float(gleam@dynamic:from(1)), - {error, <<"Expected a float, got an int"/utf8>>} - ), - gleam@should:equal( - gleam@dynamic:float(gleam@dynamic:from([])), - {error, <<"Expected a float, got a list"/utf8>>} - ). - -thunk_test() -> - gleam@should:be_ok(gleam@dynamic:thunk(gleam@dynamic:from(fun() -> 1 end))), - gleam@should:equal( - gleam@result:map( - gleam@dynamic:thunk(gleam@dynamic:from(fun() -> 1 end)), - fun(F) -> F() end - ), - {ok, gleam@dynamic:from(1)} - ), - gleam@should:be_error( - gleam@dynamic:thunk(gleam@dynamic:from(fun(X) -> X end)) - ), - gleam@should:be_error(gleam@dynamic:thunk(gleam@dynamic:from(1))), - gleam@should:be_error(gleam@dynamic:thunk(gleam@dynamic:from([]))). - -bool_test() -> - gleam@should:equal( - gleam@dynamic:bool(gleam@dynamic:from(true)), - {ok, true} - ), - gleam@should:equal( - gleam@dynamic:bool(gleam@dynamic:from(false)), - {ok, false} - ), - gleam@should:equal( - gleam@dynamic:bool(gleam@dynamic:from(1)), - {error, <<"Expected a bool, got an int"/utf8>>} - ), - gleam@should:equal( - gleam@dynamic:bool(gleam@dynamic:from([])), - {error, <<"Expected a bool, got a list"/utf8>>} - ). - -atom_test() -> - gleam@should:equal( - gleam@dynamic:atom( - gleam@dynamic:from(gleam@atom:create_from_string(<<""/utf8>>)) - ), - {ok, gleam@atom:create_from_string(<<""/utf8>>)} - ), - gleam@should:equal( - gleam@dynamic:atom( - gleam@dynamic:from(gleam@atom:create_from_string(<<"ok"/utf8>>)) - ), - {ok, gleam@atom:create_from_string(<<"ok"/utf8>>)} - ), - gleam@should:be_error(gleam@dynamic:atom(gleam@dynamic:from(1))), - gleam@should:be_error(gleam@dynamic:atom(gleam@dynamic:from([]))). - -list_test() -> - gleam@should:equal( - gleam@dynamic:list(gleam@dynamic:from([]), fun gleam@dynamic:string/1), - {ok, []} - ), - gleam@should:equal( - gleam@dynamic:list(gleam@dynamic:from([]), fun gleam@dynamic:int/1), - {ok, []} - ), - gleam@should:equal( - gleam@dynamic:list( - gleam@dynamic:from([1, 2, 3]), - fun gleam@dynamic:int/1 - ), - {ok, [1, 2, 3]} - ), - gleam@should:equal( - gleam@dynamic:list( - gleam@dynamic:from([[1], [2], [3]]), - fun(GleamCaptureVariable) -> - gleam@dynamic:list( - GleamCaptureVariable, - fun gleam@dynamic:int/1 - ) - end - ), - {ok, [[1], [2], [3]]} - ), - gleam@should:be_error( - gleam@dynamic:list(gleam@dynamic:from(1), fun gleam@dynamic:string/1) - ), - gleam@should:be_error( - gleam@dynamic:list(gleam@dynamic:from(1.0), fun gleam@dynamic:int/1) - ), - gleam@should:be_error( - gleam@dynamic:list( - gleam@dynamic:from([<<""/utf8>>]), - fun gleam@dynamic:int/1 - ) - ), - gleam@should:be_error( - gleam@dynamic:list( - gleam@dynamic:from( - [gleam@dynamic:from(1), - gleam@dynamic:from(<<"not an int"/utf8>>)] - ), - fun gleam@dynamic:int/1 - ) - ). - -field_test() -> - {ok, OkAtom} = gleam@atom:from_string(<<"ok"/utf8>>), - {ok, ErrorAtom} = gleam@atom:from_string(<<"error"/utf8>>), - gleam@should:equal( - gleam@dynamic:field( - gleam@dynamic:from(gleam@map:insert(gleam@map:new(), OkAtom, 1)), - OkAtom - ), - {ok, gleam@dynamic:from(1)} - ), - gleam@should:equal( - gleam@dynamic:field( - gleam@dynamic:from( - gleam@map:insert( - gleam@map:insert(gleam@map:new(), OkAtom, 3), - ErrorAtom, - 1 - ) - ), - OkAtom - ), - {ok, gleam@dynamic:from(3)} - ), - gleam@should:be_error( - gleam@dynamic:field(gleam@dynamic:from(gleam@map:new()), OkAtom) - ), - gleam@should:be_error(gleam@dynamic:field(gleam@dynamic:from(1), OkAtom)), - gleam@should:be_error(gleam@dynamic:field(gleam@dynamic:from([]), [])). - -element_test() -> - {ok, OkAtom} = gleam@atom:from_string(<<"ok"/utf8>>), - OkOneTuple = {OkAtom, 1}, - gleam@should:equal( - gleam@dynamic:element(gleam@dynamic:from(OkOneTuple), 0), - {ok, gleam@dynamic:from(OkAtom)} - ), - gleam@should:equal( - gleam@dynamic:element(gleam@dynamic:from(OkOneTuple), 1), - {ok, gleam@dynamic:from(1)} - ), - gleam@should:be_error( - gleam@dynamic:element(gleam@dynamic:from(OkOneTuple), 2) - ), - gleam@should:be_error( - gleam@dynamic:element(gleam@dynamic:from(OkOneTuple), -1) - ), - gleam@should:be_error(gleam@dynamic:element(gleam@dynamic:from(1), 0)), - gleam@should:be_error( - gleam@dynamic:element( - gleam@dynamic:from(gleam@map:insert(gleam@map:new(), 1, OkAtom)), - 0 - ) - ). diff --git a/gen/test/gleam@float_test.erl b/gen/test/gleam@float_test.erl deleted file mode 100644 index 4f809c6..0000000 --- a/gen/test/gleam@float_test.erl +++ /dev/null @@ -1,71 +0,0 @@ --module(gleam@float_test). --compile(no_auto_import). - --export([parse_test/0, to_string_test/0, compare_test/0, ceiling_test/0, floor_test/0, round_test/0, truncate_test/0, min_test/0, max_test/0]). - -parse_test() -> - gleam@should:equal(gleam@float:parse(<<"1.23"/utf8>>), {ok, 1.23}), - gleam@should:equal(gleam@float:parse(<<"5.0"/utf8>>), {ok, 5.0}), - gleam@should:equal( - gleam@float:parse(<<"0.123456789"/utf8>>), - {ok, 0.123456789} - ), - gleam@should:equal(gleam@float:parse(<<""/utf8>>), {error, nil}), - gleam@should:equal(gleam@float:parse(<<"what"/utf8>>), {error, nil}), - gleam@should:equal(gleam@float:parse(<<"1"/utf8>>), {error, nil}). - -to_string_test() -> - gleam@should:equal(gleam@float:to_string(123.0), <<"123.0"/utf8>>), - gleam@should:equal(gleam@float:to_string(-8.1), <<"-8.1"/utf8>>). - -compare_test() -> - gleam@should:equal(gleam@float:compare(0.0, 0.0), eq), - gleam@should:equal(gleam@float:compare(0.1, 0.1), eq), - gleam@should:equal(gleam@float:compare(0.0, 0.1), lt), - gleam@should:equal(gleam@float:compare(-2.0, -1.9), lt), - gleam@should:equal(gleam@float:compare(2.0, 1.9), gt), - gleam@should:equal(gleam@float:compare(-1.9, -2.0), gt). - -ceiling_test() -> - gleam@should:equal(gleam@float:ceiling(8.1), 9.0), - gleam@should:equal(gleam@float:ceiling(-8.1), -8.0), - gleam@should:equal(gleam@float:ceiling(-8.0), -8.0). - -floor_test() -> - gleam@should:equal(gleam@float:floor(8.1), 8.0), - gleam@should:equal(gleam@float:floor(-8.1), -9.0), - gleam@should:equal(gleam@float:floor(-8.0), -8.0). - -round_test() -> - gleam@should:equal(gleam@float:round(8.1), 8), - gleam@should:equal(gleam@float:round(8.4), 8), - gleam@should:equal(gleam@float:round(8.499), 8), - gleam@should:equal(gleam@float:round(8.5), 9), - gleam@should:equal(gleam@float:round(-8.1), -8), - gleam@should:equal(gleam@float:round(-7.5), -8). - -truncate_test() -> - gleam@should:equal(gleam@float:truncate(8.1), 8), - gleam@should:equal(gleam@float:truncate(8.4), 8), - gleam@should:equal(gleam@float:truncate(8.499), 8), - gleam@should:equal(gleam@float:truncate(8.5), 8), - gleam@should:equal(gleam@float:truncate(-8.1), -8), - gleam@should:equal(gleam@float:truncate(-7.5), -7). - -min_test() -> - gleam@should:equal(gleam@float:min(0.0, 0.0), 0.0), - gleam@should:equal(gleam@float:min(0.3, 1.5), 0.3), - gleam@should:equal(gleam@float:min(1.0, 0.0), 0.0), - gleam@should:equal(gleam@float:min(-1.7, 2.5), -1.7), - gleam@should:equal(gleam@float:min(-2.2, -2.2), -2.2), - gleam@should:equal(gleam@float:min(-1.0, -1.0), -1.0), - gleam@should:equal(gleam@float:min(-1.1, -1.0), -1.1). - -max_test() -> - gleam@should:equal(gleam@float:max(0.0, 0.0), 0.0), - gleam@should:equal(gleam@float:max(0.3, 1.5), 1.5), - gleam@should:equal(gleam@float:max(1.0, 0.0), 1.0), - gleam@should:equal(gleam@float:max(-1.7, 2.5), 2.5), - gleam@should:equal(gleam@float:max(-2.2, -2.2), -2.2), - gleam@should:equal(gleam@float:max(-1.0, -1.0), -1.0), - gleam@should:equal(gleam@float:max(-1.1, -1.0), -1.0). diff --git a/gen/test/gleam@function_test.erl b/gen/test/gleam@function_test.erl deleted file mode 100644 index d85bce1..0000000 --- a/gen/test/gleam@function_test.erl +++ /dev/null @@ -1,50 +0,0 @@ --module(gleam@function_test). --compile(no_auto_import). - --export([compose_test/0, flip_test/0, identity_test/0]). - -compose_test() -> - AddTwo = fun(Int) -> Int + 2 end, - AddThree = fun(Int1) -> Int1 + 3 end, - AddFive = gleam@function:compose(AddTwo, AddThree), - gleam@should:equal(AddFive(1), 6), - HeadToString = gleam@function:compose( - gleam@function:compose( - fun gleam@list:head/1, - fun(GleamCaptureVariable) -> - gleam@result:unwrap(GleamCaptureVariable, 0) - end - ), - fun gleam@int:to_string/1 - ), - gleam@should:equal(HeadToString([1]), <<"1"/utf8>>), - gleam@should:equal(HeadToString([]), <<"0"/utf8>>). - -flip_test() -> - Fun = fun(S, I) -> - gleam@string:append( - gleam@string:append( - gleam@string:append( - gleam@string:append(<<"String: '"/utf8>>, S), - <<"', Int: '"/utf8>> - ), - gleam@int:to_string(I) - ), - <<"'"/utf8>> - ) - end, - FlippedFun = gleam@function:flip(Fun), - gleam@should:equal( - Fun(<<"Bob"/utf8>>, 1), - <<"String: 'Bob', Int: '1'"/utf8>> - ), - gleam@should:equal( - FlippedFun(2, <<"Alice"/utf8>>), - <<"String: 'Alice', Int: '2'"/utf8>> - ). - -identity_test() -> - gleam@should:equal(gleam@function:identity(1), 1), - gleam@should:equal(gleam@function:identity(<<""/utf8>>), <<""/utf8>>), - gleam@should:equal(gleam@function:identity([]), []), - gleam@should:equal(gleam@function:identity({1, 2.0}), {1, 2.0}). diff --git a/gen/test/gleam@int_test.erl b/gen/test/gleam@int_test.erl deleted file mode 100644 index a81c427..0000000 --- a/gen/test/gleam@int_test.erl +++ /dev/null @@ -1,63 +0,0 @@ --module(gleam@int_test). --compile(no_auto_import). - --export([to_string_test/0, parse_test/0, to_base_string_test/0, compare_test/0, min_test/0, max_test/0, is_even_test/0, is_odd_test/0]). - -to_string_test() -> - gleam@should:equal(gleam@int:to_string(123), <<"123"/utf8>>), - gleam@should:equal(gleam@int:to_string(-123), <<"-123"/utf8>>), - gleam@should:equal(gleam@int:to_string(123), <<"123"/utf8>>). - -parse_test() -> - gleam@should:equal(gleam@int:parse(<<"123"/utf8>>), {ok, 123}), - gleam@should:equal(gleam@int:parse(<<"-123"/utf8>>), {ok, -123}), - gleam@should:equal(gleam@int:parse(<<"0123"/utf8>>), {ok, 123}), - gleam@should:equal(gleam@int:parse(<<""/utf8>>), {error, nil}), - gleam@should:equal(gleam@int:parse(<<"what"/utf8>>), {error, nil}), - gleam@should:equal(gleam@int:parse(<<"1.23"/utf8>>), {error, nil}). - -to_base_string_test() -> - gleam@should:equal(gleam@int:to_base_string(100, 16), <<"64"/utf8>>), - gleam@should:equal(gleam@int:to_base_string(-100, 16), <<"-64"/utf8>>). - -compare_test() -> - gleam@should:equal(gleam@int:compare(0, 0), eq), - gleam@should:equal(gleam@int:compare(1, 1), eq), - gleam@should:equal(gleam@int:compare(0, 1), lt), - gleam@should:equal(gleam@int:compare(-2, -1), lt), - gleam@should:equal(gleam@int:compare(2, 1), gt), - gleam@should:equal(gleam@int:compare(-1, -2), gt). - -min_test() -> - gleam@should:equal(gleam@int:min(0, 0), 0), - gleam@should:equal(gleam@int:min(0, 1), 0), - gleam@should:equal(gleam@int:min(1, 0), 0), - gleam@should:equal(gleam@int:min(-1, 2), -1), - gleam@should:equal(gleam@int:min(2, -2), -2), - gleam@should:equal(gleam@int:min(-1, -1), -1). - -max_test() -> - gleam@should:equal(gleam@int:max(0, 0), 0), - gleam@should:equal(gleam@int:max(0, 1), 1), - gleam@should:equal(gleam@int:max(1, 0), 1), - gleam@should:equal(gleam@int:max(-1, 2), 2), - gleam@should:equal(gleam@int:max(2, -2), 2), - gleam@should:equal(gleam@int:max(-1, -1), -1). - -is_even_test() -> - gleam@should:be_true(gleam@int:is_even(0)), - gleam@should:be_true(gleam@int:is_even(2)), - gleam@should:be_true(gleam@int:is_even(-2)), - gleam@should:be_true(gleam@int:is_even(10006)), - gleam@should:be_false(gleam@int:is_even(1)), - gleam@should:be_false(gleam@int:is_even(-3)), - gleam@should:be_false(gleam@int:is_even(10005)). - -is_odd_test() -> - gleam@should:be_false(gleam@int:is_odd(0)), - gleam@should:be_false(gleam@int:is_odd(2)), - gleam@should:be_false(gleam@int:is_odd(-2)), - gleam@should:be_false(gleam@int:is_odd(10006)), - gleam@should:be_true(gleam@int:is_odd(1)), - gleam@should:be_true(gleam@int:is_odd(-3)), - gleam@should:be_true(gleam@int:is_odd(10005)). diff --git a/gen/test/gleam@iodata_test.erl b/gen/test/gleam@iodata_test.erl deleted file mode 100644 index 3df2cbb..0000000 --- a/gen/test/gleam@iodata_test.erl +++ /dev/null @@ -1,103 +0,0 @@ --module(gleam@iodata_test). --compile(no_auto_import). - --export([iodata_test/0, lowercase_test/0, uppercase_test/0, split_test/0, is_equal_test/0, is_empty_test/0]). - -iodata_test() -> - Data = gleam@iodata:prepend( - gleam@iodata:append( - gleam@iodata:append(gleam@iodata:new(<<"ello"/utf8>>), <<","/utf8>>), - <<" world!"/utf8>> - ), - <<"H"/utf8>> - ), - gleam@should:equal(gleam@iodata:to_string(Data), <<"Hello, world!"/utf8>>), - gleam@should:equal(gleam@iodata:byte_size(Data), 13), - Data1 = gleam@iodata:prepend_iodata( - gleam@iodata:append_iodata( - gleam@iodata:append_iodata( - gleam@iodata:new(<<"ello"/utf8>>), - gleam@iodata:new(<<","/utf8>>) - ), - gleam@iodata:concat( - [gleam@iodata:new(<<" wo"/utf8>>), - gleam@iodata:new(<<"rld!"/utf8>>)] - ) - ), - gleam@iodata:new(<<"H"/utf8>>) - ), - gleam@should:equal(gleam@iodata:to_string(Data1), <<"Hello, world!"/utf8>>), - gleam@should:equal(gleam@iodata:byte_size(Data1), 13). - -lowercase_test() -> - gleam@should:equal( - gleam@iodata:to_string( - gleam@iodata:lowercase( - gleam@iodata:from_strings([<<"Gleam"/utf8>>, <<"Gleam"/utf8>>]) - ) - ), - <<"gleamgleam"/utf8>> - ). - -uppercase_test() -> - gleam@should:equal( - gleam@iodata:to_string( - gleam@iodata:uppercase( - gleam@iodata:from_strings([<<"Gleam"/utf8>>, <<"Gleam"/utf8>>]) - ) - ), - <<"GLEAMGLEAM"/utf8>> - ). - -split_test() -> - gleam@should:equal( - gleam@iodata:split( - gleam@iodata:new(<<"Gleam,Erlang,Elixir"/utf8>>), - <<","/utf8>> - ), - [gleam@iodata:new(<<"Gleam"/utf8>>), - gleam@iodata:new(<<"Erlang"/utf8>>), - gleam@iodata:new(<<"Elixir"/utf8>>)] - ), - gleam@should:equal( - gleam@iodata:split( - gleam@iodata:from_strings( - [<<"Gleam, Erl"/utf8>>, <<"ang,Elixir"/utf8>>] - ), - <<", "/utf8>> - ), - [gleam@iodata:new(<<"Gleam"/utf8>>), - gleam@iodata:from_strings([<<"Erl"/utf8>>, <<"ang,Elixir"/utf8>>])] - ). - -is_equal_test() -> - gleam@should:be_true( - gleam@iodata:is_equal( - gleam@iodata:new(<<"12"/utf8>>), - gleam@iodata:from_strings([<<"1"/utf8>>, <<"2"/utf8>>]) - ) - ), - gleam@should:be_true( - gleam@iodata:is_equal( - gleam@iodata:new(<<"12"/utf8>>), - gleam@iodata:new(<<"12"/utf8>>) - ) - ), - gleam@should:be_false( - gleam@iodata:is_equal( - gleam@iodata:new(<<"12"/utf8>>), - gleam@iodata:new(<<"2"/utf8>>) - ) - ). - -is_empty_test() -> - gleam@should:be_true(gleam@iodata:is_empty(gleam@iodata:new(<<""/utf8>>))), - gleam@should:be_false( - gleam@iodata:is_empty(gleam@iodata:new(<<"12"/utf8>>)) - ), - gleam@should:be_true(gleam@iodata:is_empty(gleam@iodata:from_strings([]))), - gleam@should:be_true( - gleam@iodata:is_empty( - gleam@iodata:from_strings([<<""/utf8>>, <<""/utf8>>]) - ) - ). diff --git a/gen/test/gleam@list_test.erl b/gen/test/gleam@list_test.erl deleted file mode 100644 index a49a26f..0000000 --- a/gen/test/gleam@list_test.erl +++ /dev/null @@ -1,291 +0,0 @@ --module(gleam@list_test). --compile(no_auto_import). - --export([length_test/0, reverse_test/0, is_empty_test/0, contains_test/0, head_test/0, tail_test/0, filter_test/0, map_test/0, traverse_test/0, drop_test/0, take_test/0, new_test/0, append_test/0, flatten_test/0, fold_test/0, fold_right_test/0, find_map_test/0, find_test/0, all_test/0, any_test/0, zip_test/0, strict_zip_test/0, intersperse_test/0, at_test/0, unique_test/0, sort_test/0, index_map_test/0, range_test/0, repeat_test/0, split_test/0, split_while_test/0, key_find_test/0]). - -length_test() -> - gleam@should:equal(gleam@list:length([]), 0), - gleam@should:equal(gleam@list:length([1]), 1), - gleam@should:equal(gleam@list:length([1, 1]), 2), - gleam@should:equal(gleam@list:length([1, 1, 1]), 3). - -reverse_test() -> - gleam@should:equal(gleam@list:reverse([]), []), - gleam@should:equal(gleam@list:reverse([1, 2, 3, 4, 5]), [5, 4, 3, 2, 1]). - -is_empty_test() -> - gleam@should:be_true(gleam@list:is_empty([])), - gleam@should:be_false(gleam@list:is_empty([1])). - -contains_test() -> - gleam@should:be_true(gleam@list:contains([0, 4, 5, 1], 1)), - gleam@should:be_false(gleam@list:contains([0, 4, 5, 7], 1)), - gleam@should:be_false(gleam@list:contains([], 1)). - -head_test() -> - gleam@should:equal(gleam@list:head([0, 4, 5, 7]), {ok, 0}), - gleam@should:equal(gleam@list:head([]), {error, nil}). - -tail_test() -> - gleam@should:equal(gleam@list:tail([0, 4, 5, 7]), {ok, [4, 5, 7]}), - gleam@should:equal(gleam@list:tail([0]), {ok, []}), - gleam@should:equal(gleam@list:tail([]), {error, nil}). - -filter_test() -> - gleam@should:equal(gleam@list:filter([], fun(_) -> true end), []), - gleam@should:equal( - gleam@list:filter([0, 4, 5, 7, 3], fun(_) -> true end), - [0, 4, 5, 7, 3] - ), - gleam@should:equal( - gleam@list:filter([0, 4, 5, 7, 3], fun(X) -> X > 4 end), - [5, 7] - ), - gleam@should:equal( - gleam@list:filter([0, 4, 5, 7, 3], fun(X1) -> X1 < 4 end), - [0, 3] - ). - -map_test() -> - gleam@should:equal(gleam@list:map([], fun(X) -> X * 2 end), []), - gleam@should:equal( - gleam@list:map([0, 4, 5, 7, 3], fun(X1) -> X1 * 2 end), - [0, 8, 10, 14, 6] - ). - -traverse_test() -> - Fun = fun(X) -> case X =:= 6 orelse X =:= 5 orelse X =:= 4 of - true -> - {ok, X * 2}; - - false -> - {error, X} - end end, - gleam@should:equal( - gleam@list:traverse([5, 6, 5, 6], Fun), - {ok, [10, 12, 10, 12]} - ), - gleam@should:equal(gleam@list:traverse([4, 6, 5, 7, 3], Fun), {error, 7}). - -drop_test() -> - gleam@should:equal(gleam@list:drop([], 5), []), - gleam@should:equal(gleam@list:drop([1, 2, 3, 4, 5, 6, 7, 8], 5), [6, 7, 8]). - -take_test() -> - gleam@should:equal(gleam@list:take([], 5), []), - gleam@should:equal( - gleam@list:take([1, 2, 3, 4, 5, 6, 7, 8], 5), - [1, 2, 3, 4, 5] - ). - -new_test() -> - gleam@should:equal(gleam@list:new(), []). - -append_test() -> - gleam@should:equal(gleam@list:append([1], [2, 3]), [1, 2, 3]). - -flatten_test() -> - gleam@should:equal(gleam@list:flatten([]), []), - gleam@should:equal(gleam@list:flatten([[]]), []), - gleam@should:equal(gleam@list:flatten([[], [], []]), []), - gleam@should:equal(gleam@list:flatten([[1, 2], [], [3, 4]]), [1, 2, 3, 4]). - -fold_test() -> - gleam@should:equal( - gleam@list:fold([1, 2, 3], [], fun(X, Acc) -> [X | Acc] end), - [3, 2, 1] - ). - -fold_right_test() -> - gleam@should:equal( - gleam@list:fold_right([1, 2, 3], [], fun(X, Acc) -> [X | Acc] end), - [1, 2, 3] - ). - -find_map_test() -> - F = fun(X) -> case X of - 2 -> - {ok, 4}; - - _ -> - {error, nil} - end end, - gleam@should:equal(gleam@list:find_map([1, 2, 3], F), {ok, 4}), - gleam@should:equal(gleam@list:find_map([1, 3, 2], F), {ok, 4}), - gleam@should:equal(gleam@list:find_map([1, 3], F), {error, nil}). - -find_test() -> - IsTwo = fun(X) -> X =:= 2 end, - gleam@should:equal(gleam@list:find([1, 2, 3], IsTwo), {ok, 2}), - gleam@should:equal(gleam@list:find([1, 3, 2], IsTwo), {ok, 2}), - gleam@should:equal(gleam@list:find([1, 3], IsTwo), {error, nil}). - -all_test() -> - gleam@should:equal( - gleam@list:all([1, 2, 3, 4, 5], fun(X) -> X > 0 end), - true - ), - gleam@should:equal( - gleam@list:all([1, 2, 3, 4, 5], fun(X1) -> X1 < 0 end), - false - ), - gleam@should:equal(gleam@list:all([], fun(_) -> false end), true). - -any_test() -> - gleam@should:equal( - gleam@list:any([1, 2, 3, 4, 5], fun(X) -> X =:= 2 end), - true - ), - gleam@should:equal( - gleam@list:any([1, 2, 3, 4, 5], fun(X1) -> X1 < 0 end), - false - ), - gleam@should:equal(gleam@list:any([], fun(_) -> false end), false). - -zip_test() -> - gleam@should:equal(gleam@list:zip([], [1, 2, 3]), []), - gleam@should:equal(gleam@list:zip([1, 2], []), []), - gleam@should:equal( - gleam@list:zip([1, 2, 3], [4, 5, 6]), - [{1, 4}, {2, 5}, {3, 6}] - ), - gleam@should:equal(gleam@list:zip([5, 6], [1, 2, 3]), [{5, 1}, {6, 2}]), - gleam@should:equal(gleam@list:zip([5, 6, 7], [1, 2]), [{5, 1}, {6, 2}]). - -strict_zip_test() -> - gleam@should:equal( - gleam@list:strict_zip([], [1, 2, 3]), - {error, length_mismatch} - ), - gleam@should:equal( - gleam@list:strict_zip([1, 2], []), - {error, length_mismatch} - ), - gleam@should:equal( - gleam@list:strict_zip([1, 2, 3], [4, 5, 6]), - {ok, [{1, 4}, {2, 5}, {3, 6}]} - ), - gleam@should:equal( - gleam@list:strict_zip([5, 6], [1, 2, 3]), - {error, length_mismatch} - ), - gleam@should:equal( - gleam@list:strict_zip([5, 6, 7], [1, 2]), - {error, length_mismatch} - ). - -intersperse_test() -> - gleam@should:equal(gleam@list:intersperse([1, 2, 3], 4), [1, 4, 2, 4, 3]), - gleam@should:equal(gleam@list:intersperse([], 2), []). - -at_test() -> - gleam@should:equal(gleam@list:at([1, 2, 3], 2), {ok, 3}), - gleam@should:equal(gleam@list:at([1, 2, 3], 5), {error, nil}), - gleam@should:equal(gleam@list:at([], 0), {error, nil}), - gleam@should:equal(gleam@list:at([1, 2, 3, 4, 5, 6], -1), {error, nil}). - -unique_test() -> - gleam@should:equal( - gleam@list:unique([1, 1, 2, 3, 4, 4, 4, 5, 6]), - [1, 2, 3, 4, 5, 6] - ), - gleam@should:equal( - gleam@list:unique([7, 1, 45, 6, 2, 47, 2, 7, 5]), - [7, 1, 45, 6, 2, 47, 5] - ), - gleam@should:equal(gleam@list:unique([3, 4, 5]), [3, 4, 5]), - gleam@should:equal(gleam@list:unique([]), []). - -sort_test() -> - gleam@should:equal( - gleam@list:sort([4, 3, 6, 5, 4], fun gleam@int:compare/2), - [3, 4, 4, 5, 6] - ), - gleam@should:equal( - gleam@list:sort([4, 3, 6, 5, 4, 1], fun gleam@int:compare/2), - [1, 3, 4, 4, 5, 6] - ), - gleam@should:equal( - gleam@list:sort([4.1, 3.1, 6.1, 5.1, 4.1], fun gleam@float:compare/2), - [3.1, 4.1, 4.1, 5.1, 6.1] - ), - gleam@should:equal(gleam@list:sort([], fun gleam@int:compare/2), []). - -index_map_test() -> - gleam@should:equal( - gleam@list:index_map([3, 4, 5], fun(I, X) -> {I, X} end), - [{0, 3}, {1, 4}, {2, 5}] - ), - F = fun(I1, X1) -> gleam@string:append(X1, gleam@int:to_string(I1)) end, - gleam@should:equal( - gleam@list:index_map([<<"a"/utf8>>, <<"b"/utf8>>, <<"c"/utf8>>], F), - [<<"a0"/utf8>>, <<"b1"/utf8>>, <<"c2"/utf8>>] - ). - -range_test() -> - gleam@should:equal(gleam@list:range(0, 0), []), - gleam@should:equal(gleam@list:range(1, 1), []), - gleam@should:equal(gleam@list:range(-1, -1), []), - gleam@should:equal(gleam@list:range(0, 1), [0]), - gleam@should:equal(gleam@list:range(0, 5), [0, 1, 2, 3, 4]), - gleam@should:equal(gleam@list:range(1, -5), [1, 0, -1, -2, -3, -4]). - -repeat_test() -> - gleam@should:equal(gleam@list:repeat(1, -10), []), - gleam@should:equal(gleam@list:repeat(1, 0), []), - gleam@should:equal(gleam@list:repeat(2, 3), [2, 2, 2]), - gleam@should:equal( - gleam@list:repeat(<<"x"/utf8>>, 5), - [<<"x"/utf8>>, <<"x"/utf8>>, <<"x"/utf8>>, <<"x"/utf8>>, <<"x"/utf8>>] - ). - -split_test() -> - gleam@should:equal(gleam@list:split([], 0), {[], []}), - gleam@should:equal( - gleam@list:split([0, 1, 2, 3, 4], 0), - {[], [0, 1, 2, 3, 4]} - ), - gleam@should:equal( - gleam@list:split([0, 1, 2, 3, 4], -2), - {[], [0, 1, 2, 3, 4]} - ), - gleam@should:equal( - gleam@list:split([0, 1, 2, 3, 4], 1), - {[0], [1, 2, 3, 4]} - ), - gleam@should:equal( - gleam@list:split([0, 1, 2, 3, 4], 3), - {[0, 1, 2], [3, 4]} - ), - gleam@should:equal( - gleam@list:split([0, 1, 2, 3, 4], 9), - {[0, 1, 2, 3, 4], []} - ). - -split_while_test() -> - gleam@should:equal( - gleam@list:split_while([], fun(X) -> X =< 5 end), - {[], []} - ), - gleam@should:equal( - gleam@list:split_while([1, 2, 3, 4, 5], fun(X1) -> X1 =< 5 end), - {[1, 2, 3, 4, 5], []} - ), - gleam@should:equal( - gleam@list:split_while([1, 2, 3, 4, 5], fun(X2) -> X2 =:= 2 end), - {[], [1, 2, 3, 4, 5]} - ), - gleam@should:equal( - gleam@list:split_while([1, 2, 3, 4, 5], fun(X3) -> X3 =< 3 end), - {[1, 2, 3], [4, 5]} - ), - gleam@should:equal( - gleam@list:split_while([1, 2, 3, 4, 5], fun(X4) -> X4 =< -3 end), - {[], [1, 2, 3, 4, 5]} - ). - -key_find_test() -> - Proplist = [{0, <<"1"/utf8>>}, {1, <<"2"/utf8>>}], - gleam@should:equal(gleam@list:key_find(Proplist, 0), {ok, <<"1"/utf8>>}), - gleam@should:equal(gleam@list:key_find(Proplist, 1), {ok, <<"2"/utf8>>}), - gleam@should:equal(gleam@list:key_find(Proplist, 2), {error, nil}). diff --git a/gen/test/gleam@map_test.erl b/gen/test/gleam@map_test.erl deleted file mode 100644 index 4729edf..0000000 --- a/gen/test/gleam@map_test.erl +++ /dev/null @@ -1,191 +0,0 @@ --module(gleam@map_test). --compile(no_auto_import). - --export([from_list_test/0, has_key_test/0, new_test/0, get_test/0, insert_test/0, map_values_test/0, keys_test/0, values_test/0, take_test/0, drop_test/0, merge_test/0, delete_test/0, update_test/0, fold_test/0]). - -from_list_test() -> - gleam@should:equal( - gleam@map:size(gleam@map:from_list([{4, 0}, {1, 0}])), - 2 - ), - gleam@should:equal( - gleam@map:from_list([{1, 0}, {1, 1}]), - gleam@map:from_list([{1, 1}]) - ). - -has_key_test() -> - gleam@should:be_false(gleam@map:has_key(gleam@map:from_list([]), 1)), - gleam@should:be_true(gleam@map:has_key(gleam@map:from_list([{1, 0}]), 1)), - gleam@should:be_true( - gleam@map:has_key(gleam@map:from_list([{4, 0}, {1, 0}]), 1) - ), - gleam@should:be_false( - gleam@map:has_key(gleam@map:from_list([{4, 0}, {1, 0}]), 0) - ). - -new_test() -> - gleam@should:equal(gleam@map:size(gleam@map:new()), 0), - gleam@should:equal(gleam@map:to_list(gleam@map:new()), []). - -get_test() -> - Proplist = [{4, 0}, {1, 1}], - M = gleam@map:from_list(Proplist), - gleam@should:equal(gleam@map:get(M, 4), {ok, 0}), - gleam@should:equal(gleam@map:get(M, 1), {ok, 1}), - gleam@should:equal(gleam@map:get(M, 2), {error, nil}). - -insert_test() -> - gleam@should:equal( - gleam@map:insert( - gleam@map:insert( - gleam@map:insert(gleam@map:new(), <<"a"/utf8>>, 0), - <<"b"/utf8>>, - 1 - ), - <<"c"/utf8>>, - 2 - ), - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ) - ). - -map_values_test() -> - gleam@should:equal( - gleam@map:map_values( - gleam@map:from_list([{1, 0}, {2, 1}, {3, 2}]), - fun(K, V) -> K + V end - ), - gleam@map:from_list([{1, 1}, {2, 3}, {3, 5}]) - ). - -keys_test() -> - gleam@should:equal( - gleam@map:keys( - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ) - ), - [<<"a"/utf8>>, <<"b"/utf8>>, <<"c"/utf8>>] - ). - -values_test() -> - gleam@should:equal( - gleam@map:values( - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ) - ), - [0, 1, 2] - ). - -take_test() -> - gleam@should:equal( - gleam@map:take( - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ), - [<<"a"/utf8>>, <<"b"/utf8>>, <<"d"/utf8>>] - ), - gleam@map:from_list([{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}]) - ). - -drop_test() -> - gleam@should:equal( - gleam@map:drop( - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ), - [<<"a"/utf8>>, <<"b"/utf8>>, <<"d"/utf8>>] - ), - gleam@map:from_list([{<<"c"/utf8>>, 2}]) - ). - -merge_test() -> - A = gleam@map:from_list( - [{<<"a"/utf8>>, 2}, {<<"c"/utf8>>, 4}, {<<"d"/utf8>>, 3}] - ), - B = gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ), - gleam@should:equal( - gleam@map:merge(A, B), - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, - {<<"b"/utf8>>, 1}, - {<<"c"/utf8>>, 2}, - {<<"d"/utf8>>, 3}] - ) - ), - gleam@should:equal( - gleam@map:merge(B, A), - gleam@map:from_list( - [{<<"a"/utf8>>, 2}, - {<<"b"/utf8>>, 1}, - {<<"c"/utf8>>, 4}, - {<<"d"/utf8>>, 3}] - ) - ). - -delete_test() -> - gleam@should:equal( - gleam@map:delete( - gleam@map:delete( - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ), - <<"a"/utf8>> - ), - <<"d"/utf8>> - ), - gleam@map:from_list([{<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}]) - ). - -update_test() -> - Dict = gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ), - IncOrZero = fun(X) -> case X of - {ok, I} -> - I + 1; - - {error, _} -> - 0 - end end, - gleam@should:equal( - gleam@map:update(Dict, <<"a"/utf8>>, IncOrZero), - gleam@map:from_list( - [{<<"a"/utf8>>, 1}, {<<"b"/utf8>>, 1}, {<<"c"/utf8>>, 2}] - ) - ), - gleam@should:equal( - gleam@map:update(Dict, <<"b"/utf8>>, IncOrZero), - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, {<<"b"/utf8>>, 2}, {<<"c"/utf8>>, 2}] - ) - ), - gleam@should:equal( - gleam@map:update(Dict, <<"z"/utf8>>, IncOrZero), - gleam@map:from_list( - [{<<"a"/utf8>>, 0}, - {<<"b"/utf8>>, 1}, - {<<"c"/utf8>>, 2}, - {<<"z"/utf8>>, 0}] - ) - ). - -fold_test() -> - Dict = gleam@map:from_list( - [{<<"a"/utf8>>, 0}, - {<<"b"/utf8>>, 1}, - {<<"c"/utf8>>, 2}, - {<<"d"/utf8>>, 3}] - ), - Add = fun(_, V, Acc) -> V + Acc end, - gleam@should:equal(gleam@map:fold(Dict, 0, Add), 6), - Concat = fun(K, _, Acc1) -> gleam@string:append(Acc1, K) end, - gleam@should:equal( - gleam@map:fold(Dict, <<""/utf8>>, Concat), - <<"abcd"/utf8>> - ), - gleam@should:equal(gleam@map:fold(gleam@map:from_list([]), 0, Add), 0). diff --git a/gen/test/gleam@order_test.erl b/gen/test/gleam@order_test.erl deleted file mode 100644 index 771e72c..0000000 --- a/gen/test/gleam@order_test.erl +++ /dev/null @@ -1,47 +0,0 @@ --module(gleam@order_test). --compile(no_auto_import). - --export([reverse_test/0, to_int_test/0, compare_test/0, max_test/0, min_test/0]). - -reverse_test() -> - gleam@should:equal(gleam@order:reverse(lt), gt), - gleam@should:equal(gleam@order:reverse(eq), eq), - gleam@should:equal(gleam@order:reverse(gt), lt). - -to_int_test() -> - gleam@should:equal(gleam@order:to_int(lt), -1), - gleam@should:equal(gleam@order:to_int(eq), 0), - gleam@should:equal(gleam@order:to_int(gt), 1). - -compare_test() -> - gleam@should:equal(gleam@order:compare(lt, lt), eq), - gleam@should:equal(gleam@order:compare(lt, eq), lt), - gleam@should:equal(gleam@order:compare(lt, gt), lt), - gleam@should:equal(gleam@order:compare(eq, lt), gt), - gleam@should:equal(gleam@order:compare(eq, eq), eq), - gleam@should:equal(gleam@order:compare(eq, gt), lt), - gleam@should:equal(gleam@order:compare(gt, lt), gt), - gleam@should:equal(gleam@order:compare(gt, eq), gt), - gleam@should:equal(gleam@order:compare(gt, gt), eq). - -max_test() -> - gleam@should:equal(gleam@order:max(lt, lt), lt), - gleam@should:equal(gleam@order:max(lt, eq), eq), - gleam@should:equal(gleam@order:max(lt, gt), gt), - gleam@should:equal(gleam@order:max(eq, lt), eq), - gleam@should:equal(gleam@order:max(eq, eq), eq), - gleam@should:equal(gleam@order:max(eq, gt), gt), - gleam@should:equal(gleam@order:max(gt, lt), gt), - gleam@should:equal(gleam@order:max(gt, eq), gt), - gleam@should:equal(gleam@order:max(gt, gt), gt). - -min_test() -> - gleam@should:equal(gleam@order:min(lt, lt), lt), - gleam@should:equal(gleam@order:min(lt, eq), lt), - gleam@should:equal(gleam@order:min(lt, gt), lt), - gleam@should:equal(gleam@order:min(eq, lt), lt), - gleam@should:equal(gleam@order:min(eq, eq), eq), - gleam@should:equal(gleam@order:min(eq, gt), eq), - gleam@should:equal(gleam@order:min(gt, lt), lt), - gleam@should:equal(gleam@order:min(gt, eq), eq), - gleam@should:equal(gleam@order:min(gt, gt), gt). diff --git a/gen/test/gleam@pair_test.erl b/gen/test/gleam@pair_test.erl deleted file mode 100644 index d073e19..0000000 --- a/gen/test/gleam@pair_test.erl +++ /dev/null @@ -1,29 +0,0 @@ --module(gleam@pair_test). --compile(no_auto_import). - --export([first_test/0, second_test/0, swap_test/0, map_first_test/0, map_second_test/0]). - -first_test() -> - gleam@should:equal(gleam@pair:first({1, 2}), 1), - gleam@should:equal(gleam@pair:first({<<"abc"/utf8>>, []}), <<"abc"/utf8>>). - -second_test() -> - gleam@should:equal(gleam@pair:second({1, 2}), 2), - gleam@should:equal(gleam@pair:second({<<"abc"/utf8>>, []}), []). - -swap_test() -> - gleam@should:equal(gleam@pair:swap({1, <<"2"/utf8>>}), {<<"2"/utf8>>, 1}). - -map_first_test() -> - Inc = fun(A) -> A + 1 end, - gleam@should:equal(gleam@pair:map_first({1, 2}, Inc), {2, 2}), - gleam@should:equal(gleam@pair:map_first({8, 2}, Inc), {9, 2}), - gleam@should:equal(gleam@pair:map_first({0, -2}, Inc), {1, -2}), - gleam@should:equal(gleam@pair:map_first({-10, 20}, Inc), {-9, 20}). - -map_second_test() -> - Dec = fun(A) -> A - 1 end, - gleam@should:equal(gleam@pair:map_second({1, 2}, Dec), {1, 1}), - gleam@should:equal(gleam@pair:map_second({8, 2}, Dec), {8, 1}), - gleam@should:equal(gleam@pair:map_second({0, -2}, Dec), {0, -3}), - gleam@should:equal(gleam@pair:map_second({-10, 20}, Dec), {-10, 19}). diff --git a/gen/test/gleam@result_test.erl b/gen/test/gleam@result_test.erl deleted file mode 100644 index b40d41d..0000000 --- a/gen/test/gleam@result_test.erl +++ /dev/null @@ -1,67 +0,0 @@ --module(gleam@result_test). --compile(no_auto_import). - --export([is_ok_test/0, is_error_test/0, map_test/0, map_error_test/0, flatten_test/0, then_test/0, unwrap_test/0]). - -is_ok_test() -> - gleam@should:be_true(gleam@result:is_ok({ok, 1})), - gleam@should:be_false(gleam@result:is_ok({error, 1})). - -is_error_test() -> - gleam@should:be_false(gleam@result:is_error({ok, 1})), - gleam@should:be_true(gleam@result:is_error({error, 1})). - -map_test() -> - gleam@should:equal(gleam@result:map({ok, 1}, fun(X) -> X + 1 end), {ok, 2}), - gleam@should:equal( - gleam@result:map({ok, 1}, fun(_) -> <<"2"/utf8>> end), - {ok, <<"2"/utf8>>} - ), - gleam@should:equal( - gleam@result:map({error, 1}, fun(X1) -> X1 + 1 end), - {error, 1} - ). - -map_error_test() -> - gleam@should:equal( - gleam@result:map_error({ok, 1}, fun(X) -> X + 1 end), - {ok, 1} - ), - gleam@should:equal( - gleam@result:map_error( - {error, 1}, - fun(X1) -> {<<"ok"/utf8>>, X1 + 1} end - ), - {error, {<<"ok"/utf8>>, 2}} - ). - -flatten_test() -> - gleam@should:equal(gleam@result:flatten({ok, {ok, 1}}), {ok, 1}), - gleam@should:equal(gleam@result:flatten({ok, {error, 1}}), {error, 1}), - gleam@should:equal(gleam@result:flatten({error, 1}), {error, 1}), - gleam@should:equal( - gleam@result:flatten({error, {error, 1}}), - {error, {error, 1}} - ). - -then_test() -> - gleam@should:equal( - gleam@result:then({error, 1}, fun(X) -> {ok, X + 1} end), - {error, 1} - ), - gleam@should:equal( - gleam@result:then({ok, 1}, fun(X1) -> {ok, X1 + 1} end), - {ok, 2} - ), - gleam@should:equal( - gleam@result:then({ok, 1}, fun(_) -> {ok, <<"type change"/utf8>>} end), - {ok, <<"type change"/utf8>>} - ), - gleam@should:equal( - gleam@result:then({ok, 1}, fun(_) -> {error, 1} end), - {error, 1} - ). - -unwrap_test() -> - gleam@should:equal(gleam@result:unwrap({ok, 1}, 50), 1), - gleam@should:equal(gleam@result:unwrap({error, <<"nope"/utf8>>}, 50), 50). diff --git a/gen/test/gleam@string_test.erl b/gen/test/gleam@string_test.erl deleted file mode 100644 index 54e517f..0000000 --- a/gen/test/gleam@string_test.erl +++ /dev/null @@ -1,212 +0,0 @@ --module(gleam@string_test). --compile(no_auto_import). - --export([length_test/0, lowercase_test/0, uppercase_test/0, reverse_test/0, split_test/0, replace_test/0, append_test/0, compare_test/0, contains_test/0, concat_test/0, repeat_test/0, join_test/0, trim_test/0, trim_left_test/0, trim_right_test/0, starts_with_test/0, ends_with_test/0, slice_test/0, pad_left_test/0, pad_right_test/0]). - -length_test() -> - gleam@should:equal(gleam@string:length(<<"ß↑e̊"/utf8>>), 3), - gleam@should:equal(gleam@string:length(<<"Gleam"/utf8>>), 5), - gleam@should:equal(gleam@string:length(<<""/utf8>>), 0). - -lowercase_test() -> - gleam@should:equal( - gleam@string:lowercase(<<"Gleam"/utf8>>), - <<"gleam"/utf8>> - ). - -uppercase_test() -> - gleam@should:equal( - gleam@string:uppercase(<<"Gleam"/utf8>>), - <<"GLEAM"/utf8>> - ). - -reverse_test() -> - gleam@should:equal( - gleam@string:reverse(<<"Gleam"/utf8>>), - <<"maelG"/utf8>> - ). - -split_test() -> - gleam@should:equal( - gleam@string:split(<<"Gleam,Erlang,Elixir"/utf8>>, <<","/utf8>>), - [<<"Gleam"/utf8>>, <<"Erlang"/utf8>>, <<"Elixir"/utf8>>] - ), - gleam@should:equal( - gleam@string:split(<<"Gleam, Erlang,Elixir"/utf8>>, <<", "/utf8>>), - [<<"Gleam"/utf8>>, <<"Erlang,Elixir"/utf8>>] - ). - -replace_test() -> - gleam@should:equal( - gleam@string:replace( - <<"Gleam,Erlang,Elixir"/utf8>>, - <<","/utf8>>, - <<"++"/utf8>> - ), - <<"Gleam++Erlang++Elixir"/utf8>> - ). - -append_test() -> - gleam@should:equal( - gleam@string:append(<<"Test"/utf8>>, <<" Me"/utf8>>), - <<"Test Me"/utf8>> - ). - -compare_test() -> - gleam@should:equal(gleam@string:compare(<<""/utf8>>, <<""/utf8>>), eq), - gleam@should:equal(gleam@string:compare(<<"a"/utf8>>, <<""/utf8>>), gt), - gleam@should:equal(gleam@string:compare(<<"a"/utf8>>, <<"A"/utf8>>), gt), - gleam@should:equal(gleam@string:compare(<<"A"/utf8>>, <<"B"/utf8>>), lt), - gleam@should:equal(gleam@string:compare(<<"t"/utf8>>, <<"ABC"/utf8>>), gt). - -contains_test() -> - gleam@should:equal( - gleam@string:contains(<<"gleam"/utf8>>, <<"ea"/utf8>>), - true - ), - gleam@should:equal( - gleam@string:contains(<<"gleam"/utf8>>, <<"x"/utf8>>), - false - ), - gleam@should:equal( - gleam@string:contains(<<"bellwether"/utf8>>, <<"bell"/utf8>>), - true - ). - -concat_test() -> - gleam@should:equal( - gleam@string:concat( - [<<"Hello"/utf8>>, <<", "/utf8>>, <<"world!"/utf8>>] - ), - <<"Hello, world!"/utf8>> - ). - -repeat_test() -> - gleam@should:equal( - gleam@string:repeat(<<"hi"/utf8>>, 3), - <<"hihihi"/utf8>> - ), - gleam@should:equal(gleam@string:repeat(<<"hi"/utf8>>, 0), <<""/utf8>>), - gleam@should:equal(gleam@string:repeat(<<"hi"/utf8>>, -1), <<""/utf8>>). - -join_test() -> - gleam@should:equal( - gleam@string:join([<<"Hello"/utf8>>, <<"world!"/utf8>>], <<", "/utf8>>), - <<"Hello, world!"/utf8>> - ), - gleam@should:equal( - gleam@string:join([<<"Hello"/utf8>>, <<"world!"/utf8>>], <<"-"/utf8>>), - <<"Hello-world!"/utf8>> - ). - -trim_test() -> - gleam@should:equal( - gleam@string:trim(<<" hats \n"/utf8>>), - <<"hats"/utf8>> - ). - -trim_left_test() -> - gleam@should:equal( - gleam@string:trim_left(<<" hats \n"/utf8>>), - <<"hats \n"/utf8>> - ). - -trim_right_test() -> - gleam@should:equal( - gleam@string:trim_right(<<" hats \n"/utf8>>), - <<" hats"/utf8>> - ). - -starts_with_test() -> - gleam@should:equal( - gleam@string:starts_with(<<"theory"/utf8>>, <<""/utf8>>), - true - ), - gleam@should:equal( - gleam@string:starts_with(<<"theory"/utf8>>, <<"the"/utf8>>), - true - ), - gleam@should:equal( - gleam@string:starts_with(<<"theory"/utf8>>, <<"ory"/utf8>>), - false - ), - gleam@should:equal( - gleam@string:starts_with(<<"theory"/utf8>>, <<"theory2"/utf8>>), - false - ). - -ends_with_test() -> - gleam@should:equal( - gleam@string:ends_with(<<"theory"/utf8>>, <<""/utf8>>), - true - ), - gleam@should:equal( - gleam@string:ends_with(<<"theory"/utf8>>, <<"ory"/utf8>>), - true - ), - gleam@should:equal( - gleam@string:ends_with(<<"theory"/utf8>>, <<"the"/utf8>>), - false - ), - gleam@should:equal( - gleam@string:ends_with(<<"theory"/utf8>>, <<"theory2"/utf8>>), - false - ). - -slice_test() -> - gleam@should:equal( - gleam@string:slice(<<"gleam"/utf8>>, 1, 2), - <<"le"/utf8>> - ), - gleam@should:equal( - gleam@string:slice(<<"gleam"/utf8>>, 1, 10), - <<"leam"/utf8>> - ), - gleam@should:equal( - gleam@string:slice(<<"gleam"/utf8>>, 10, 3), - <<""/utf8>> - ), - gleam@should:equal( - gleam@string:slice(<<"gleam"/utf8>>, -2, 2), - <<"am"/utf8>> - ), - gleam@should:equal( - gleam@string:slice(<<"gleam"/utf8>>, -12, 2), - <<""/utf8>> - ). - -pad_left_test() -> - gleam@should:equal( - gleam@string:pad_left(<<"121"/utf8>>, 5, <<"."/utf8>>), - <<"..121"/utf8>> - ), - gleam@should:equal( - gleam@string:pad_left(<<"121"/utf8>>, 3, <<"."/utf8>>), - <<"121"/utf8>> - ), - gleam@should:equal( - gleam@string:pad_left(<<"121"/utf8>>, 2, <<"."/utf8>>), - <<"121"/utf8>> - ), - gleam@should:equal( - gleam@string:pad_left(<<"121"/utf8>>, 5, <<"XY"/utf8>>), - <<"XYXY121"/utf8>> - ). - -pad_right_test() -> - gleam@should:equal( - gleam@string:pad_right(<<"121"/utf8>>, 5, <<"."/utf8>>), - <<"121.."/utf8>> - ), - gleam@should:equal( - gleam@string:pad_right(<<"121"/utf8>>, 3, <<"."/utf8>>), - <<"121"/utf8>> - ), - gleam@should:equal( - gleam@string:pad_right(<<"121"/utf8>>, 2, <<"."/utf8>>), - <<"121"/utf8>> - ), - gleam@should:equal( - gleam@string:pad_right(<<"121"/utf8>>, 5, <<"XY"/utf8>>), - <<"121XYXY"/utf8>> - ). |