Skip to content

Commit

Permalink
rego-v1: Future-proofing lineage pkg tests to be 1.0 compatible (#7043
Browse files Browse the repository at this point in the history
)

Signed-off-by: Johan Fylling <[email protected]>
  • Loading branch information
johanfylling committed Sep 19, 2024
1 parent 2b1fba8 commit f25dd67
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions topdown/lineage/lineage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ func TestFilter(t *testing.T) {
{
note: "lineage",
module: `package test
import rego.v1
p { q }
q { r }
r { trace("R") }`,
p if { q }
q if { r }
r if { trace("R") }`,
exp: `
Enter data.test.p = x
| Enter data.test.p
Expand All @@ -38,8 +39,9 @@ Enter data.test.p = x
{
note: "conjunction",
module: `package test
import rego.v1
p { trace("P1"); trace("P2") }`,
p if { trace("P1"); trace("P2") }`,
exp: `
Enter data.test.p = x
| Enter data.test.p
Expand All @@ -49,10 +51,11 @@ Enter data.test.p = x
{
note: "conjunction (multiple enters)",
module: `package test
import rego.v1
p { q; r }
q { trace("Q") }
r { trace("Q") }
p if { q; r }
q if { trace("Q") }
r if { trace("Q") }
`,
exp: `
Enter data.test.p = x
Expand All @@ -65,10 +68,11 @@ Enter data.test.p = x
{
note: "disjunction",
module: `package test
import rego.v1
p = x { x := true; trace("P1") }
p = x { x := true; false }
p = x { x := true; trace("P2") }
p = x if { x := true; trace("P1") }
p = x if { x := true; false }
p = x if { x := true; trace("P2") }
`,
exp: `
Enter data.test.p = x
Expand All @@ -81,10 +85,11 @@ Redo data.test.p = x
{
note: "disjunction (failure)",
module: `package test
import rego.v1
p = x { x := true; trace("P1") }
p = x { x := true; trace("P2"); false }
p = x { x := true; trace("P3") }
p = x if { x := true; trace("P1") }
p = x if { x := true; trace("P2"); false }
p = x if { x := true; trace("P3") }
`,
exp: `
Enter data.test.p = x
Expand All @@ -99,9 +104,11 @@ Redo data.test.p = x
{
note: "disjunction (iteration)",
module: `package test
q[1]
q[2]
p { q[x]; trace(sprintf("x=%d", [x])) }`,
import rego.v1
q contains 1
q contains 2
p if { q[x]; trace(sprintf("x=%d", [x])) }`,
exp: `
Enter data.test.p = x
| Enter data.test.p
Expand All @@ -111,9 +118,10 @@ Enter data.test.p = x
{
note: "parent child",
module: `package test
import rego.v1
p { trace("P"); q }
q { trace("Q") }`,
p if { trace("P"); q }
q if { trace("Q") }`,
exp: `
Enter data.test.p = x
| Enter data.test.p
Expand All @@ -124,9 +132,10 @@ Enter data.test.p = x
{
note: "negation",
module: `package test
import rego.v1
p { not q }
q = false { trace("Q") }`,
p if { not q }
q = false if { trace("Q") }`,
exp: `
Enter data.test.p = x
| Enter data.test.p
Expand All @@ -137,9 +146,10 @@ Enter data.test.p = x
{
note: "fail",
module: `package test
import rego.v1
p { not q }
q { trace("P"); 1 = 2 }`,
p if { not q }
q if { trace("P"); 1 = 2 }`,
exp: `
Enter data.test.p = x
| Enter data.test.p
Expand All @@ -150,8 +160,9 @@ Enter data.test.p = x
{
note: "comprehensions",
module: `package test
import rego.v1
p { [true | true; trace("X")] }`,
p if { [true | true; trace("X")] }`,
exp: `
Enter data.test.p = x
| Enter data.test.p
Expand Down

0 comments on commit f25dd67

Please sign in to comment.