extend("test")
extend("array")

describe("array:prop", () => {

  it("retrieves the value of a specified key from a keyed array", () => {
    keyedExample = [ name:"Alice", city:"Paris" ]
    expect_equal( array:prop("name", keyedExample), "Alice" )
    expect_equal( array:prop("city", keyedExample), "Paris" )
  })

  it("handles partial usage for the key", () => {
    getCity = array:prop("city")
    keyed   = [ name:"Bob", city:"London" ]
    expect_equal( getCity(keyed), "London" )
  })

  it("handles underscore for the first param, object known", () => {
    keyedExample = [ alpha:111, beta:222 ]
    partial = array:prop(_, keyedExample)
    expect_equal( partial("beta"), 222 )
  })

})
