---
cases:
  - note: objectget/empty_path_returns_object
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": 1}, [], 2)
        }
    want_result:
      - x:
          a: 1
  - note: objectget/path_with_single_element
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": 1}, ["a"], 2)
        }
    want_result:
      - x: 1
  - note: objectget/path_with_two_elements
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": {"b": 1}}, ["a", "b"], 2)
        }
    want_result:
      - x: 1
  - note: objectget/path_with_three_elements
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": {"b": {"c": 1}}}, ["a", "b", "c"], 2)
        }
    want_result:
      - x: 1
  - note: objectget/path_with_single_element_no_result
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": 1}, ["b"], 2)
        }
    want_result:
      - x: 2
  - note: objectget/path_with_two_elements_no_result
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": {"b": 1}}, ["b", "a"], 2)
        }
    want_result:
      - x: 2
  - note: objectget/path_with_three_elements_no_result
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": {"b": {"c": 1}}}, ["a", "b", "a"], 2)
        }
    want_result:
      - x: 2
  - note: objectget/path_with_non_string_keys
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({1: {"b": {[1, 2, 3]: 1}}}, [1, "b", [1, 2, 3]], 2)
        }
    want_result:
      - x: 1
  - note: objectget/get_intermediate_non_object
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": {"b": [1, 2, 3]}}, ["a", "b", "a"], 2)
        }
    want_result:
      - x: 2
  - note: objectget/get_intermediate_array
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get({"a": {"b": [{"c": 1}]}}, ["a", "b", 0, "c"], 2)
        }
    want_result:
      - x: 1
  - note: objectget/get_for_non_object
    query: data.test.p = x
    modules:
      - |
        package test

        p := x if {
        	x := object.get(input.obj, ["a"], 2)
        }
    input_term: '{"obj":"object"}'
    want_error_code: eval_type_error
    want_error: "object.get: operand 1 must be object but got string"
    strict_error: true
