Skip to content

Commit 1e33fab

Browse files
committed
ZJIT: Add hir test for optional args, pos and kwarg
1 parent 48ea1a4 commit 1e33fab

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

zjit/src/hir/opt_tests.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,6 +3095,40 @@ mod hir_opt_tests {
30953095
");
30963096
}
30973097

3098+
#[test]
3099+
fn specialize_call_with_pos_optional_and_kw_optional() {
3100+
eval("
3101+
def foo(r, x = 2, a:, b: 4) = [r, x, a, b]
3102+
def test = [foo(1, a: 3), foo(1, 2, b: 40, a: 30)] # with and without the optionals
3103+
test
3104+
test
3105+
");
3106+
assert_snapshot!(hir_string("test"), @r"
3107+
fn test@<compiled>:3:
3108+
bb0():
3109+
EntryPoint interpreter
3110+
v1:BasicObject = LoadSelf
3111+
Jump bb2(v1)
3112+
bb1(v4:BasicObject):
3113+
EntryPoint JIT(0)
3114+
Jump bb2(v4)
3115+
bb2(v6:BasicObject):
3116+
v11:Fixnum[1] = Const Value(1)
3117+
v13:Fixnum[3] = Const Value(3)
3118+
IncrCounter complex_arg_pass_param_kw_opt
3119+
v15:BasicObject = SendWithoutBlock v6, :foo, v11, v13 # SendFallbackReason: Complex argument passing
3120+
v18:Fixnum[1] = Const Value(1)
3121+
v20:Fixnum[2] = Const Value(2)
3122+
v22:Fixnum[40] = Const Value(40)
3123+
v24:Fixnum[30] = Const Value(30)
3124+
IncrCounter complex_arg_pass_param_kw_opt
3125+
v26:BasicObject = SendWithoutBlock v6, :foo, v18, v20, v22, v24 # SendFallbackReason: Complex argument passing
3126+
v28:ArrayExact = NewArray v15, v26
3127+
CheckInterrupts
3128+
Return v28
3129+
");
3130+
}
3131+
30983132
#[test]
30993133
fn test_send_call_to_iseq_with_optional_kw() {
31003134
eval("

0 commit comments

Comments
 (0)