I'm porting the QuickCheck unit test framework to Factor. The idea is to
test properties (quotations) against test values.
For example, to test whether all integers have the property even:
[ even? ] { gen-integer } for-all
The property is a quotation because isn't evaluated directly but passed
values from gen-integer.
for-all will test properties with different types and numbers of arguments,
that's why gen-integer is inside a sequence.
So for-all's type hint should be something like
: for-all ( quot seq -- ? )
! ...
;
And gen-integer's type hint would be something like
: gen-integer ( -- quot | quot: -- n )
! ...
;
I'm getting an error, though. Factor doesn't like my type hint for
gen-integer.
$ ./example.factor
Loading /Users/andrew/.factor-rc
./example.factor
3: INCLUDING: factcheck ;
^
factcheck.factor
5: : gen-integer ( -- quot | quot: -- n ) [ random-32 ] ;
^
No word named “--” found in current vocabulary search path
In
factcheck.factor<https://github.com/mcandre/factcheck/blob/master/factcheck.factor>
:
! A quotation generating a random integer.
: gen-integer ( -- quot | quot: -- n ) [ random-32 ] ;
In
example.factor<https://github.com/mcandre/factcheck/blob/master/example.factor>
:
#! /usr/bin/env factor
INCLUDING: factcheck ;
USING: math prettyprint ;
IN: example
: main ( -- )
gen-integer apply .
Am I not using the pipe (|) correctly in the type hint?
Cheers,
Andrew Pennebaker
www.yellosoft.us
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk