Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davydog187 committed Nov 30, 2024
1 parent 989d67b commit ddb42d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/luerl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ externalize(S) ->
internalize(S) ->
luerl_lib_math:internalize(S).

%% put_private(Key, Value, State) ->
%% State.
%% get_private(Key, State) ->
%% Value.
put_private(Key, Value, S) ->
Private = maps:put(Key, Value, S#luerl.private),
S#luerl{private=Private}.
Expand Down
6 changes: 6 additions & 0 deletions test/luerl_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ invalid_value_test() ->
State = luerl:init(),
?assertException(error, {badarg, {invalid, value}},
luerl:encode({invalid, value}, State)).

private_test() ->
State1 = luerl:init(),
State2 = luerl:put_private(secret, <<"mysecret">>, State1),
?assertMatch(<<"mysecret">>, luerl:get_private(secret, State2)),
?assertException(error, {badkey, missing}, luerl:get_private(missing, State2)).

0 comments on commit ddb42d8

Please sign in to comment.