---
cases:
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every x in [] { x != x }
        }
    note: every/empty domain (array)
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every x in set() { x != x }
        }
    note: every/empty domain (set)
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every x in {} { x != x }
        }
    note: every/empty domain (object)
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        l[1] {
          false
        }

        p {
          every x in l { x != x }
        }
    note: every/empty domain (partial rule ref)
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every _ in input { true }
        }
    note: every/domain undefined (input)
    query: data.test.p = x
    want_result: []
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every _ in data.foo { true }
        }
    note: every/domain undefined (data ref)
    query: data.test.p = x
    want_result: []
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every x in numbers.range(1, 10) { x >= 1 }
        }
    note: every/domain is call
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every k, v in [1, 2] { k+1 == v }
        }
    note: every/simple key/val
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every k, v in {1, 2} { k == v }
        }
    note: every/simple key/val (set)
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        l[1] {
          true
        }

        l[2] {
          true
        }

        p {
          every k, v in l { k == v }
        }
    note: every/simple key/val (partial rule ref)
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          i := 10
          every k, v in [1, 2] { k+v != i }
        }
    note: every/outer bindings
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every v in [1, 2] { v != 1 }
        }
    note: every/simple failure, first
    query: data.test.p = x
    want_result: []
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every v in [1, 2] { v != 2 }
        }
    note: every/simple failure, last
    query: data.test.p = x
    want_result: []
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every v in input { v == 1 } with input as [1, 1, 1]
        }
    note: "every/with: domain"
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every v in [1, 2] { v in input } with input as [1, 2, 1, 0]
        }
    note: "every/with: body"
    query: data.test.p = x
    want_result:
      - x: true
  - data:
    modules:
      - |
        package test
        import future.keywords.every

        p[v] {
          every v in [1, 2] { v < 3 }
          v := 10
          v > 3
        }
    note: "every/followed by another query"
    query: data.test.p = x
    want_result:
      - x: [10]
  - note: "every/array with calls"
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every v in [1 / 2, 3, 4 + 5] { v < 10 }
        }
    query: data.test.p = x
    want_result:
      - x: true
  - note: "every/array with calls (fail)"
    modules:
      - |
        package test
        import future.keywords.every

        p {
          every v in [1 / 2, 3, 4 + 5] { v < 9 }
        }

        q {
          not p
        }
    query: data.test.q = x
    want_result:
      - x: true
