factor/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor

40 lines
1.2 KiB
Factor
Raw Normal View History

2008-08-08 14:14:36 -04:00
IN: compiler.tree.tuple-unboxing.tests
2008-08-10 00:00:27 -04:00
USING: tools.test compiler.tree.tuple-unboxing compiler.tree
compiler.tree.builder compiler.tree.normalization
2008-08-08 14:14:36 -04:00
compiler.tree.propagation compiler.tree.cleanup
compiler.tree.escape-analysis compiler.tree.tuple-unboxing
2008-08-10 00:00:27 -04:00
compiler.tree.checker compiler.tree.def-use kernel accessors
sequences math math.private sorting math.order binary-search
sequences.private slots.private ;
2008-08-08 14:14:36 -04:00
\ unbox-tuples must-infer
: test-unboxing ( quot -- )
build-tree
normalize
propagate
cleanup
escape-analysis
unbox-tuples
2008-08-10 00:00:27 -04:00
check-nodes ;
2008-08-08 14:14:36 -04:00
TUPLE: cons { car read-only } { cdr read-only } ;
TUPLE: empty-tuple ;
{
2008-08-08 17:04:33 -04:00
[ 1 2 cons boa [ car>> ] [ cdr>> ] bi ]
2008-08-08 14:14:36 -04:00
[ empty-tuple boa drop ]
[ cons boa [ car>> ] [ cdr>> ] bi ]
[ [ 1 cons boa ] [ 2 cons boa ] if car>> ]
[ dup cons boa 10 [ nip dup cons boa ] each-integer car>> ]
2008-08-10 00:00:27 -04:00
[ 2 cons boa { [ ] [ ] } dispatch ]
[ dup [ drop f ] [ "A" throw ] if ]
[ [ ] [ ] curry curry dup 3 slot swap 4 slot dup 3 slot swap 4 slot drop ]
[ [ ] [ ] curry curry call ]
[ <complex> <complex> dup 1 slot drop 2 slot drop ]
[ 1 cons boa over [ "A" throw ] when car>> ]
2008-08-08 17:04:33 -04:00
[ [ <=> ] sort ]
[ [ <=> ] with search ]
2008-08-08 14:14:36 -04:00
} [ [ ] swap [ test-unboxing ] curry unit-test ] each