Skip to content

Commit

Permalink
TMP<
Browse files Browse the repository at this point in the history
  • Loading branch information
Morriar committed Aug 20, 2024
1 parent 3cebc30 commit bf94b90
Show file tree
Hide file tree
Showing 55 changed files with 31 additions and 21 deletions.
3 changes: 3 additions & 0 deletions lib/spoom/cfg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ def visit_or_node(node)

sig { override.params(node: Prism::RescueNode).void }
def visit_rescue_node(node)
puts node.inspect
visit_all(node.exceptions)
visit(node.reference)
visit(node.statements)
end

Expand Down
2 changes: 1 addition & 1 deletion sorbet/config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.
--ignore=vendor/
--ignore=test/spoom/cfg/
--ignore=test/spoom/cfg/fixtures
--enable-experimental-requires-ancestor
18 changes: 2 additions & 16 deletions test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
# frozen_string_literal: true

begin
x = 1
puts "inside"
if foo?
return
puts "dead"
else
return
puts "dead"
end

puts "dead"
rescue
puts x
puts "rescue"
return
puts "dead"
rescue MyException.new.class => e
puts e
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions test/spoom/cfg/fixtures/begin_rescue_args.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cfg: <main>

bb#0
-> bb#3
-> bb#1

bb#3
MyException.new.class()
e
<self>.puts(e)
-> bb#1

bb#1
4 changes: 4 additions & 0 deletions test/spoom/cfg/fixtures/begin_rescue_args.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
begin
rescue MyException.new.class => e
puts e
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 8 additions & 4 deletions test/spoom/cfg/fixtures_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class CFGFixturesTest < Minitest::Test
test_name = "test_#{name}"

define_method(test_name) do
expected_path = File.join(dir, "#{name}.cfg.exp")
assert(File.exist?(expected_path), "expectation file missing for #{file}")
expected_output = File.read(expected_path)
T.bind(self, Minitest::Test)

node = Spoom.parse_ruby(File.read(file), file: file)
cfgs_cluster = Spoom::CFG.from_node(node)
Expand All @@ -31,7 +29,13 @@ class CFGFixturesTest < Minitest::Test
puts
puts actual_output
cfgs_cluster.show_dot
elsif ENV["CFG_UPDATE_FIXTURES"]
end

expected_path = File.join(dir, "#{name}.cfg")
assert(File.exist?(expected_path), "expectation file missing for #{file}")
expected_output = File.read(expected_path)

if ENV["CFG_UPDATE_FIXTURES"]
File.write(expected_path, actual_output)
else
unless expected_output == actual_output
Expand Down

0 comments on commit bf94b90

Please sign in to comment.