factor/basis/compiler/tests/stack-trace.factor

33 lines
798 B
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
USING: compiler tools.test namespaces sequences
kernel.private kernel math continuations continuations.private
2008-09-02 02:53:01 -04:00
words splitting grouping sorting accessors ;
IN: compiler.tests.stack-trace
2007-09-20 18:09:08 -04:00
: symbolic-stack-trace ( -- newseq )
2008-09-02 02:53:01 -04:00
error-continuation get call>> callstack>array
3 group flip first ;
2007-09-20 18:09:08 -04:00
2008-06-08 16:32:55 -04:00
: foo ( -- * ) 3 throw 7 ;
: bar ( -- * ) foo 4 ;
: baz ( -- * ) bar 5 ;
[ baz ] [ 3 = ] must-fail-with
2007-09-28 00:26:58 -04:00
[ t ] [
symbolic-stack-trace
2009-08-18 04:49:05 -04:00
2 head*
2009-03-18 18:01:26 -04:00
{ baz bar foo } tail?
2007-09-20 18:09:08 -04:00
] unit-test
2008-06-08 16:32:55 -04:00
: bleh ( seq -- seq' ) [ 3 + ] map [ 0 > ] filter ;
2007-09-20 18:09:08 -04:00
: stack-trace-any? ( word -- ? ) symbolic-stack-trace member-eq? ;
2007-09-28 00:26:58 -04:00
2007-09-20 18:09:08 -04:00
[ t ] [
[ { 1 "hi" } bleh ] ignore-errors \ + stack-trace-any?
2007-09-20 18:09:08 -04:00
] unit-test
2009-08-18 04:49:05 -04:00
[ t f ] [
[ { "hi" } bleh ] ignore-errors
\ + stack-trace-any?
\ > stack-trace-any?
2007-09-20 18:09:08 -04:00
] unit-test