FEATURE: Operators
| Field | Value |
|---|---|
| Version | 20261028 V1 |
| Description | Evaluate jq arithmetic, comparison, and Boolean operators. |
| Depends On | FEATURE-Collections.md |
| Provides | jq operators |
| Consumes | jq collection expressions |
Behavior
Evaluate each operand filter against the same input and produce the applicable combinations in jq order. Implement arithmetic for the types and operations defined in the manual, including array subtraction, object merging, string operations, and null addition. Invalid combinations and division by zero raise runtime errors.
Equality distinguishes booleans from numbers and compares arrays and objects structurally. Ordering follows jq's type and value ordering. Boolean operators use false and null as false values and preserve jq's short-circuit and generator behavior. Numeric operations use the non-decnum behavior specified by the corpus.
Programmatic Acceptance
=== AC operators-corpus ===
Intent: Arithmetic and comparison expressions execute the selected corpus cases with jq operand and result semantics.
Suite: scoped
Requires: executable=python3; scope=test
Probe: --list
Probe Count: summary
import json import os import subprocess import sys
SELECT = r"^1\+1$|^2-1$|^2-\(-1\)$|^25 % 7$|^49732 % 472$|^1 \+ 2 \* 2 \+ 10 / 2$" result = subprocess.run( [sys.executable, "sources/run_conformance.py", "--select", SELECT, "--json"], capture_output=True, text=True, env={**os.environ, "JQ": os.path.abspath("jq")}, ) print(result.stdout) print(result.stderr, file=sys.stderr) report = json.loads(result.stdout) tally = report["summary"] print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored") assert sum(tally.values()) > 0 assert tally["fail"] == 0 and tally["error"] == 0, tally assert result.returncode == 0, result.returncode === END AC operators-corpus ===
User Acceptance
- None.
Guardrails
- Preserve generator ordering and distinguish runtime errors from compile errors.
- Leave corpus cases requiring later builtins or control constructs to scoped integration.