[erlang-questions] Design strategies for a test suite
John Haugeland
stonecypher@REDACTED
Sat May 17 22:16:12 CEST 2008
Actually, orbitz on freenode #erlang just gave me a tremendously interesting
new mechanism that's left me feeling quite stupid for not having thought of
it: provide a function that returns the non-exported functions as lambdas.
Yes, it's related to the "omg you're breaking export" mindset, but if you
take export to be "the things which should be usable under normal
circumstances" and declare test time to be a magical time when the laws of
common sense don't apply, then this suddenly becomes by far the least
offensive hack to this end that I've seen.
Here's a super-cheesy example which works (obviously you'd want to export
information like name and arity and whatever, but this gets the idea
across):
-module(run_lambda_export).
-export([go/0]).
go() ->
[ F0, F1 ] = lambda_export:get_funcs(),
io:format("~p~n~p~n", [ F0(), F1(hello) ]),
done.
-module(lambda_export).
-export([get_funcs/0]).
internal() -> a_winner_is_yuo.
hidden(X) -> { you_sent, X }.
get_funcs() ->
[ fun internal/0, fun hidden/1 ].
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080517/5b3a30c8/attachment.htm>
More information about the erlang-questions
mailing list