summaryrefslogtreecommitdiff
path: root/jstests/aggregation/sources/bucketauto/granularity_near_zero.js
blob: 7f456f9428dc33158110bf7bf0352de32354778c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Tests when the granularity rounder needs to approach zero to round correctly. This test was
// designed to reproduce SERVER-57091.
(function() {
"use strict";
const coll = db.server57091;
coll.drop();
coll.insertOne({});

const res =
    coll.aggregate([{
            $bucketAuto: {
                groupBy: {
                    $reduce:
                        {input: [], initialValue: 4.940656484124654e-324, in : {$size: ["$$value"]}}
                },
                buckets: NumberLong("8"),
                granularity: "R80"
            }
        }])
        .toArray();
assert.eq(res, [{_id: {min: 0, max: 1.02e-321}, count: 1}]);
})();