]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/cfg/loop-detection/loop-detection-tests.factor
Reformat
[factor.git] / basis / compiler / cfg / loop-detection / loop-detection-tests.factor
1 USING: accessors compiler.cfg.loop-detection
2 compiler.cfg.loop-detection.private compiler.cfg.utilities
3 compiler.test kernel namespaces sequences sets tools.test ;
4 IN: compiler.cfg.loop-detection.tests
5
6 { V{ 0 } { 1 } } [
7     V{ } 0 insns>block V{ } 1 insns>block [ connect-bbs ] keep
8     f f <natural-loop> [ process-loop-block ] keep
9     blocks>> members
10     [ [ number>> ] map ] bi@
11 ] unit-test
12
13 ! process-loop-ends
14 { } [
15     f f <natural-loop> process-loop-ends
16 ] unit-test
17
18
19 V{ } 0 test-bb
20 V{ } 1 test-bb
21 V{ } 2 test-bb
22
23 0 { 1 2 } edges
24 2 0 edge
25
26 : test-loop-detection ( -- )
27     0 get block>cfg needs-loops ;
28
29 { } [ test-loop-detection ] unit-test
30
31 { 1 } [ 0 get loop-nesting-at ] unit-test
32 { 0 } [ 1 get loop-nesting-at ] unit-test
33 { 1 } [ 2 get loop-nesting-at ] unit-test