Skip to content

Add $rand expression tests#120

Merged
eerxuan merged 6 commits intodocumentdb:mainfrom
danielfrankcom:pr/rand-tests
Apr 20, 2026
Merged

Add $rand expression tests#120
eerxuan merged 6 commits intodocumentdb:mainfrom
danielfrankcom:pr/rand-tests

Conversation

@danielfrankcom
Copy link
Copy Markdown
Collaborator

This change adds tests for the $rand expression operator. These tests were originally written by @mitchell-elholm.

Test files added:

  • Argument handling tests for empty array/object syntax, invalid argument types (all BSON types, field references, $missing), and non-empty array/object error codes
  • Return value tests for type (double), range [0, 1), and per-invocation independence
  • Combination tests covering arithmetic operators ($multiply, $add, $subtract, $pow, $mod, $divide), conditional operators ($cond), type conversions ($toString, $concat), $let variable binding and reuse, $switch, $filter, object expressions, and deep nesting
  • Pipeline stage integration tests for $project, $group, and $match covering per-document independence, statistical distribution, uniform distribution, range validation, null field handling, and empty collection behavior — placed at operator level to match repo conventions

Ref: #17

@danielfrankcom danielfrankcom requested a review from a team as a code owner April 16, 2026 23:45
mitchell-elholm and others added 3 commits April 16, 2026 16:55
Signed-off-by: Mitchell Elholm <mitchell-elholm@users.noreply.github.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom danielfrankcom requested a review from manojnks April 17, 2026 18:45
@danielfrankcom danielfrankcom deleted the pr/rand-tests branch April 20, 2026 21:13
@danielfrankcom danielfrankcom restored the pr/rand-tests branch April 20, 2026 21:27
@eerxuan eerxuan reopened this Apr 20, 2026
@eerxuan eerxuan merged commit 374889b into documentdb:main Apr 20, 2026
9 checks passed
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