Skip to content

Commit 1dd3e2b

Browse files
authored
test(builtins): add spec tests for jq --arg/--argjson (#925)
Closes #914
1 parent 55ce92b commit 1dd3e2b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crates/bashkit/tests/spec_cases/jq/jq.test.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,33 @@ jq -n --argjson obj '{"a":1}' '$obj.a'
933933
1
934934
### end
935935

936+
### jq_arg_field_assignment
937+
# --arg with field assignment using herestring
938+
jq --arg name "John" '.greeting = "Hello " + $name' <<< '{}'
939+
### expect
940+
{
941+
"greeting": "Hello John"
942+
}
943+
### end
944+
945+
### jq_argjson_field_assignment
946+
# --argjson with numeric field assignment
947+
jq --argjson count 42 '.total = $count' <<< '{}'
948+
### expect
949+
{
950+
"total": 42
951+
}
952+
### end
953+
954+
### jq_arg_dynamic_key
955+
# --arg with dynamic key using .[$key]
956+
jq --arg key "name" --arg val "Alice" '.[$key] = $val' <<< '{}'
957+
### expect
958+
{
959+
"name": "Alice"
960+
}
961+
### end
962+
936963
### jq_combined_flags_snr
937964
# Three combined short flags -snr
938965
jq -snr '"hello"'

0 commit comments

Comments
 (0)