1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* iseq.c (iseq_data_to_ary): fix condition.

r34303 introduces a bug to avoid all line information from
  a result of ISeq#to_a. This is a regression problem from 2.0.0p0.
* test/ruby/test_iseq.rb: add a test of lines after ISeq#to_a.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-02-28 11:26:23 +00:00
parent 731acc0950
commit b0690af9a4
3 changed files with 21 additions and 1 deletions

View file

@ -1,3 +1,11 @@
Thu Feb 28 20:22:04 2013 Koichi Sasada <ko1@atdot.net>
* iseq.c (iseq_data_to_ary): fix condition.
r34303 introduces a bug to avoid all line information from
a result of ISeq#to_a. This is a regression problem from 2.0.0p0.
* test/ruby/test_iseq.rb: add a test of lines after ISeq#to_a.
Thu Feb 28 08:20:33 2013 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/available_set.rb: Undent for style

2
iseq.c
View file

@ -1841,7 +1841,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
rb_ary_push(body, (VALUE)label);
}
if (iseq->line_info_size < ti && iseq->line_info_table[ti].position == pos) {
if (ti < iseq->line_info_size && iseq->line_info_table[ti].position == pos) {
line = iseq->line_info_table[ti].line_no;
rb_ary_push(body, INT2FIX(line));
ti++;

View file

@ -9,6 +9,18 @@ class TestISeq < Test::Unit::TestCase
assert_normal_exit('p RubyVM::InstructionSequence.compile("1", "mac", "", 0).to_a', bug5894)
end
def test_to_a_lines
src = <<-EOS
p __LINE__ # 1
p __LINE__ # 2
# 3
p __LINE__ # 4
EOS
body = RubyVM::InstructionSequence.new(src).to_a[13]
lines = body.find_all{|e| e.kind_of? Fixnum}
assert_equal [1, 2, 4], lines
end
def test_unsupport_type
ary = RubyVM::InstructionSequence.compile("p").to_a
ary[9] = :foobar