func makeProgramArgs(history *jq.Jv) *jq.Jv { // Create this structure: // programArgs = [ // {"name": "out", "value": history }, // {"name": "_", "value": history[-1] }, // {"name": "__", "value": history[-2] }, // ] arg := jq.JvObject().ObjectSet(jvStringName.Copy(), jvStringOut.Copy()).ObjectSet(jvStringValue.Copy(), history.Copy()) res := jq.JvArray().ArrayAppend(arg) len := history.Copy().ArrayLength() if len >= 1 { arg = jq.JvObject().ObjectSet(jvStringName.Copy(), jvStringUnderscore.Copy()).ObjectSet(jvStringValue.Copy(), history.Copy().ArrayGet(len-1)) res = res.ArrayAppend(arg) } if len >= 2 { arg = jq.JvObject().ObjectSet(jvStringName.Copy(), jvStringDunderscore.Copy()).ObjectSet(jvStringValue.Copy(), history.Copy().ArrayGet(len-2)) res = res.ArrayAppend(arg) } return res }
func TestJvInvalidWithMessage_object(t *testing.T) { is := is.New(t) jv := jq.JvInvalidWithMessage(jq.JvObject()) is.False(jv.IsValid()) msg := jv.Copy().GetInvalidMessage() is.Equal(msg.Kind(), jq.JV_KIND_OBJECT) msg.Free() str, ok := jv.GetInvalidMessageAsString() is.True(ok) is.Equal("{}", str) }