Code re-use in Speclj

已查看 34 次
跳至第一个未读帖子

Karsten Schmidt

未读,
2014年2月3日 17:58:002014/2/3
收件人 spe...@googlegroups.com
Hiya,

(apologies for x-posting, only just realized this group exists)

I've been getting quite excited about integrating Speclj via its
auto-runner into my mixed CLJ/CLJS Org-mode/Babel setup, but now
feeling a bit lost how to go about wrapping a number of test
characteristics ("(it)" forms in speclj parlance) into re-usable
units. In the assertions below I'd like to parameterize the "+" calls
(i.e.. replace with other math ops), but the docs are pretty
slim/non-existent about how one could form modules/groups of such
parameterized tests. It doesn't seem to be possible to just wrap those
within a function:

(describe "blah"
  (with a2 (vec2 1 2))
  (with b2 (vec2 10 20))

  ;; FIXME how to group these as unit?
  (it "a2 n m" (should= (+ @a2 @b2) (+ @a2 10 20)))
  (it "a2 b2 m" (should= (+ (+ @a2 @b2) 20) (+ @a2 @b2 20)))
  (it "a2 b2 b2" (should= (+ (+ @a2 @b2) @b2) (+ @a2 @b2 @b2)))
  (it "a2 n b2" (should= (+ (+ @a2 10) @b2) (+ @a2 10 @b2))))


Any pointers please? Is it even possible? If not, isn't this a fairly
common use case?

Thanks a lot!
回复全部
回复作者
转发
0 个新帖子