Skip to content

Render list results in CQL list syntax in the results file - #107

Merged
bryantaustin13 merged 1 commit into
mainfrom
claude/results-actual-cql-list-format
Jul 29, 2026
Merged

Render list results in CQL list syntax in the results file#107
bryantaustin13 merged 1 commit into
mainfrom
claude/results-actual-cql-list-format

Conversation

@alexzautke

Copy link
Copy Markdown

List-typed actual values were flattened with String() when writing the results file, so a list like ['@2012-01-01T', '@2012-01-01T12'] appeared as the comma-joined string @2012-01-01T,@2012-01-01T12. That obscures the list structure and makes failures hard to read — e.g. for CqlListOperatorsTest / Sort / SortDatesAsc, the only difference from the expected value was element order, which was invisible in the flattened form.

Changes

  • src/test-results/cql-test-results.ts: added a formatActualValue helper that renders array actuals in CQL list syntax — { a, b, c }, recursing into nested lists, {} for empty lists — so the actual value reads like the expected value's CQL/CVL notation. Non-array objects fall back to JSON.stringify, scalars to String() as before. Used by both toJSON and equalizeValueTypes.
  • actual remains a plain string, so the results JSON schema and downstream consumers of results files are unaffected.

Before / after for SortDatesAsc:

"actual":   "@2012-01-01T12,@2012-01-01T,@2012-10-05T,@2012-10-05T10"
"actual":   "{ @2012-01-01T12, @2012-01-01T, @2012-10-05T, @2012-10-05T10 }",
"expected": "{ @2012-01-01T, @2012-01-01T12, @2012-10-05T, @2012-10-05T10 }"

Note: string elements are not re-quoted (a CQL { 'a', 'b' } renders as { a, b }), since the extracted values no longer carry type information. This only affects display in the results file; pass/fail comparison happens before formatting and is unchanged.

Testing

  • Unit tests for list, scalar, nested-list, and empty-list rendering in toJSON and equalizeValueTypes.
  • Full suite passes (125 tests) and tsc --noEmit is clean.
  • Verified end to end by running run-tests against a mock FHIR server returning repeated return parameters — the results file shows the CQL-list-formatted actual above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M6fK2KhnNsn28SJfe83Htw


Generated by Claude Code

List-typed actual values were flattened with String(), so a list like
['@2012-01-01T', '@2012-01-01T12'] appeared in the results JSON as the
comma-joined string '@2012-01-01T,@2012-01-01T12', obscuring the list
structure (and hiding that only element order differed from expected).

Format array actuals as '{ a, b, c }' (recursively, '{}' when empty) so
the actual value reads like the expected value's CQL/CVL notation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6fK2KhnNsn28SJfe83Htw

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves readability of generated CQL test results by rendering array-typed actual values using CQL list syntax ({ a, b, c }, recursive for nested lists, {} for empty lists) instead of the prior flattened String() output, while keeping the actual field as a plain string to avoid schema/consumer changes.

Changes:

  • Added a formatActualValue helper to serialize array actuals into CQL list syntax (with recursion for nested lists).
  • Updated toJSON and equalizeValueTypes to use formatActualValue when producing schema-compliant string actual values.
  • Added unit tests covering scalar, list, nested-list, and empty-list formatting behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/test-results/cql-test-results.ts Adds formatActualValue and uses it to preserve list structure in actual when serializing results.
test/cql-test-results-validator.test.ts Adds tests validating list/scalar/nested/empty list formatting for toJSON and equalizeValueTypes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bryantaustin13 bryantaustin13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Improves readability.

@bryantaustin13
bryantaustin13 merged commit 60ba2f5 into main Jul 29, 2026
1 check passed
@alexzautke
alexzautke deleted the claude/results-actual-cql-list-format branch July 31, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants