From 7466eb628932fbbbe66727cf2b5cc390f4c7dad0 Mon Sep 17 00:00:00 2001 From: ccamel Date: Mon, 23 Sep 2024 11:25:20 +0200 Subject: [PATCH] test(vm): add test for Predicate Recursion of Death scenario --- interpreter_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/interpreter_test.go b/interpreter_test.go index fc7c1fa..aeeeb54 100644 --- a/interpreter_test.go +++ b/interpreter_test.go @@ -1219,6 +1219,25 @@ func TestInterpreter_Bombing(t *testing.T) { }) }) + t.Run("💣 backtrack of death", func(t *testing.T) { + nbCalls := 0 + t.Run("create vm", func(t *testing.T) { + i := New(nil, nil) + assert.NotNil(t, i) + i.InstallHook(limitHooker(&nbCalls)) + + t.Run("execute program", func(t *testing.T) { + assert.NoError(t, i.Exec("backtrackOfDeath :- repeat, fail.")) + + t.Run("💥", func(t *testing.T) { + sol := i.QuerySolutionContext(context.Background(), `backtrackOfDeath.`) + + assert.Nil(t, sol.sols) + assert.EqualError(t, sol.Err(), "error(resource_error(calls),\\+ /1)") + }) + }) + }) + }) } func TestInterpreter_QuerySolution(t *testing.T) {