-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* vm_eval.c (make_no_method_execption): extract from
raise_method_missing(). * vm_eval.c (send_internal): remove inadvertent symbol creation from public_send. based on a patch by Jeremy Evans <code AT jeremyevans.net> in [ruby-core:38576]. [Feature #5112] * vm_insnhelper.c (vm_call_method): remove inadvertent symbol creation from send and __send__, too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
- Loading branch information
Showing
8 changed files
with
138 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] | ||
inits = $srcs.map {|s| File.basename(s, ".*")} | ||
inits.delete("init") | ||
inits.map! {|s|"X(#{s})"} | ||
$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\"" | ||
create_makefile("-test-/symbol/symbol") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "ruby.h" | ||
|
||
#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);} | ||
|
||
void | ||
Init_symbol(void) | ||
{ | ||
VALUE mBug = rb_define_module("Bug"); | ||
VALUE klass = rb_define_class_under(mBug, "Symbol", rb_cSymbol); | ||
TEST_INIT_FUNCS(init); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "ruby.h" | ||
|
||
static VALUE | ||
bug_sym_interned_p(VALUE self, VALUE name) | ||
{ | ||
ID id = rb_check_id(&name); | ||
return id ? Qtrue : Qfalse; | ||
} | ||
|
||
void | ||
Init_intern(VALUE klass) | ||
{ | ||
rb_define_singleton_method(klass, "interned?", bug_sym_interned_p, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'test/unit' | ||
require "-test-/symbol/symbol" | ||
|
||
module Test_Symbol | ||
class TestInadvertent < Test::Unit::TestCase | ||
def self.noninterned_name | ||
th = Thread.current.object_id.to_s(36) | ||
begin | ||
name = "#{th}.#{rand(0x1000).to_s(16)}.#{Time.now.usec}" | ||
end while Bug::Symbol.interned?(name) | ||
name | ||
end | ||
|
||
def setup | ||
@obj = Object.new | ||
end | ||
|
||
Feature5112 = '[ruby-core:38576]' | ||
|
||
def test_public_send | ||
name = self.class.noninterned_name | ||
e = assert_raise(NoMethodError) {@obj.public_send(name, Feature5112)} | ||
assert_not_send([Bug::Symbol, :interned?, name]) | ||
assert_equal(name, e.name) | ||
assert_equal([Feature5112], e.args) | ||
end | ||
|
||
def test_send | ||
name = self.class.noninterned_name | ||
e = assert_raise(NoMethodError) {@obj.send(name, Feature5112)} | ||
assert_not_send([Bug::Symbol, :interned?, name]) | ||
assert_equal(name, e.name) | ||
assert_equal([Feature5112], e.args) | ||
end | ||
|
||
def test___send__ | ||
name = self.class.noninterned_name | ||
e = assert_raise(NoMethodError) {@obj.__send__(name, Feature5112)} | ||
assert_not_send([Bug::Symbol, :interned?, name]) | ||
assert_equal(name, e.name) | ||
assert_equal([Feature5112], e.args) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters