From b2da3824c5cc03658c652ed810ee0e322bd62b80 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 18 Sep 2017 02:27:13 +0000 Subject: refinements in string interpolation * compile.c (iseq_compile_each0): insert to_s method call, so that refinements activated at the caller should take place. [Feature #13812] * insns.def (tostring): fix up converted object to a string, infect and fallback. * insns.def (branchiftype): new instruction for conversion. branches if TOS is an instance of the given type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_refinement.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index d79eb2b187..31925f3933 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1961,6 +1961,19 @@ class TestRefinement < Test::Unit::TestCase end end + class ToString + c = self + using Module.new {refine(c) {def to_s; "ok"; end}} + def string + "#{self}" + end + end + + def test_tostring + assert_equal("ok", ToString.new.string) + assert_predicate(ToString.new.taint.string, :tainted?) + end + private def eval_using(mod, s) -- cgit v1.2.3