Skip to content

Commit e74e48a

Browse files
263 multiple break events from loop and one leading into other (#264)
* 263 - Created test cases for multiple break events from loop and one leads into other * 263 - add end to end test that tests the relevant situation * 263 - update functionality to handle cases with break events heading into other break events * 263 - update tests status * 263 - fix linting errors
1 parent b4b5c83 commit e74e48a

File tree

8 files changed

+310
-64
lines changed

8 files changed

+310
-64
lines changed

docs/development/Current-status.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ The tests are divided into the following categories:
1010
* [Bunched](#bunched)
1111
* [Kill Detach](#kill-detach)
1212

13-
Currently the number of end-to-end tests stands at 70, with 69 passing and 1 failing (98.57% coverage).
13+
Currently the number of end-to-end tests stands at 71, with 70 passing and 1 failing (98.59% coverage).
1414

1515
| filepath | $$\textcolor{#23d18b}{\tt{passed}}$$ | $$\textcolor{#f5f543}{\tt{xfailed}}$$ | SUBTOTAL |
1616
| ---------------------------------------------------------------------------------- | --------------------------------: | --------------------------------: | -------: |
17-
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_branch\\_counts.py}}$$ | $$\textcolor{#23d18b}{\tt{4}}$$ | $$\textcolor{#666666}{\tt{0}}$$ | $$\textcolor{#23d18b}{\tt{4}}$$ |
18-
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{15}}$$ | $$\textcolor{#666666}{\tt{0}}$$ | $$\textcolor{#23d18b}{\tt{15}}$$ |
1917
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/constraints/test\\_constraints\\_bunched.py}}$$ | $$\textcolor{#23d18b}{\tt{21}}$$ | $$\textcolor{#666666}{\tt{0}}$$ | $$\textcolor{#23d18b}{\tt{21}}$$ |
2018
| $$\textcolor{#f5f543}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/constraints/test\\_constraints\\_kill.py}}$$ | $$\textcolor{#23d18b}{\tt{3}}$$ | $$\textcolor{#f5f543}{\tt{1}}$$ | $$\textcolor{#f5f543}{\tt{4}}$$ |
2119
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/constraints/test\\_constraints\\_nested.py}}$$ | $$\textcolor{#23d18b}{\tt{15}}$$ | $$\textcolor{#666666}{\tt{0}}$$ | $$\textcolor{#23d18b}{\tt{15}}$$ |
2220
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/constraints/test\\_constraints\\_simple.py}}$$ | $$\textcolor{#23d18b}{\tt{11}}$$ | $$\textcolor{#666666}{\tt{0}}$$ | $$\textcolor{#23d18b}{\tt{11}}$$ |
23-
| $$\textcolor{#f5f543}{\tt{TOTAL}}$$ | $$\textcolor{#23d18b}{\tt{69}}$$ | $$\textcolor{#f5f543}{\tt{1}}$$ | $$\textcolor{#f5f543}{\tt{70}}$$ |
21+
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_branch\\_counts.py}}$$ | $$\textcolor{#23d18b}{\tt{4}}$$ | $$\textcolor{#666666}{\tt{0}}$$ | $$\textcolor{#23d18b}{\tt{4}}$$ |
22+
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{16}}$$ | $$\textcolor{#666666}{\tt{0}}$$ | $$\textcolor{#23d18b}{\tt{16}}$$ |
23+
| $$\textcolor{#f5f543}{\tt{TOTAL}}$$ | $$\textcolor{#23d18b}{\tt{70}}$$ | $$\textcolor{#f5f543}{\tt{1}}$$ | $$\textcolor{#f5f543}{\tt{71}}$$ |
2424

2525

2626
## Branch counts
@@ -38,7 +38,7 @@ Currently the number of branch tests stands at 4, with 4 passing and 0 failing (
3838

3939
## Loops
4040

41-
Currently the number of loops tests stands at 15, with 15 passing and 0 failing (100.00% coverage).
41+
Currently the number of loops tests stands at 16, with 16 passing and 0 failing (100.00% coverage).
4242

4343
| filepath | function | $$\textcolor{#23d18b}{\tt{passed}}$$ | SUBTOTAL |
4444
| -------------------------------------------------------- | -------------------------------------------------------------------------- | --------------------------------: | -------: |
@@ -54,10 +54,11 @@ Currently the number of loops tests stands at 15, with 15 passing and 0 failing
5454
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{TestBreakPoints.test\\_loop\\_break\\_point}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
5555
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{TestBreakPoints.test\\_loop\\_two\\_break\\_points}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
5656
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{TestBreakPoints.test\\_loop\\_nested\\_break\\_point}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
57+
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{TestBreakPoints.test\\_loop\\_with\\_2\\_breaks\\_one\\_leads\\_to\\_other}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
5758
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{TestEdgeCases.test\\_loop\\_break\\_split\\_exit}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
5859
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{TestEdgeCases.test\\_paths\\_should\\_kill\\_in\\_loop}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
5960
| $$\textcolor{#23d18b}{\tt{tests/tel2puml/pv\\_to\\_puml/end\text{-}to\text{-}end\text{-}tests/test\\_loops.py}}$$ | $$\textcolor{#23d18b}{\tt{TestEdgeCases.test\\_two\\_different\\_loops\\_follow\\_same\\_event}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
60-
| $$\textcolor{#23d18b}{\tt{TOTAL}}$$ | | $$\textcolor{#23d18b}{\tt{15}}$$ | $$\textcolor{#23d18b}{\tt{15}}$$ |
61+
| $$\textcolor{#23d18b}{\tt{TOTAL}}$$ | | $$\textcolor{#23d18b}{\tt{16}}$$ | $$\textcolor{#23d18b}{\tt{16}}$$ |
6162

6263

6364
## Constraints

docs/development/end-to-end-tests/Loops.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ Tests a case where two break points exist in a loop
6969
Tests a case where a break point is within a nested loop[]
7070

7171
![](/end-to-end-pumls/loops/break_points/loop_nested_break_point.svg)
72+
#### Two Break Points In Loop One Leads To The Other
73+
Tests a case where two break points exist in a loop and one leads to the other
74+
75+
![](/end-to-end-pumls/loops/break_points/loop_with_2_breaks_one_leads_to_other.svg)
7276
### Nested Branch Counts
7377
Tests cases where branch counts are nested within loops
7478
#### Nested Branch Count At Start Of Loop
7579
Tests a case where a branch count is nested in a loop, starts the loop and then its children loop back to it again
7680

7781
![](/end-to-end-pumls/loops/nested_branch_counts/loop_nested_branch_counts.svg)
78-
7982
#### Nested Branch Count At End Of Loop
8083
Tests a case where a branch count is nested in a loop, ends the loop and then its children loop back to it again
8184

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@startuml
2+
partition "loop_with_2_breaks_one_leads_to_other" {
3+
group "loop_with_2_breaks_one_leads_to_other"
4+
#green:A;
5+
repeat
6+
:B;
7+
switch (XOR)
8+
case ("")
9+
:E;
10+
:F;
11+
:G;
12+
break
13+
case ("")
14+
:F;
15+
:G;
16+
break
17+
case ("")
18+
:C;
19+
endswitch
20+
repeat while
21+
end group
22+
}
23+
@enduml
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@startuml
2+
partition "loop_with_2_breaks_one_leads_to_other" {
3+
group "loop_with_2_breaks_one_leads_to_other"
4+
#green:A;
5+
repeat
6+
:B;
7+
switch (XOR)
8+
case ("")
9+
:E;
10+
break
11+
case ("")
12+
:F;
13+
break
14+
case ("")
15+
:C;
16+
endswitch
17+
repeat while
18+
switch (XOR)
19+
case ("")
20+
:G;
21+
detach
22+
case ("")
23+
:F;
24+
:G;
25+
detach
26+
endswitch
27+
end group
28+
}
29+
@enduml

tel2puml/loop_detection/calculate_updated_graph.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,33 @@ def calculate_updated_graph_with_loop_event(
5757
)
5858
# remove all loop events
5959
graph.remove_nodes_from(loop.loop_events)
60-
# handle break events without path back to root event
60+
# handle break events without path back to root event or other break events
6161
break_events_without_path_back_to_root = {
6262
event for event in loop.break_events if not has_path(
6363
graph, root_event, event
6464
)
6565
}
66+
break_events_without_path_back_to_root_and_other_break_events = {
67+
break_event_1
68+
for break_event_1 in break_events_without_path_back_to_root
69+
for break_event_2 in loop.break_events
70+
if not has_path(graph, break_event_2, break_event_1)
71+
and break_event_1 != break_event_2
72+
}
6673
update_graph_for_loop_end_events(
67-
break_events_without_path_back_to_root,
68-
loop.loop_events | loop.break_events,
74+
break_events_without_path_back_to_root_and_other_break_events,
75+
loop.loop_events,
6976
loop_event,
7077
graph,
7178
)
7279
# handle break events with path back to root event
7380
break_events_with_path_back_to_root = (
74-
loop.break_events - break_events_without_path_back_to_root
81+
loop.break_events
82+
- break_events_without_path_back_to_root_and_other_break_events
7583
)
7684
update_graph_for_break_events_with_path_to_root_event(
7785
break_events_with_path_back_to_root,
78-
loop.loop_events | loop.break_events,
86+
loop.loop_events,
7987
loop_event,
8088
graph,
8189
)

0 commit comments

Comments
 (0)