summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-10-27 16:10:25 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-28 13:43:02 -0400
commite53d07f583866e6df7a88963ada33cad68018ebd (patch)
treec65d78bdc6475760a11c1447c462a67b5b689a06 /test/ruby
parentd8e97169baf3073366f768a52956c43a1d4b0806 (diff)
Rename ::YJIT to RubyVM::YJIT
Since the YJIT Ruby module is CRuby specific and not meant for general use, it should live under RubyVM instead of at top level.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5038
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_rubyoptions.rb8
-rw-r--r--test/ruby/test_yjit.rb14
2 files changed, 12 insertions, 10 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 579d0cb362..b4080010e2 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -7,10 +7,12 @@ require 'tempfile'
require_relative '../lib/jit_support'
class TestRubyOptions < Test::Unit::TestCase
+ def self.yjit_enabled? = defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?
+
NO_JIT_DESCRIPTION =
if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE
RUBY_DESCRIPTION.sub(/\+JIT /, '')
- elsif defined?(YJIT.enabled?) && YJIT.enabled? # checking -DYJIT_FORCE_ENABLE
+ elsif yjit_enabled? # checking -DYJIT_FORCE_ENABLE
RUBY_DESCRIPTION.sub(/\+YJIT /, '')
else
RUBY_DESCRIPTION
@@ -146,7 +148,7 @@ class TestRubyOptions < Test::Unit::TestCase
assert_match(VERSION_PATTERN, r[0])
if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE
assert_equal(NO_JIT_DESCRIPTION, r[0])
- elsif defined?(YJIT.enabled?) && YJIT.enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE
+ elsif self.class.yjit_enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE
assert_equal(NO_JIT_DESCRIPTION, r[0])
else
assert_equal(RUBY_DESCRIPTION, r[0])
@@ -212,7 +214,7 @@ class TestRubyOptions < Test::Unit::TestCase
assert_match(VERSION_PATTERN, r[0])
if ENV['RUBY_YJIT_ENABLE'] == '1'
assert_equal(NO_JIT_DESCRIPTION, r[0])
- elsif defined?(RubyVM::JIT) && RubyVM::JIT.enabled? || defined?(YJIT.enabled?) && YJIT.enabled? # checking -D(M|Y)JIT_FORCE_ENABLE
+ elsif defined?(RubyVM::JIT) && RubyVM::JIT.enabled? || self.class.yjit_enabled? # checking -D(M|Y)JIT_FORCE_ENABLE
assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
else
assert_equal(RUBY_DESCRIPTION, r[0])
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb
index 9014a1e567..ad40ad1988 100644
--- a/test/ruby/test_yjit.rb
+++ b/test/ruby/test_yjit.rb
@@ -3,7 +3,7 @@ require 'test/unit'
require 'envutil'
require 'tmpdir'
-return unless defined?(YJIT) && YJIT.enabled?
+return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
# Tests for YJIT with assertions on compilation and side exits
# insipired by the MJIT tests in test/ruby/test_jit.rb
@@ -49,7 +49,7 @@ class TestYJIT < Test::Unit::TestCase
assert_equal([], stderr)
end
assert_in_out_err([yjit_child_env, '-e puts RUBY_DESCRIPTION'], '', [RUBY_DESCRIPTION])
- assert_in_out_err([yjit_child_env, '-e p YJIT.enabled?'], '', ['true'])
+ assert_in_out_err([yjit_child_env, '-e p RubyVM::YJIT.enabled?'], '', ['true'])
end
def test_compile_getclassvariable
@@ -498,7 +498,7 @@ class TestYJIT < Test::Unit::TestCase
objects[1].foo
}
- stats = YJIT.runtime_stats
+ stats = RubyVM::YJIT.runtime_stats
return :ok unless stats[:all_stats]
return :ok if stats[:invalidation_count] < 10
@@ -513,12 +513,12 @@ class TestYJIT < Test::Unit::TestCase
ANY = Object.new
def assert_compiles(test_script, insns: [], min_calls: 1, stdout: nil, exits: {}, result: ANY, frozen_string_literal: nil)
reset_stats = <<~RUBY
- YJIT.runtime_stats
- YJIT.reset_stats!
+ RubyVM::YJIT.runtime_stats
+ RubyVM::YJIT.reset_stats!
RUBY
write_results = <<~RUBY
- stats = YJIT.runtime_stats
+ stats = RubyVM::YJIT.runtime_stats
def collect_blocks(blocks)
blocks.sort_by(&:address).map { |b| [b.iseq_start_index, b.iseq_end_index] }
@@ -527,7 +527,7 @@ class TestYJIT < Test::Unit::TestCase
def collect_iseqs(iseq)
iseq_array = iseq.to_a
insns = iseq_array.last.grep(Array)
- blocks = YJIT.blocks_for(iseq)
+ blocks = RubyVM::YJIT.blocks_for(iseq)
h = {
name: iseq_array[5],
insns: insns,