I am trying to make a unit-testing framework for J, in the lines of
the other standard star-unit frameworks, for example, like JUnit
http://en.wikipedia.org/wiki/JUnit

However, I found the facilities for reflection and exception handling
in J is wanting compared to other languages like Java.

---------
sum=: +
mul=: *

should_eq=: dyad :0
  :
  text=. ''
  if. -.x-:y do.
    text=. x ([,' -...@-: ',])&": y
  end.

  text assert x-:y
)

test_sum=: monad : 0
  10 should_eq sum/ 1 2 3 4
  10 should_eq sum/ 1 2 3
)
test_mul=: monad : 0
  24 should_eq mul/ 1 2 3 4
  6 should_eq mul/ 1 2 3 4
)

all_test=: monad : 0
  test_sum''
  test_mul''
)

all_test''

---------

First limitation: I want to get the line number(in the script file
along with the file name) when there is a failure. How do I get this?
(13!:13 was a possible path but the line number there isn't the LN
from the top of the file)

Second limitation: each test case should run independently from each
other. That means the failure in test_sum shouldn't stop running
test_mul. What is an easy and flexible way? (maybe making a gerund
array of test_sum and test_mul, and running through the gerund array
to execute each verb inside try, catch statement -- handling the
failure appropriately afterwards)

Gathering all the verbs that start with "test_" wouldn't be that hard.
(reflection)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to