@@ -50,6 +50,38 @@ func TestEmitAnchorAnnotation_FromAndTo(t *testing.T) {
5050 }
5151}
5252
53+ func TestEmitAnchorAnnotation_OmitsDefaultRightToLeft (t * testing.T ) {
54+ activity := & microflows.ActionActivity {
55+ BaseActivity : microflows.BaseActivity {
56+ BaseMicroflowObject : microflows.BaseMicroflowObject {
57+ BaseElement : model.BaseElement {ID : "act-default" },
58+ },
59+ },
60+ }
61+ incoming := & microflows.SequenceFlow {
62+ DestinationID : "act-default" ,
63+ DestinationConnectionIndex : AnchorLeft ,
64+ }
65+ outgoing := & microflows.SequenceFlow {
66+ OriginID : "act-default" ,
67+ OriginConnectionIndex : AnchorRight ,
68+ }
69+
70+ flowsByOrigin := map [model.ID ][]* microflows.SequenceFlow {
71+ "act-default" : {outgoing },
72+ }
73+ flowsByDest := map [model.ID ][]* microflows.SequenceFlow {
74+ "act-default" : {incoming },
75+ }
76+
77+ var lines []string
78+ emitAnchorAnnotation (activity , flowsByOrigin , flowsByDest , & lines , "" )
79+
80+ if len (lines ) != 0 {
81+ t .Fatalf ("expected default anchor line to be omitted, got %v" , lines )
82+ }
83+ }
84+
5385func TestEmitAnchorAnnotation_NoFlowsSkipsEmission (t * testing.T ) {
5486 activity := & microflows.ActionActivity {
5587 BaseActivity : microflows.BaseActivity {
@@ -66,6 +98,53 @@ func TestEmitAnchorAnnotation_NoFlowsSkipsEmission(t *testing.T) {
6698 }
6799}
68100
101+ func TestEmitAnchorAnnotation_IgnoresLoopBodyTailOutgoingFlow (t * testing.T ) {
102+ activity := & microflows.ActionActivity {
103+ BaseActivity : microflows.BaseActivity {
104+ BaseMicroflowObject : microflows.BaseMicroflowObject {
105+ BaseElement : model.BaseElement {ID : "body-act" },
106+ },
107+ },
108+ }
109+ loop := & microflows.LoopedActivity {
110+ BaseMicroflowObject : microflows.BaseMicroflowObject {
111+ BaseElement : model.BaseElement {ID : "loop-1" },
112+ },
113+ ObjectCollection : & microflows.MicroflowObjectCollection {
114+ Objects : []microflows.MicroflowObject {activity },
115+ },
116+ }
117+
118+ flowsByOrigin := map [model.ID ][]* microflows.SequenceFlow {
119+ "body-act" : {
120+ {
121+ OriginID : "body-act" ,
122+ DestinationID : "loop-1" ,
123+ OriginConnectionIndex : AnchorLeft ,
124+ },
125+ },
126+ }
127+ flowsByDest := map [model.ID ][]* microflows.SequenceFlow {
128+ "body-act" : {
129+ {
130+ DestinationID : "body-act" ,
131+ DestinationConnectionIndex : AnchorLeft ,
132+ },
133+ },
134+ }
135+ activityMap := map [model.ID ]microflows.MicroflowObject {
136+ "body-act" : activity ,
137+ "loop-1" : loop ,
138+ }
139+
140+ var lines []string
141+ emitAnchorAnnotationWithActivityMap (activity , flowsByOrigin , flowsByDest , activityMap , & lines , "" )
142+
143+ if len (lines ) != 0 {
144+ t .Fatalf ("expected loop body tail flow to be ignored, got %v" , lines )
145+ }
146+ }
147+
69148func TestAnchorRoundtripViaParserBuilder (t * testing.T ) {
70149 // Build an AST with an @anchor on a statement, run it through the builder,
71150 // and verify the resulting SequenceFlow has the right anchors. Then the
0 commit comments