summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2021-09-08 18:47:09 -0700
committerAlan Wu <[email protected]>2021-10-20 18:19:40 -0400
commit44214e8ad9e8ba1adf704c8231b4ecced77d3b7a (patch)
tree1660eb87148943394d4b44f616c42867de55e17c /test
parentcc2aa1221f96055c1d1d70ea4407b1ee12ed9a6b (diff)
Implement getspecial
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_yjit.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb
index 4307a7dfb6..10eb4aa476 100644
--- a/test/ruby/test_yjit.rb
+++ b/test/ruby/test_yjit.rb
@@ -205,6 +205,15 @@ class TestYJIT < Test::Unit::TestCase
RUBY
end
+ def test_getspecial_backref
+ assert_compiles("'foo' =~ /(o)./; $&", insns: %i[getspecial], result: "oo")
+ assert_compiles("'foo' =~ /(o)./; $`", insns: %i[getspecial], result: "f")
+ assert_compiles("'foo' =~ /(o)./; $'", insns: %i[getspecial], result: "")
+ assert_compiles("'foo' =~ /(o)./; $+", insns: %i[getspecial], result: "o")
+ assert_compiles("'foo' =~ /(o)./; $1", insns: %i[getspecial], result: "o")
+ assert_compiles("'foo' =~ /(o)./; $2", insns: %i[getspecial], result: nil)
+ end
+
def test_compile_opt_getinlinecache
assert_compiles(<<~RUBY, insns: %i[opt_getinlinecache], result: 123, min_calls: 2)
def get_foo