Skip to content

feat: add comprehensive tests for built-in string functions#47

Merged
alvinreal merged 1 commit intomainfrom
fix/issue-18
Feb 21, 2026
Merged

feat: add comprehensive tests for built-in string functions#47
alvinreal merged 1 commit intomainfrom
fix/issue-18

Conversation

@alvinreal
Copy link
Owner

Summary

Adds comprehensive test coverage for all built-in string functions specified in #18, along with a small enhancement to join() and clippy fixes.

Changes

New integration tests (tests/string_functions.rs — 21 tests):
Covers every TDD scenario from the issue:

  • join("a", "b", "c")"abc" (variadic string concat)
  • join(.first, " ", .last) with field values
  • join(.tags, ",") array join with separator
  • split("a,b,c", ",")["a", "b", "c"]
  • split("hello", "x")["hello"] (no match)
  • lower("HELLO")"hello"
  • lower("Already lower")"already lower"
  • upper("hello")"HELLO"
  • trim(" hello ")"hello"
  • trim("no-spaces")"no-spaces"
  • replace("hello world", "world", "rust")"hello rust"
  • replace("aaa", "a", "b")"bbb" (all occurrences)
  • len("hello")5, len([1,2,3])3, len("")0
  • coalesce(null, null, "found")"found"
  • coalesce("first", "second")"first"
  • coalesce(.missing, .name) → fallback to existing field
  • Error on wrong arg count
  • Nested: lower(trim(...)), upper(replace(...))

Enhanced join() function:

  • Now supports variadic string concatenation: join("a", "b", "c")"abc"
  • Array join with separator still works: join(["a","b"], ",")"a,b"

Additional unit tests in functions.rs:

  • split_no_match, lower_already_lower, lower_non_string_coerces
  • trim_no_spaces, replace_all_occurrences, len_empty_string, len_array_3
  • coalesce_first_non_null, join_strings, join_with_field_values

Clippy fixes:

  • Replaced redundant closure with function reference
  • Replaced match single-pattern with if let
  • Fixed approx_constant warnings (3.14 → 3.15 in tests)

Fixes #18

- Add 21 integration tests in tests/string_functions.rs covering all TDD
  scenarios from the issue: join, split, lower, upper, trim, replace,
  len, coalesce, error handling, and composability
- Extend join() to support variadic string concatenation (join(a, b, c))
  in addition to array join(arr, sep)
- Add unit tests for edge cases: split no-match, lower already-lower,
  trim no-spaces, replace all occurrences, len empty string, coalesce
  first-non-null, lower with non-string coercion
- Fix clippy warnings: redundant closure, single_match, approx_constant

Fixes #18
@alvinreal alvinreal merged commit a05a0ef into main Feb 21, 2026
6 checks passed
@alvinreal alvinreal deleted the fix/issue-18 branch February 21, 2026 19:53
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
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.

Mapping language: Built-in string functions

1 participant