Skip to content

Commit 5dac316

Browse files
committed
Add loop test
1 parent 236e902 commit 5dac316

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

zjit/src/hir/opt_tests.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21608,4 +21608,50 @@ mod hir_opt_tests {
2160821608
Return v63
2160921609
");
2161021610
}
21611+
21612+
#[test]
21613+
fn test_while_loop() {
21614+
eval(r#"
21615+
def test
21616+
i = 0
21617+
while i < 10
21618+
i += 1
21619+
end
21620+
i
21621+
end
21622+
21623+
test
21624+
"#);
21625+
assert_snapshot!(hir_string("test"), @"
21626+
fn test@<compiled>:3:
21627+
bb1():
21628+
EntryPoint interpreter
21629+
v1:BasicObject = LoadSelf
21630+
v2:NilClass = Const Value(nil)
21631+
Jump bb3(v1, v2)
21632+
bb2():
21633+
EntryPoint JIT(0)
21634+
v5:BasicObject = LoadArg :self@0
21635+
v6:NilClass = Const Value(nil)
21636+
Jump bb3(v5, v6)
21637+
bb3(v8:BasicObject, v9:NilClass):
21638+
v13:Fixnum[0] = Const Value(0)
21639+
Jump bb5(v8, v13)
21640+
bb5(v18:BasicObject, v19:Fixnum):
21641+
v23:Fixnum[10] = Const Value(10)
21642+
PatchPoint MethodRedefined(Integer@0x1000, <@0x1008, cme:0x1010)
21643+
v58:BoolExact = FixnumLt v19, v23
21644+
CheckInterrupts
21645+
v29:CBool = Test v58
21646+
CondBranch v29, bb4(), bb6()
21647+
bb4():
21648+
v48:Fixnum[1] = Const Value(1)
21649+
PatchPoint MethodRedefined(Integer@0x1000, +@0x1038, cme:0x1040)
21650+
v62:Fixnum = FixnumAdd v19, v48
21651+
Jump bb5(v18, v62)
21652+
bb6():
21653+
CheckInterrupts
21654+
Return v19
21655+
");
21656+
}
2161121657
}

0 commit comments

Comments
 (0)