diff options
author | Mindaugas Malinauskas <mindaugas.malinauskas@mongodb.com> | 2021-06-29 17:55:00 +0100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-20 15:21:20 +0000 |
commit | ed1231808d79d17952a0cc39e7180892fed5b72b (patch) | |
tree | 63586ee35dbc81ff1e34ffdd702c42bcb9f6f71f /src/mongo/shell | |
parent | 9313fbaac63f091c4590ec862456fd115c4a57dd (diff) | |
download | mongo-ed1231808d79d17952a0cc39e7180892fed5b72b.tar.gz |
SERVER-57321 Make $mod match expression handle NaN, Infinity and large values
(cherry picked from commit 23e56121a014719f0dd29d27a60a72a0e11dac10)
(cherry picked from commit b9e15d31f7cc46fe2581545ce7c5ebaeb04cfea5)
Co-authored-by: Mihai Andrei <mihai.andrei@mongodb.com>
Diffstat (limited to 'src/mongo/shell')
-rw-r--r-- | src/mongo/shell/assert.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js index e4d74097830..1d15cdc774d 100644 --- a/src/mongo/shell/assert.js +++ b/src/mongo/shell/assert.js @@ -580,6 +580,24 @@ assert = (function() { return error; }; + assert.throwsWithCode = function(func, expectedCode, params, msg) { + if (arguments.length < 2) { + throw new Error("assert.throwsWithCode expects at least 2 arguments"); + } + // Remove the 'code' parameter, and any undefined parameters, from the list of arguments. + // Use .apply() to preserve the length of the 'arguments' object. + const newArgs = [func, params, msg].filter(element => element !== undefined); + const error = assert.throws.apply(null, newArgs); + if (!Array.isArray(expectedCode)) { + expectedCode = [expectedCode]; + } + if (!expectedCode.some((ec) => error.code == ec)) { + doassert(_buildAssertionMessage( + msg, + "[" + tojson(error.code) + "] != [" + tojson(expectedCode) + "] are not equal")); + } + }; + assert.doesNotThrow = function(func, params, msg) { _validateAssertionMessage(msg); |