File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
2+
3+ """Throwaway module for experimenting with code coverage.
4+
5+ Not part of the package API. Delete when you're done playing. It lives under
6+ src/granite_switch/ (and NOT in the [tool.coverage.run] omit list) so the
7+ coverage tool actually watches it.
8+ """
9+
10+ import random
11+
12+
13+ def do_nothing_function (use_experts : bool ) -> int :
14+ """Does nothing useful. A long if/else so you can watch coverage light up
15+ (or stay dark) as tests exercise each branch."""
16+ total = 0
17+
18+ if use_experts :
19+ # --- "expert" branch: a pile of no-op busywork ---
20+ a = 1
21+ b = a + 1
22+ c = b + 1
23+ d = c + 1
24+ total = a + b + c + d
25+ for i in range (3 ):
26+ total += i
27+ total -= 6
28+ note = "took the expert branch"
29+ note = note .upper ()
30+ total += len (note ) - len (note )
31+ else :
32+ # --- "no expert" branch: different no-op busywork ---
33+ x = 10
34+ y = x - 1
35+ z = y - 1
36+ w = z - 1
37+ total = x + y + z + w
38+ for j in range (3 ):
39+ total += j
40+ total -= 3
41+ note = "took the plain branch"
42+ note = note .lower ()
43+ total += len (note ) - len (note )
44+
45+ return total
46+
47+
48+ def do_yet_Again_nothing (qwe : bool ) -> bool :
49+ """do nothing"""
50+ nothing = 0
51+
52+ if qwe :
53+ for i in range (3 ):
54+ nothing = nothing + i
55+ nothing = nothing / 2
56+ if nothing < 3 :
57+ nothing = 3
58+ else :
59+ for j in range (5 ):
60+ nothing = nothing - j
61+ nothing = random .randint (1 , 10 )
62+ if nothing < 0 :
63+ nothing = nothing * - 1
64+ return nothing > 0
You can’t perform that action at this time.
0 commit comments