summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-05-27 10:59:41 -0700
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:35 -0400
commiteb6e5be038a94c622f09188c957370d86650628c (patch)
treeee6731b8d83a25a36956e38332415e490d15edc4 /bootstraptest
parentd01204a15da9afcd4ddcc48ec022f9bf92db0a70 (diff)
Add newhash and newarray instructions to yjit codegen (#48)
* Implement gen_newarray * Implement newhash for n=0 * Add yjit tests for newhash/newarray * Fix integer size warning on clang * Save PC and SP in newhash and newarray Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 524b387502..51b4a9b85f 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -927,3 +927,53 @@ assert_equal '[Proc, 1, 2, 3, Proc]', %q{
[use_zero] + use_three
}
+
+# test building empty array
+assert_equal '[]', %q{
+ def build_arr
+ []
+ end
+
+ build_arr
+ build_arr
+}
+
+# test building array of one element
+assert_equal '[5]', %q{
+ def build_arr(val)
+ [val]
+ end
+
+ build_arr(5)
+ build_arr(5)
+}
+
+# test building array of several element
+assert_equal '[5, 5, 5, 5, 5]', %q{
+ def build_arr(val)
+ [val, val, val, val, val]
+ end
+
+ build_arr(5)
+ build_arr(5)
+}
+
+# test building empty hash
+assert_equal '{}', %q{
+ def build_hash
+ {}
+ end
+
+ build_hash
+ build_hash
+}
+
+# test building hash with values
+assert_equal '{:foo=>:bar}', %q{
+ def build_hash(val)
+ { foo: val }
+ end
+
+ build_hash(:bar)
+ build_hash(:bar)
+}