Add $toInt, $toDouble, $toLong, $toDecimal tests - #684
Merged
Conversation
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…ed magic number with constants Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Migrates tests from old_tests/ to documentdb_tests/compatibility/ tests/core/operator/expressions/type/toLong/ following the migration harness. Files added: - __init__.py - test_smoke_toLong.py (was already present) - test_toLong_arity.py (arity + invalid field path) - test_toLong_numeric.py (null/missing, bool, int32, int64, double) - test_toLong_decimal128.py (Decimal128 truncation and overflow) - test_toLong_datetime_binary.py (datetime, binary, unsupported types) - test_toLong_string.py (string conversion + size limit) - test_toLong_return_type.py (return type invariant + idempotency) - test_toLong_field_ref.py (field references + expression input) Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…idator - Add generate_bson_rejection_test_cases() to test_toLong_return_type.py for ObjectId, Regex, Timestamp, JavaScript/Code, MinKey, MaxKey types - Skip NULL (returns null, not error), OBJECT and ARRAY (need $literal wrapping) from generated rejection — keep hand-written cases for those - Remove the six now-redundant hand-written ExpressionTestCase rejection entries from test_toLong_datetime_binary.py - Drop unused bson imports (Code, MaxKey, MinKey, ObjectId, Regex, Timestamp) Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Add two cases missing from the new test suite vs the old: 1. type_code_with_scope: CodeWithScope (BSON 0x0f) is a distinct type from JavaScript/Code (0x0d) and is not covered by bson_type_validator samples. Verified it produces CONVERSION_FAILURE_ERROR like plain Code. 2. type_nested_array: $toLong([[\x22 42\x22]]) — the outer single-element literal array is unwrapped at parse time, leaving the inner [\x2242\x22] (a runtime array) as the actual argument, which is a conversion failure. Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Replace three bare numeric literals flagged by find_numerical_constant_replacements.py: - 0 (int32) -> INT32_ZERO - 0.5 -> DOUBLE_HALF - -0.5 -> DOUBLE_NEGATIVE_HALF Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…nstants
framework/test_constants.py:
- Add INT64_FROM_DOUBLE_MAX_FITTING = Int64(9223372036854774784)
(int64 truncation of DOUBLE_MAX_FITTING_INT64)
- Add DOUBLE_BELOW_INT64_MIN = math.nextafter(-float(2**63), float('-inf'))
(first IEEE 754 double strictly below int64 min)
- Add 'import math' for the above
test_toLong_numeric.py:
- Replace inline Int64(9223372036854774784) with INT64_FROM_DOUBLE_MAX_FITTING
- Replace math.nextafter(...) expression with DOUBLE_BELOW_INT64_MIN
- Drop now-redundant 'import math'
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Restore math.nextafter(-float(2**63), FLOAT_NEGATIVE_INFINITY) inline in test_toLong_numeric.py and remove the constant (and import math) that were added to test_constants.py in the previous commit. Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage, test-framework); effort from diff stats (5654+0 LOC, 36 files); LLM: Adds compatibility test coverage for four type conversion aggregation operators ($toInt, $toDouble, $toLong, $toDecimal), expanding test suite for tracked issues. If a label is wrong, remove it manually and ping |
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
danielfrankcom
approved these changes
Jul 14, 2026
eerxuan
approved these changes
Jul 15, 2026
RyanGarfinkel
pushed a commit
to RyanGarfinkel/functional-tests
that referenced
this pull request
Jul 20, 2026
Signed-off-by: PatersonProjects <keldonhoff@gmail.com> Co-authored-by: PatersonProjects <keldonhoff@gmail.com> Co-authored-by: Daniel Frankcom <frankcom@amazon.com> Signed-off-by: RyanGarfinkel <113050972+RyanGarfinkel@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the tests for $toInt, $toDouble, $toLong, and $toDecimal. It was originally authored by @danielfrankcom.
Ref: Issue #15, #328, #327, #329, #326