This is the kind of contribution that we hoped for when the
J Wiki was set up.  Thanks.

I do have a suggestion.  Experience shows that having a
companion test script for an implemented facility would
be very useful.  A test script is like an ordinary script,
but the sentences contained therein are purported true
propositions and any non-assigned results are all 1s.
You run a test script with 0!:2 and/or 0!:3 .

For example, a test script for trace.ijs might look like the
following:

'(3 + 4)'                    -: paren '3+4'
'(1 2 3 ((+ /)  . *) 4 5 6)' -: paren '1 2 3 +/ .* 4 5 6' 

'a b c'=: 1 2 3
t=: '((2 * a) (% ~) ((- b) ((+ , -) (*: b) (- (4 * (a * c))))))'
t -: paren '(2*a) %~ (-b) (+,-) (*:b)-4*a*c'

"trace" would be harder to test since it is its output which
is paramount, rather than its result, but you can still test
it to some extent, e.g. you can test that it runs to completion
without error on a phrase.

A couple of utility are useful:

etx=: 1 : 'x. :: (<:@(13!:11)@[EMAIL PROTECTED]: >@{ 9!:[EMAIL PROTECTED]@0:)'
ex =: ". ::(<:@(13!:11)@[EMAIL PROTECTED]: >@{ 9!:[EMAIL PROTECTED]@0:)

With these, you can test that expected errors actually happen:

'length error'      -: 1 2 3 + etx 3 4
'domain error'      -: 3 4 5 + etx '012'
'syntax error'      -: ex '/ 1 2 3'
'assertion failure' -: trace etx '=:'



----- Original Message ----- 
From: "Miller, Raul D" <[EMAIL PROTECTED]>
To: "Beta forum" <[email protected]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, March 26, 2006 7:51 AM
Subject: RE: [Jbeta] RE: [Jgeneral] trace.ijs bug

I've uploaded a patched copy of trace.ijs to the jwiki.

This version works with the current beta.

For now, I've imposed the limitation that sentences are always 
parsed in the base locale (instead of the invoking locale).

http://www.jsoftware.com/jwiki/Scripts/Tracer?action=AttachFile&do=get&t
arget=jtrace.ijs

With this caveat, both the paren and the trace methods work.


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to