renaming: contain? -> any?, deep-contains? -> deep-any?, pad-left -> pad-head, pad...
[factor/jcg.git] / basis / compiler / tests / stack-trace.factor
blobcfbea3bcb92c9e060e932876a86cdf1faa47f2cb
1 IN: compiler.tests
2 USING: compiler tools.test namespaces sequences
3 kernel.private kernel math continuations continuations.private
4 words splitting grouping sorting accessors ;
6 : symbolic-stack-trace ( -- newseq )
7     error-continuation get call>> callstack>array
8     2 group flip first ;
10 : foo ( -- * ) 3 throw 7 ;
11 : bar ( -- * ) foo 4 ;
12 : baz ( -- * ) bar 5 ;
13 [ baz ] [ 3 = ] must-fail-with
14 [ t ] [
15     symbolic-stack-trace
16     [ word? ] filter
17     { baz bar foo throw } tail?
18 ] unit-test
20 : bleh ( seq -- seq' ) [ 3 + ] map [ 0 > ] filter ;
22 : stack-trace-any? ( word -- ? ) symbolic-stack-trace memq? ;
24 [ t ] [
25     [ { 1 "hi" } bleh ] ignore-errors \ + stack-trace-any?
26 ] unit-test
27     
28 [ t f ] [
29     [ { "hi" } bleh ] ignore-errors
30     \ + stack-trace-any?
31     \ > stack-trace-any?
32 ] unit-test