diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-06-25 22:48:07 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-06-25 22:48:07 +0100 |
commit | 2c2541750ca4b7b604070c75c18d84be833c97d5 (patch) | |
tree | f5e63d941a1c7e2c2d4dff1d81c43fa2766308ae /gen/test/std@any_test.erl | |
parent | 96c20b8ebf8420fbba75c97fa08eaeb34e8dc394 (diff) | |
download | gleam_stdlib-2c2541750ca4b7b604070c75c18d84be833c97d5.tar.gz gleam_stdlib-2c2541750ca4b7b604070c75c18d84be833c97d5.zip |
stdlib namespace std -> gleam
Diffstat (limited to 'gen/test/std@any_test.erl')
-rw-r--r-- | gen/test/std@any_test.erl | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/gen/test/std@any_test.erl b/gen/test/std@any_test.erl deleted file mode 100644 index 3164919..0000000 --- a/gen/test/std@any_test.erl +++ /dev/null @@ -1,110 +0,0 @@ --module(std@any_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, tuple_test/0, field_test/0]). - -string_test() -> - std@expect:equal(std@any:string(std@any:from(<<"">>)), {ok, <<"">>}), - std@expect:equal(std@any:string(std@any:from(<<"Hello">>)), - {ok, <<"Hello">>}), - std@expect:equal(std@any:string(std@any:from(1)), - {error, <<"Expected a String, got `1`">>}), - std@expect:equal(std@any:string(std@any:from([])), - {error, <<"Expected a String, got `[]`">>}). - -int_test() -> - std@expect:equal(std@any:int(std@any:from(1)), {ok, 1}), - std@expect:equal(std@any:int(std@any:from(2)), {ok, 2}), - std@expect:equal(std@any:int(std@any:from(1.0)), - {error, <<"Expected an Int, got `1.0`">>}), - std@expect:equal(std@any:int(std@any:from([])), - {error, <<"Expected an Int, got `[]`">>}). - -float_test() -> - std@expect:equal(std@any:float(std@any:from(1.0)), {ok, 1.0}), - std@expect:equal(std@any:float(std@any:from(2.2)), {ok, 2.2}), - std@expect:equal(std@any:float(std@any:from(1)), - {error, <<"Expected a Float, got `1`">>}), - std@expect:equal(std@any:float(std@any:from([])), - {error, <<"Expected a Float, got `[]`">>}). - -thunk_test() -> - std@expect:is_ok(std@any:thunk(std@any:from(fun() -> 1 end))), - std@expect:equal(std@result:map(std@any:thunk(std@any:from(fun() -> 1 end)), - fun(F) -> F() end), - {ok, std@any:from(1)}), - std@expect:is_error(std@any:thunk(std@any:from(fun(X) -> X end))), - std@expect:is_error(std@any:thunk(std@any:from(1))), - std@expect:is_error(std@any:thunk(std@any:from([]))). - -bool_test() -> - std@expect:equal(std@any:bool(std@any:from(true)), {ok, true}), - std@expect:equal(std@any:bool(std@any:from(false)), {ok, false}), - std@expect:equal(std@any:bool(std@any:from(1)), - {error, <<"Expected a Bool, got `1`">>}), - std@expect:equal(std@any:bool(std@any:from([])), - {error, <<"Expected a Bool, got `[]`">>}). - -atom_test() -> - std@expect:equal(std@any:atom(std@any:from(std@atom:create_from_string(<<"">>))), - {ok, std@atom:create_from_string(<<"">>)}), - std@expect:equal(std@any:atom(std@any:from(std@atom:create_from_string(<<"ok">>))), - {ok, std@atom:create_from_string(<<"ok">>)}), - std@expect:is_error(std@any:atom(std@any:from(1))), - std@expect:is_error(std@any:atom(std@any:from([]))). - -list_test() -> - std@expect:equal(std@any:list(std@any:from([]), fun std@any:string/1), - {ok, []}), - std@expect:equal(std@any:list(std@any:from([]), fun std@any:int/1), - {ok, []}), - std@expect:equal(std@any:list(std@any:from([1, 2, 3]), fun std@any:int/1), - {ok, [1, 2, 3]}), - std@expect:equal(std@any:list(std@any:from([[1], [2], [3]]), - fun(Capture1) -> - std@any:list(Capture1, fun std@any:int/1) - end), - {ok, [[1], [2], [3]]}), - std@expect:is_error(std@any:list(std@any:from(1), fun std@any:string/1)), - std@expect:is_error(std@any:list(std@any:from(1.0), fun std@any:int/1)), - std@expect:is_error(std@any:list(std@any:from([<<"">>]), - fun std@any:int/1)), - std@expect:is_error(std@any:list(std@any:from([std@any:from(1), - std@any:from(<<"not an int">>)]), - fun std@any:int/1)). - -tuple_test() -> - std@expect:equal(std@any:tuple(std@any:from({1, []})), - {ok, {std@any:from(1), std@any:from([])}}), - std@expect:equal(std@any:tuple(std@any:from({<<"ok">>, <<"ok">>})), - {ok, {std@any:from(<<"ok">>), std@any:from(<<"ok">>)}}), - std@expect:is_error(std@any:tuple(std@any:from({1}))), - std@expect:is_error(std@any:tuple(std@any:from({1, 2, 3}))), - std@expect:equal(std@result:then(std@result:then(std@any:tuple(std@any:from({1, - 2.0})), - fun(X) -> - std@result:map(std@any:int(std@tuple:first(X)), - fun(F) -> - {F, - std@tuple:second(X)} - end) - end), - fun(X) -> - std@result:map(std@any:float(std@tuple:second(X)), - fun(F) -> - {std@tuple:first(X), - F} - end) - end), - {ok, {1, 2.0}}). - -field_test() -> - {ok, OkAtom} = std@atom:from_string(<<"ok">>), - std@expect:equal(std@any:field(std@any:from(#{}#{ok => 1}), OkAtom), - {ok, std@any:from(1)}), - std@expect:equal(std@any:field(std@any:from(#{}#{ok => 3}#{earlier => 2}), - OkAtom), - {ok, std@any:from(3)}), - std@expect:is_error(std@any:field(std@any:from(#{}), OkAtom)), - std@expect:is_error(std@any:field(std@any:from(1), OkAtom)), - std@expect:is_error(std@any:field(std@any:from([]), [])). |