---
cases:
  - note: keywordrefs/some keyword in package
    query: data.foo.p = x
    modules:
      - |
        package foo.some.bar

        baz := 42
      - |
        package foo
        import data.foo.some.bar

        p if {
          bar.baz == 42
          data.foo.some.bar.baz == 42
        }
    want_result:
      - x: true
  - note: keywordrefs/some keyword in package, import alias
    query: data.foo.p = x
    modules:
      - |
        package foo.some

        bar := 42
      - |
        package foo
        import data.foo.some as my_if

        p if {
          my_if.bar == 42
          data.foo.some.bar == 42
        }
    want_result:
      - x: true
  - note: keywordrefs/some keyword rule refhead
    query: data.test.p = x
    modules:
      - |
        package test

        p if {
          some.foo == 1
          foo.some == 2
        }

        some.foo := 1

        foo.some := 2
    want_result:
      - x: true
  - note: keywordrefs/some keyword rule refhead, else bodies
    query: data.test.p = x
    input:
      x: 3
    modules:
      - |
        package test

        p if {
          some.foo == 3
          foo.some == 6
        }

        some.foo := 1 if {
          input.x == 1
        } else := 2 if {
          input.x == 2
        } else := 3

        foo.some := 4 if {
          input.x == 1
        } else := 5 if {
          input.x == 2
        } else := 6
    want_result:
      - x: true
  - note: keywordrefs/some keyword rule refhead, partial set
    query: data.test.p = x
    modules:
      - |
        package test

        p if {
          some.foo == {"a", "c"}
          foo.some == {"a", "c"}
        }

        some.foo contains "a"

        some.foo contains "b" if {
          false
        }

        some.foo contains "c" if {
          true
        }

        foo.some contains "a"

        foo.some contains "b" if {
          false
        }

        foo.some contains "c" if {
          true
        }
    want_result:
      - x: true
  - note: keywordrefs/some keyword rule refhead, partial object
    query: data.test.p = x
    modules:
      - |
        package test

        p if {
          some.foo == "a"
          some.bar.one == "a"
          some.bar.three == "c"
          foo.some == "a"
          bar.baz.some == "a"
        }

        some.foo := "a"

        some.foo := "b" if {
          false
        }

        some.foo := "c" if {
          false
        }

        some.bar.one := "a"

        some.bar.two := "b" if {
          false
        }

        some.bar.three := "c" if {
          true
        }

        foo.some := "a"

        foo.some := "b" if {
          false
        }

        foo.some := "c" if {
          false
        }

        bar.baz.some := "a"

        bar.baz.some := "b" if {
          false
        }

        bar.baz.some := "c" if {
          false
        }
    want_result:
      - x: true
  - note: keywordrefs/some keyword function refhead
    query: data.test.p = x
    modules:
      - |
        package test

        p if {
          some.foo(1) == 1
          some.foo(11) == 42
          foo.some(1) == 1
          foo.some(11) == 42
          bar.some.baz(1) == 1
          bar.some.baz(11) == 42
        }

        default some.foo(_) := 42

        some.foo(x) := x if {
          x < 10
        }

        default foo.some(_) := 42

        foo.some(x) := x if {
          x < 10
        }

        default bar.some.baz(_) := 42

        bar.some.baz(x) := x if {
          x < 10
        }
    want_result:
      - x: true
