diff options
| -rw-r--r-- | test/ruby/test_backtrace.rb | 22 | ||||
| -rw-r--r-- | version.h | 2 | ||||
| -rw-r--r-- | vm.c | 34 |
3 files changed, 39 insertions, 19 deletions
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb index 91dec4a943..3d2caf4e76 100644 --- a/test/ruby/test_backtrace.rb +++ b/test/ruby/test_backtrace.rb @@ -162,4 +162,26 @@ class TestBacktrace < Test::Unit::TestCase q << true end end + + def test_core_backtrace_alias + obj = BasicObject.new + e = assert_raise(NameError) do + class << obj + alias foo bar + end + end + /`(.*)'\z/.match e.backtrace[0] + assert_not_match(/\Acore#/, $1) + end + + def test_core_backtrace_undef + obj = BasicObject.new + e = assert_raise(NameError) do + class << obj + undef foo + end + end + /`(.*)'\z/.match e.backtrace[0] + assert_not_match(/\Acore#/, $1) + end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-07-07" -#define RUBY_PATCHLEVEL 520 +#define RUBY_PATCHLEVEL 521 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 @@ -2137,46 +2137,44 @@ m_core_set_postexe(VALUE self, VALUE iseqval) return Qnil; } +static VALUE m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary); + +static VALUE +core_hash_merge(VALUE hash, long argc, const VALUE *argv) +{ + long i; + assert(argc % 2 == 0); + for (i=0; i<argc; i+=2) { + rb_hash_aset(hash, argv[i], argv[i+1]); + } + return hash; +} + static VALUE m_core_hash_from_ary(VALUE self, VALUE ary) { VALUE hash = rb_hash_new(); - int i; if (RUBY_DTRACE_HASH_CREATE_ENABLED()) { RUBY_DTRACE_HASH_CREATE(RARRAY_LEN(ary), rb_sourcefile(), rb_sourceline()); } - assert(RARRAY_LEN(ary) % 2 == 0); - for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_hash_aset(hash, RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]); - } - - return hash; + return m_core_hash_merge_ary(self, hash, ary); } static VALUE m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary) { - int i; - - assert(RARRAY_LEN(ary) % 2 == 0); - for (i=0; i<RARRAY_LEN(ary); i+=2) { - rb_hash_aset(hash, RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]); - } - + core_hash_merge(hash, RARRAY_LEN(ary), RARRAY_PTR(ary)); return hash; } static VALUE m_core_hash_merge_ptr(int argc, VALUE *argv, VALUE recv) { - int i; VALUE hash = argv[0]; - for (i=1; i<argc; i+=2) { - rb_hash_aset(hash, argv[i], argv[i+1]); - } + core_hash_merge(hash, argc-1, argv+1); return hash; } |
