diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-03-17 14:34:07 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-03-17 14:34:07 +0000 |
commit | 00ff9767dc61e698aac791b43704cfce1ab33600 (patch) | |
tree | 257392f879a3524b04043e5385ca1ba871aa6908 /gen/atom.erl | |
parent | de6dca34edf5ab52bc7eab02745c59d8c0dd777d (diff) | |
download | gleam_stdlib-00ff9767dc61e698aac791b43704cfce1ab33600.tar.gz gleam_stdlib-00ff9767dc61e698aac791b43704cfce1ab33600.zip |
stdlib atom
Diffstat (limited to 'gen/atom.erl')
-rw-r--r-- | gen/atom.erl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gen/atom.erl b/gen/atom.erl new file mode 100644 index 0000000..70c899b --- /dev/null +++ b/gen/atom.erl @@ -0,0 +1,38 @@ +-module(atom). +-compile(no_auto_import). +-include_lib("eunit/include/eunit.hrl"). + +-export([from_string/1, create_from_string/1, to_string/1]). + +from_string(A) -> + gleam__stdlib:atom_from_string(A). + +-ifdef(TEST). +from_string_test() -> + expect:is_ok(from_string(<<"ok">>)), + expect:is_ok(from_string(<<"expect">>)), + expect:equal(from_string(<<"this is not an atom we have seen before">>), + {error, atom_not_loaded}). +-endif. + +create_from_string(A) -> + gleam__stdlib:atom_create_from_string(A). + +-ifdef(TEST). +create_from_string_test() -> + Ok = fun(X) -> {ok, X} end, + expect:equal(Ok(create_from_string(<<"ok">>)), from_string(<<"ok">>)), + expect:equal(Ok(create_from_string(<<"expect">>)), + from_string(<<"expect">>)), + expect:equal(Ok(create_from_string(<<"this is another atom we have not seen before">>)), + from_string(<<"this is another atom we have not seen before">>)). +-endif. + +to_string(A) -> + gleam__stdlib:atom_to_string(A). + +-ifdef(TEST). +to_string_test() -> + expect:equal(to_string(create_from_string(<<"ok">>)), <<"ok">>), + expect:equal(to_string(create_from_string(<<"expect">>)), <<"expect">>). +-endif. |