Skip to content

Commit

Permalink
Add spec to the result of Coverage lib for begin
Browse files Browse the repository at this point in the history
Ref: jruby/jruby#8173
This commit is intended to make sure `Coverage` library behaves
the same for the code with `begin`. JRuby had an issue so this
change will help JRuby and other implementations to avoid it.
  • Loading branch information
okuramasafumi committed Apr 22, 2024
1 parent 1afa2ea commit b93d02a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions library/coverage/code_with_begin_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require_relative '../../spec_helper'
require 'coverage'

describe 'Coverage for the code with begin' do
before :all do
@file = fixture __FILE__, 'code_with_begin.rb'
end

after :each do
$LOADED_FEATURES.delete(@file)
end

it 'covers 100% lines' do
Coverage.start
require @file.chomp('.rb')
result = Coverage.result

result.should == {
@file => [
nil, 1, nil
]
}
end
end
3 changes: 3 additions & 0 deletions library/coverage/fixtures/code_with_begin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
begin
puts 'begin'
end

0 comments on commit b93d02a

Please sign in to comment.