summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-11-05 14:01:07 -0700
committerGitHub <noreply@github.com>2021-11-05 17:01:07 -0400
commitfbd6cc5856d10f935dd8aea96826652dbb49d844 (patch)
tree27b6092dfcab0146cc16e6bcbafa79f06672da30 /bootstraptest
parent9cc2c74b8381670f584ed31b81aedb66c8f61b34 (diff)
YJIT: Support iseq sends with mixed kwargs (#5082)
* YJIT: Support iseq sends with mixed kwargs Co-authored-by: Kevin Newton <kddnewton@gmail.com> * Add additional comments to iseq sends Co-authored-by: Kevin Newton <kddnewton@gmail.com>
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 13d63b521c..33e9a35462 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -2187,6 +2187,60 @@ assert_equal '[3]', %q{
5.times.map { default_expression }.uniq
}
+# reordered optional kwargs
+assert_equal '[[100, 1]]', %q{
+ def foo(capacity: 100, max: nil)
+ [capacity, max]
+ end
+
+ 5.times.map { foo(max: 1) }.uniq
+}
+
+# invalid lead param
+assert_equal 'ok', %q{
+ def bar(baz: 2)
+ baz
+ end
+
+ def foo
+ bar(1, baz: 123)
+ end
+
+ begin
+ foo
+ foo
+ rescue ArgumentError => e
+ print "ok"
+ end
+}
+
+# reordered required kwargs
+assert_equal '[[1, 2, 3, 4]]', %q{
+ def foo(default1: 1, required1:, default2: 3, required2:)
+ [default1, required1, default2, required2]
+ end
+
+ 5.times.map { foo(required1: 2, required2: 4) }.uniq
+}
+
+# reordered default expression kwargs
+assert_equal '[[:one, :two, 3]]', %q{
+ def foo(arg1: (1+0), arg2: (2+0), arg3: (3+0))
+ [arg1, arg2, arg3]
+ end
+
+ 5.times.map { foo(arg2: :two, arg1: :one) }.uniq
+}
+
+# complex kwargs
+assert_equal '[[1, 2, 3, 4]]', %q{
+ def foo(required:, specified: 999, simple_default: 3, complex_default: "4".to_i)
+ [required, specified, simple_default, complex_default]
+ end
+
+ 5.times.map { foo(specified: 2, required: 1) }.uniq
+}
+
# attr_reader on frozen object
assert_equal 'false', %q{
class Foo