/test/decorator_test.erl
Erlang | 21 lines | 13 code | 6 blank | 2 comment | 0 complexity | e54d5345b8a86b35f5504e08358d5938 MD5 | raw file
1-module(decorator_test). 2-include_lib("eunit/include/eunit.hrl"). 3-export([replace_return_value_decorator/2]). 4 5-compile([{parse_transform, decorators}]). 6 7 8% example decorator that replaces the return value with the atom 'replaced' 9% note that we always pass the arguments as a single list to the next fun 10replace_return_value_decorator(F,Args)-> 11 fun() -> 12 _R = apply(F, [Args] ), 13 replaced 14 end. 15 16-decorate({ ?MODULE, replace_return_value_decorator }). 17replace_ret_val_decorated() -> ok. 18 19replace_ret_value_test()-> 20 ?assertEqual(replaced, replace_ret_val_decorated() ). 21