The example for ExUnit's "Case.describe/2" 
<https://hexdocs.pm/ex_unit/ExUnit.Case.html#describe/2-examples> uses a 
String to reference to the given Function in test:

describe "String.capitalize/1" do...
 
Changes to the actual implementation (names, arity) are currently not 
picked up by the compiler or test frameworks.

To help myself out i wrote a helper function "literally/1" which accepts a 
function as parameter and turns it into a fully qualified function capture 
string:

describe literally(&String.capitalize/1) do...

This removes potential code smells when referring to functions.

Having a dedicated function for this adds a lot of clutter (every describe 
line get's expanded and you have to maintain that helper function in each 
project).

So if this is something improving the developer experience for anybody else 
i'd like to propose the additional acceptance of function-captures as first 
parameter of describe/2:

describe &String.capitalize/1 do...

P.s.: i hope i got the terms function capture for function references right.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/3b47d4bf-4e91-4896-8549-a9ffab5890a0n%40googlegroups.com.

Reply via email to