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

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

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

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

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

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

        as.foo := 1

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

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

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

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

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

        as.foo.bar contains "a"

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

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

        foo.bar.as contains "a"

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

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

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

        as.foo := "a"

        as.foo := "b" {
          false
        }

        as.foo := "c" {
          false
        }

        as.bar.one := "a"

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

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

        foo.as := "a"

        foo.as := "b" {
          false
        }

        foo.as := "c" {
          false
        }

        bar.baz.as := "a"

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

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

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

        default as.foo(_) := 42

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

        default foo.as(_) := 42

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

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

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