Skip to content

Commit 57eee03

Browse files
committed
Add CFG tests for compound assignments
1 parent dfcf4c9 commit 57eee03

2 files changed

Lines changed: 125 additions & 26 deletions

File tree

ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 117 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,7 @@ desugar.rb:
22542254
#-----| -> x
22552255

22562256
# 17| m5
2257-
#-----| -> @x
2257+
#-----| -> m6
22582258

22592259
# 17| exit m5
22602260

@@ -2369,79 +2369,170 @@ desugar.rb:
23692369
# 18| 1
23702370
#-----| -> ... + ...
23712371

2372-
# 21| X
2373-
#-----| -> $global_var
2372+
# 21| enter m6
2373+
#-----| -> x
2374+
2375+
# 21| m6
2376+
#-----| -> m7
2377+
2378+
# 21| exit m6
2379+
2380+
# 21| exit m6 (normal)
2381+
#-----| -> exit m6
23742382

23752383
# 22| ... = ...
2376-
#-----| -> @x
2384+
#-----| -> exit m6 (normal)
23772385

2378-
# 22| @x
2386+
# 22| (..., ...)
23792387
#-----| -> 1
23802388

2389+
# 22| x
2390+
#-----| -> y
2391+
2392+
# 22| y
2393+
#-----| -> self
2394+
2395+
# 22| call to bar
2396+
#-----| -> (..., ...)
2397+
2398+
# 22| call to z
2399+
#-----| -> call to bar
2400+
2401+
# 22| self
2402+
#-----| -> call to z
2403+
2404+
# 22| [...]
2405+
#-----| -> ... = ...
2406+
23812407
# 22| 1
2408+
#-----| -> 2
2409+
2410+
# 22| 2
2411+
#-----| -> 3
2412+
2413+
# 22| 3
2414+
#-----| -> 4
2415+
2416+
# 22| 4
2417+
#-----| -> [...]
2418+
2419+
# 25| enter m7
2420+
#-----| -> x
2421+
2422+
# 25| m7
2423+
#-----| -> @x
2424+
2425+
# 25| exit m7
2426+
2427+
# 25| exit m7 (normal)
2428+
#-----| -> exit m7
2429+
2430+
# 26| ... = ...
2431+
#-----| -> exit m7 (normal)
2432+
2433+
# 26| (..., ...)
2434+
#-----| -> 1
2435+
2436+
# 26| x
2437+
#-----| -> y
2438+
2439+
# 26| (..., ...)
2440+
#-----| -> (..., ...)
2441+
2442+
# 26| y
2443+
#-----| -> z
2444+
2445+
# 26| z
2446+
#-----| -> (..., ...)
2447+
2448+
# 26| [...]
23822449
#-----| -> ... = ...
23832450

2384-
# 23| @x
2451+
# 26| 1
2452+
#-----| -> 2
2453+
2454+
# 26| [...]
2455+
#-----| -> [...]
2456+
2457+
# 26| 2
2458+
#-----| -> 3
2459+
2460+
# 26| 3
2461+
#-----| -> [...]
2462+
2463+
# 29| X
2464+
#-----| -> $global_var
2465+
2466+
# 30| ... = ...
2467+
#-----| -> @x
2468+
2469+
# 30| @x
2470+
#-----| -> 1
2471+
2472+
# 30| 1
2473+
#-----| -> ... = ...
2474+
2475+
# 31| @x
23852476
#-----| -> @x
23862477

2387-
# 23| ... = ...
2478+
# 31| ... = ...
23882479
#-----| -> @@y
23892480

2390-
# 23| @x
2481+
# 31| @x
23912482
#-----| -> 2
23922483

2393-
# 23| ... + ...
2484+
# 31| ... + ...
23942485
#-----| -> ... = ...
23952486

2396-
# 23| 2
2487+
# 31| 2
23972488
#-----| -> ... + ...
23982489

2399-
# 25| ... = ...
2490+
# 33| ... = ...
24002491
#-----| -> @@y
24012492

2402-
# 25| @@y
2493+
# 33| @@y
24032494
#-----| -> 3
24042495

2405-
# 25| 3
2496+
# 33| 3
24062497
#-----| -> ... = ...
24072498

2408-
# 26| @@y
2499+
# 34| @@y
24092500
#-----| -> @@y
24102501

2411-
# 26| ... = ...
2502+
# 34| ... = ...
24122503
#-----| -> X
24132504

2414-
# 26| @@y
2505+
# 34| @@y
24152506
#-----| -> 4
24162507

2417-
# 26| ... / ...
2508+
# 34| ... / ...
24182509
#-----| -> ... = ...
24192510

2420-
# 26| 4
2511+
# 34| 4
24212512
#-----| -> ... / ...
24222513

2423-
# 29| ... = ...
2514+
# 37| ... = ...
24242515
#-----| -> $global_var
24252516

2426-
# 29| $global_var
2517+
# 37| $global_var
24272518
#-----| -> 5
24282519

2429-
# 29| 5
2520+
# 37| 5
24302521
#-----| -> ... = ...
24312522

2432-
# 30| $global_var
2523+
# 38| $global_var
24332524
#-----| -> $global_var
24342525

2435-
# 30| ... = ...
2526+
# 38| ... = ...
24362527
#-----| -> exit desugar.rb (normal)
24372528

2438-
# 30| $global_var
2529+
# 38| $global_var
24392530
#-----| -> 6
24402531

2441-
# 30| ... * ...
2532+
# 38| ... * ...
24422533
#-----| -> ... = ...
24432534

2444-
# 30| 6
2535+
# 38| 6
24452536
#-----| -> ... * ...
24462537

24472538
exit.rb:

ql/test/library-tests/controlflow/graph/desugar.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def m5 x, y
1818
x.foo[0, y.bar, x.baz + 3] += 1
1919
end
2020

21+
def m6
22+
x, *y, z.bar = [1, 2, 3, 4]
23+
end
24+
25+
def m7
26+
x, (y, z) = [1, [2, 3]]
27+
end
28+
2129
class X
2230
@x = 1
2331
@x += 2

0 commit comments

Comments
 (0)