summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorJimmy Miller <jimmy.miller@shopify.com>2023-02-15 14:05:42 -0500
committerGitHub <noreply@github.com>2023-02-15 14:05:42 -0500
commit8943b0d411519adeebd0d3dbf7cef337eed1ed02 (patch)
tree37375f26b02a88860c9d7e80029aa196fc6a4a00 /bootstraptest
parentae2340c9d793e00000186a461a37596b09268370 (diff)
downloadruby-8943b0d411519adeebd0d3dbf7cef337eed1ed02.tar.gz
YJIT: `Kernel#{is_a?,instance_of?}` fast paths (GH-7297)
Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index ebb19c8d3a..f79f047928 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -3552,3 +3552,30 @@ assert_equal 'threw', %q{
bar([Hash.ruby2_keywords_hash({})])
}
+
+# Test instance_of? and is_a?
+assert_equal 'true', %q{
+ 1.instance_of?(Integer) && 1.is_a?(Integer)
+}
+
+# Test instance_of? and is_a? for singleton classes
+assert_equal 'true', %q{
+ a = []
+ def a.test = :test
+ a.instance_of?(Array) && a.is_a?(Array)
+}
+
+# Test instance_of? for singleton_class
+# Yes this does really return false
+assert_equal 'false', %q{
+ a = []
+ def a.test = :test
+ a.instance_of?(a.singleton_class)
+}
+
+# Test is_a? for singleton_class
+assert_equal 'true', %q{
+ a = []
+ def a.test = :test
+ a.is_a?(a.singleton_class)
+}