From 57eee0368d2acc7cfcea37dd6a1968a3dd2c2bb5 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Tue, 25 May 2021 21:16:55 +0200 Subject: [PATCH] Add CFG tests for compound assignments --- .../controlflow/graph/Cfg.expected | 187 +++++++++++++----- .../controlflow/graph/desugar.rb | 8 + 2 files changed, 147 insertions(+), 48 deletions(-) diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index c87790abbce..0bc9ee491fb 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -2254,7 +2254,7 @@ desugar.rb: #-----| -> x # 17| m5 -#-----| -> @x +#-----| -> m6 # 17| exit m5 @@ -2369,79 +2369,170 @@ desugar.rb: # 18| 1 #-----| -> ... + ... -# 21| X -#-----| -> $global_var +# 21| enter m6 +#-----| -> x + +# 21| m6 +#-----| -> m7 + +# 21| exit m6 + +# 21| exit m6 (normal) +#-----| -> exit m6 # 22| ... = ... -#-----| -> @x +#-----| -> exit m6 (normal) -# 22| @x +# 22| (..., ...) #-----| -> 1 -# 22| 1 +# 22| x +#-----| -> y + +# 22| y +#-----| -> self + +# 22| call to bar +#-----| -> (..., ...) + +# 22| call to z +#-----| -> call to bar + +# 22| self +#-----| -> call to z + +# 22| [...] #-----| -> ... = ... -# 23| @x -#-----| -> @x - -# 23| ... = ... -#-----| -> @@y - -# 23| @x +# 22| 1 #-----| -> 2 -# 23| ... + ... -#-----| -> ... = ... - -# 23| 2 -#-----| -> ... + ... - -# 25| ... = ... -#-----| -> @@y - -# 25| @@y +# 22| 2 #-----| -> 3 -# 25| 3 -#-----| -> ... = ... - -# 26| @@y -#-----| -> @@y - -# 26| ... = ... -#-----| -> X - -# 26| @@y +# 22| 3 #-----| -> 4 -# 26| ... / ... +# 22| 4 +#-----| -> [...] + +# 25| enter m7 +#-----| -> x + +# 25| m7 +#-----| -> @x + +# 25| exit m7 + +# 25| exit m7 (normal) +#-----| -> exit m7 + +# 26| ... = ... +#-----| -> exit m7 (normal) + +# 26| (..., ...) +#-----| -> 1 + +# 26| x +#-----| -> y + +# 26| (..., ...) +#-----| -> (..., ...) + +# 26| y +#-----| -> z + +# 26| z +#-----| -> (..., ...) + +# 26| [...] #-----| -> ... = ... -# 26| 4 -#-----| -> ... / ... +# 26| 1 +#-----| -> 2 -# 29| ... = ... -#-----| -> $global_var +# 26| [...] +#-----| -> [...] -# 29| $global_var -#-----| -> 5 +# 26| 2 +#-----| -> 3 -# 29| 5 -#-----| -> ... = ... +# 26| 3 +#-----| -> [...] -# 30| $global_var +# 29| X #-----| -> $global_var # 30| ... = ... -#-----| -> exit desugar.rb (normal) +#-----| -> @x -# 30| $global_var -#-----| -> 6 +# 30| @x +#-----| -> 1 -# 30| ... * ... +# 30| 1 #-----| -> ... = ... -# 30| 6 +# 31| @x +#-----| -> @x + +# 31| ... = ... +#-----| -> @@y + +# 31| @x +#-----| -> 2 + +# 31| ... + ... +#-----| -> ... = ... + +# 31| 2 +#-----| -> ... + ... + +# 33| ... = ... +#-----| -> @@y + +# 33| @@y +#-----| -> 3 + +# 33| 3 +#-----| -> ... = ... + +# 34| @@y +#-----| -> @@y + +# 34| ... = ... +#-----| -> X + +# 34| @@y +#-----| -> 4 + +# 34| ... / ... +#-----| -> ... = ... + +# 34| 4 +#-----| -> ... / ... + +# 37| ... = ... +#-----| -> $global_var + +# 37| $global_var +#-----| -> 5 + +# 37| 5 +#-----| -> ... = ... + +# 38| $global_var +#-----| -> $global_var + +# 38| ... = ... +#-----| -> exit desugar.rb (normal) + +# 38| $global_var +#-----| -> 6 + +# 38| ... * ... +#-----| -> ... = ... + +# 38| 6 #-----| -> ... * ... exit.rb: diff --git a/ql/test/library-tests/controlflow/graph/desugar.rb b/ql/test/library-tests/controlflow/graph/desugar.rb index 95b1bba99e9..68b36508d33 100644 --- a/ql/test/library-tests/controlflow/graph/desugar.rb +++ b/ql/test/library-tests/controlflow/graph/desugar.rb @@ -18,6 +18,14 @@ def m5 x, y x.foo[0, y.bar, x.baz + 3] += 1 end +def m6 + x, *y, z.bar = [1, 2, 3, 4] +end + +def m7 + x, (y, z) = [1, [2, 3]] +end + class X @x = 1 @x += 2