Skip to content

Commit 7466eb6

Browse files
committed
test(vm): add test for Predicate Recursion of Death scenario
1 parent 237ae8f commit 7466eb6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

interpreter_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,25 @@ func TestInterpreter_Bombing(t *testing.T) {
12191219
})
12201220
})
12211221

1222+
t.Run("💣 backtrack of death", func(t *testing.T) {
1223+
nbCalls := 0
1224+
t.Run("create vm", func(t *testing.T) {
1225+
i := New(nil, nil)
1226+
assert.NotNil(t, i)
1227+
i.InstallHook(limitHooker(&nbCalls))
1228+
1229+
t.Run("execute program", func(t *testing.T) {
1230+
assert.NoError(t, i.Exec("backtrackOfDeath :- repeat, fail."))
1231+
1232+
t.Run("💥", func(t *testing.T) {
1233+
sol := i.QuerySolutionContext(context.Background(), `backtrackOfDeath.`)
1234+
1235+
assert.Nil(t, sol.sols)
1236+
assert.EqualError(t, sol.Err(), "error(resource_error(calls),\\+ /1)")
1237+
})
1238+
})
1239+
})
1240+
})
12221241
}
12231242

12241243
func TestInterpreter_QuerySolution(t *testing.T) {

0 commit comments

Comments
 (0)