---
# Short-circuit is observed via strict-builtin-errors: the RHS is wired
# with a builtin that errors at runtime; the test passes only if the RHS is
# *not* evaluated when the LHS already failed.
cases:
  - note: "logic_op/and/short-circuit: lhs fails, rhs builtin not evaluated"
    experimental_keywords: true
    strict_error: true
    query: data.test.p = x
    modules:
      - |
        package test
        import future.keywords.and

        p if {
          input.x > 0 and to_number("foo") == 1
        }
    input:
      x: 0
    want_result: []
  - note: "logic_op/and/short-circuit: lhs succeeds, rhs builtin error surfaces"
    experimental_keywords: true
    strict_error: true
    query: data.test.p = x
    modules:
      - |
        package test
        import future.keywords.and

        p if {
          input.x > 0 and to_number("foo") == 1
        }
    input:
      x: 1
    want_error_code: eval_builtin_error
    want_error: to_number
  - note: "logic_op/and/short-circuit: guarded type access"
    experimental_keywords: true
    strict_error: true
    query: data.test.p = x
    modules:
      - |
        package test
        import future.keywords.and

        # RHS would error if evaluated
        p if {
          is_array(input.x) and count(input.x) > 0
        }
    input:
      x: "not an array"
    want_result: []
