*Problem*
The parentheses in elm-test are visually noisy.
For example:
all : Test all = describe "Unit test examples"
[ test "Addition" <|
\() -> -- <= HERE!
Expect.equal (3 + 7) 10
, test "String.left" <|
\() -> -- <= HERE!
Expect.equal "a" (String.left 1 "abcdefg")
]
Year, I know they have an important role to control order of evaluation of test
codes.
But in fact, I think the role is relatively less important in Elm and elm-test.
Because Elm functions rarely crush by its design.
So we usually *don't have to be warried that the entire test stops by a runtime
error* in test codes.
Of course, there're a somewhat important problem left:
Entire test codes are evaluated even when testing partially, which slows
partial test executions.
*Solution*
I found a way to the parentheses *optionally* omittable, inspired by this
article (in Japanese) <http://qiita.com/hosomichi/items/f4f45535deca7ebebe65>.
Make a module like this:
module WrappedExpect -- The name is provisional.
exposing (..)
import Expect
*-- Wrap Expect.* functions which receives () as an argument
equal : a -> a -> () -> Expectation
equal a b _ = Expect.equal a b*
-- When using:
tests : Test
tests =
describe "example suite"
[ test "example test" <| equal "actual" "expected"
]
I think it make writing tests more flexible to provide the module like
above along with the exisiting Expect. Feel free to comment!
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.