diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-24 23:17:59 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-24 23:17:59 +0000 |
commit | 2eadff346a96ccb756bd8949298a48e709edbe4f (patch) | |
tree | 543628436bd619117505cd9d05192a21ccee7bcc | |
parent | 418bbce88a77599672a5851f63245a4723a8a608 (diff) | |
download | ruby-2eadff346a96ccb756bd8949298a48e709edbe4f.tar.gz |
* iseq.c (rb_iseq_defined_string): the index of defined_strings must
be the value of type - 1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | iseq.c | 4 | ||||
-rw-r--r-- | test/ruby/test_defined.rb | 5 |
3 files changed, 12 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Tue Sep 25 08:11:11 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * iseq.c (rb_iseq_defined_string): the index of defined_strings must + be the value of type - 1. + Mon Sep 24 17:36:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * compile.c (defined_expr), insns.def (defined): share single frozen @@ -1779,11 +1779,11 @@ rb_iseq_defined_string(enum defined_type type) defs = ruby_xcalloc(numberof(expr_names), sizeof(VALUE)); GET_VM()->defined_strings = defs; } - str = defs[type]; + str = defs[type-1]; if (!str) { str = rb_str_new_cstr(estr);; OBJ_FREEZE(str); - defs[type] = str; + defs[type-1] = str; } return str; } diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index ec37488c81..fe985340c1 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -84,6 +84,11 @@ class TestDefined < Test::Unit::TestCase assert_equal 'global-variable', defined?($+) assert_equal 'global-variable', defined?($1) assert_equal nil, defined?($2) + + assert_equal("nil", defined?(nil)) + assert_equal("true", defined?(true)) + assert_equal("false", defined?(false)) + assert_equal("expression", defined?(1)) end def test_defined_impl_specific |