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

40 lines
879 B
Factor
Raw Normal View History

2008-03-01 17:00:45 -05:00
IN: compiler.tests
2007-09-20 18:09:08 -04:00
USING: compiler tools.test namespaces sequences
kernel.private kernel math continuations continuations.private
2008-02-13 14:31:43 -05:00
words splitting sorting ;
2007-09-20 18:09:08 -04:00
: symbolic-stack-trace ( -- newseq )
2007-09-28 00:26:58 -04:00
error-continuation get continuation-call callstack>array
2 group flip first ;
2007-09-20 18:09:08 -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
[ word? ] subset
{ baz bar foo throw } tail?
2007-09-20 18:09:08 -04:00
] unit-test
: bleh [ 3 + ] map [ 0 > ] subset ;
: stack-trace-contains? symbolic-stack-trace memq? ;
2007-09-28 00:26:58 -04:00
2007-09-20 18:09:08 -04:00
[ t ] [
[ { 1 "hi" } bleh ] ignore-errors \ + stack-trace-contains?
2007-09-20 18:09:08 -04:00
] unit-test
[ t f ] [
[ { "hi" } bleh ] ignore-errors
2007-09-20 18:09:08 -04:00
\ + stack-trace-contains?
\ > stack-trace-contains?
] unit-test
2008-02-13 14:31:43 -05:00
: quux { 1 2 3 } [ "hi" throw ] sort ;
2007-09-20 18:09:08 -04:00
[ t ] [
[ 10 quux ] ignore-errors
2008-02-13 14:31:43 -05:00
\ sort stack-trace-contains?
2007-09-20 18:09:08 -04:00
] unit-test