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

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

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

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

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

        p {
          not.foo == 1
          foo.not == 2
        }

        not.foo := 1

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

        p {
          not.foo.bar == 3
          foo.bar.not == 6
        }

        not.foo.bar := 1 {
          input.x == 1
        } else := 2 {
          input.x == 2
        } else := 3

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

        p {
          not.foo.bar == {"a", "c"}
          foo.bar.not == {"a", "c"}
        }

        not.foo.bar contains "a"

        not.foo.bar contains "b" {
          false
        }

        not.foo.bar contains "c" {
          true
        }

        foo.bar.not contains "a"

        foo.bar.not contains "b" {
          false
        }

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

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

        not.foo := "a"

        not.foo := "b" {
          false
        }

        not.foo := "c" {
          false
        }

        not.bar.one := "a"

        not.bar.two := "b" {
          false
        }

        not.bar.three := "c" {
          true
        }

        foo.not := "a"

        foo.not := "b" {
          false
        }

        foo.not := "c" {
          false
        }

        bar.baz.not := "a"

        bar.baz.not := "b" {
          false
        }

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

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

        default not.foo(_) := 42

        not.foo(x) := x {
          x < 10
        }

        default foo.not(_) := 42

        foo.not(x) := x {
          x < 10
        }

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

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