summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_ujit.rb30
-rw-r--r--test/ruby/test_microjit.rb27
2 files changed, 30 insertions, 27 deletions
diff --git a/bootstraptest/test_ujit.rb b/bootstraptest/test_ujit.rb
new file mode 100644
index 0000000000..9d26aec347
--- /dev/null
+++ b/bootstraptest/test_ujit.rb
@@ -0,0 +1,30 @@
+# Method redefinition (code invalidation) test
+assert_equal '1', %q{
+ def ret1
+ return 1
+ end
+
+ klass = Class.new do
+ def alias_then_hash(klass, method_to_redefine)
+ # Redefine the method to be ret1
+ klass.alias_method(method_to_redefine, :ret1)
+ hash
+ end
+ end
+
+ instance = klass.new
+
+ i = 0
+ while i < 12
+ if i < 11
+ # Redefine the bar method
+ instance.alias_then_hash(klass, :bar)
+ else
+ # Redefine the hash method to be ret1
+ retval = instance.alias_then_hash(klass, :hash)
+ end
+ i += 1
+ end
+
+ retval
+} \ No newline at end of file
diff --git a/test/ruby/test_microjit.rb b/test/ruby/test_microjit.rb
deleted file mode 100644
index f0c876b70f..0000000000
--- a/test/ruby/test_microjit.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-require 'test/unit'
-
-class TestMicroJIT < Test::Unit::TestCase
- # MicroJIT's code invalidation mechanism can't invalidate
- # code that is executing. Test that we don't try to do that.
- def test_code_invalidation
- klass = Class.new do
- def alias_then_hash(klass, method_to_redefine)
- klass.alias_method(method_to_redefine, :itself)
- hash
- end
- end
-
- instance = klass.new
- i = 0
- while i < 12
- if i < 11
- instance.alias_then_hash(klass, :bar)
- else
- ret = instance.alias_then_hash(klass, :hash)
- assert(instance.equal?(ret))
- end
- i += 1
- end
- end
-end