rename 'sloppy_existing_atom' to 'attempt_atom'

This commit is contained in:
alisdair sullivan 2013-07-05 03:11:01 +00:00
parent 5dd62e27b5
commit fe2bd15184
2 changed files with 11 additions and 10 deletions

View file

@ -53,7 +53,7 @@ to_term(Source, Config) when is_list(Config) ->
parse_config(Config) -> parse_config(Config, #config{}).
parse_config([{labels, Val}|Rest], Config)
when Val == binary; Val == atom; Val == existing_atom; Val == sloppy_existing_atom ->
when Val == binary; Val == atom; Val == existing_atom; Val == attempt_atom ->
parse_config(Rest, Config#config{labels = Val});
parse_config([labels|Rest], Config) ->
parse_config(Rest, Config#config{labels = binary});
@ -107,7 +107,7 @@ format_key(Key, Config) ->
binary -> Key
; atom -> binary_to_atom(Key, utf8)
; existing_atom -> binary_to_existing_atom(Key, utf8)
; sloppy_existing_atom ->
; attempt_atom ->
try binary_to_existing_atom(Key, utf8) of
Result -> Result
catch
@ -140,8 +140,8 @@ config_test_() ->
parse_config([{labels, existing_atom}])
)},
{"sloppy existing atom labels", ?_assertEqual(
#config{labels=sloppy_existing_atom},
parse_config([{labels, sloppy_existing_atom}])
#config{labels=attempt_atom},
parse_config([{labels, attempt_atom}])
)},
{"post decode", ?_assertEqual(
#config{post_decode=F},
@ -167,11 +167,11 @@ format_key_test_() ->
)},
{"sloppy existing atom key", ?_assertEqual(
key,
format_key(<<"key">>, #config{labels=sloppy_existing_atom})
format_key(<<"key">>, #config{labels=attempt_atom})
)},
{"nonexisting atom key", ?_assertEqual(
<<"nonexistentatom">>,
format_key(<<"nonexistentatom">>, #config{labels=sloppy_existing_atom})
format_key(<<"nonexistentatom">>, #config{labels=attempt_atom})
)}
].