summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPavel <[email protected]>2014-02-09 23:51:51 +0700
committerPavel <[email protected]>2014-02-09 23:54:49 +0700
commit411168deab5f3fa3cff5c204db0758c482d206ea (patch)
treecdfa40ddea3eea20ee9abea6fc5f37133b01e12d
parent00bdaec7668b14eb4efe6c2e47b6d4e38f15e385 (diff)
downloadmruby-411168deab5f3fa3cff5c204db0758c482d206ea.tar.gz
mruby-411168deab5f3fa3cff5c204db0758c482d206ea.zip
Fix Kernel#global_variables for $1-$9
-rw-r--r--src/variable.c2
-rw-r--r--test/t/kernel.rb9
2 files changed, 9 insertions, 2 deletions
diff --git a/src/variable.c b/src/variable.c
index 5ced2dfbd..de56c3ce6 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1052,7 +1052,7 @@ mrb_f_global_variables(mrb_state *mrb, mrb_value self)
buf[2] = 0;
for (i = 1; i <= 9; ++i) {
buf[1] = (char)(i + '0');
- mrb_ary_push(mrb, ary, mrb_symbol_value(mrb_intern_lit(mrb, buf)));
+ mrb_ary_push(mrb, ary, mrb_symbol_value(mrb_intern(mrb, buf, 2)));
}
return ary;
}
diff --git a/test/t/kernel.rb b/test/t/kernel.rb
index e7c9c2635..2d409940b 100644
--- a/test/t/kernel.rb
+++ b/test/t/kernel.rb
@@ -479,7 +479,7 @@ assert('Kernel#!=') do
assert_false (str2 != str1)
end
-# operator "!~" is defined in ISO Ruby 11.4.4.
+# operator "!~" is defined in ISO Ruby 11.4.4.
assert('Kernel#!~') do
x = "x"
def x.=~(other)
@@ -511,6 +511,13 @@ assert('Kernel#respond_to_missing?') do
assert_false Test4RespondToMissing.new.respond_to?(:no_method)
end
+assert('Kernel#global_variables') do
+ variables = global_variables
+ 1.upto(9) do |i|
+ assert_equal variables.include?(:"$#{i}"), true
+ end
+end
+
assert('stack extend') do
def recurse(count, stop)
return count if count > stop