From 9871698cee75b9b86864f5dbd39db0ce9e0fd49a Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Tue, 18 May 2021 20:23:48 +0200 Subject: [PATCH] Add more CFG tests --- .../controlflow/graph/Cfg.expected | 104 +++++++++++++++++- .../library-tests/controlflow/graph/raise.rb | 14 +++ 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index c4cb7e4a166..37ae08e9dbc 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -3173,6 +3173,9 @@ raise.rb: # 1| exit raise.rb +# 1| exit raise.rb (abnormal) +#-----| -> exit raise.rb + # 1| exit raise.rb (normal) #-----| -> exit raise.rb @@ -4253,7 +4256,7 @@ raise.rb: #-----| -> element # 154| m14 -#-----| -> exit raise.rb (normal) +#-----| -> m15 # 154| exit m14 @@ -4304,3 +4307,102 @@ raise.rb: # 155| element #-----| -> call to nil? + +# 158| enter m15 +#-----| -> self + +# 158| m15 +#-----| -> self + +# 158| exit m15 + +# 158| exit m15 (normal) +#-----| -> exit m15 + +# 159| call to foo +#-----| -> exit m15 (normal) + +# 159| self +#-----| -> do ... end + +# 159| enter do ... end +#-----| -> self + +# 159| do ... end +#-----| -> call to foo + +# 159| exit do ... end + +# 159| exit do ... end (abnormal) +#-----| -> exit do ... end + +# 159| exit do ... end (normal) +#-----| -> exit do ... end + +# 160| call to bar +#-----| -> exit do ... end (normal) + +# 160| self +#-----| -> -> { ... } + +# 160| enter -> { ... } +#-----| -> x + +# 160| -> { ... } +#-----| -> call to bar + +# 160| exit -> { ... } + +# 160| exit -> { ... } (abnormal) +#-----| -> exit -> { ... } + +# 160| exit -> { ... } (normal) +#-----| -> exit -> { ... } + +# 160| x +#-----| -> x + +# 161| call to raise +#-----| raise -> exit do ... end (abnormal) +#-----| raise -> exit -> { ... } (abnormal) + +# 161| ... unless ... +#-----| -> exit -> { ... } (normal) + +# 161| self +#-----| -> "" + +# 161| "" +#-----| -> call to raise + +# 161| x +#-----| true -> ... unless ... +#-----| false -> self + +# 166| C +#-----| -> exit raise.rb (normal) + +# 167| enter m +#-----| -> self + +# 167| m +#-----| -> C + +# 167| exit m + +# 167| exit m (abnormal) +#-----| -> exit m + +# 167| self +#-----| -> m + +# 168| call to raise +#-----| raise -> C +#-----| raise -> exit m (abnormal) +#-----| raise -> exit raise.rb (abnormal) + +# 168| self +#-----| -> "" + +# 168| "" +#-----| -> call to raise diff --git a/ql/test/library-tests/controlflow/graph/raise.rb b/ql/test/library-tests/controlflow/graph/raise.rb index f4e24402649..e5f0c0e50f5 100644 --- a/ql/test/library-tests/controlflow/graph/raise.rb +++ b/ql/test/library-tests/controlflow/graph/raise.rb @@ -154,3 +154,17 @@ end def m14 element element.each { |elem| raise "" if element.nil? } end + +def m15 + foo do + bar ->(x) do + raise "" unless x + end + end +end + +class C + def self.m() + raise "" + end +end