@@ -10,43 +10,54 @@ const specials = [{val: NaN, path: "$nan"}, {val: Infinity, path: "$inf"}];
1010
1111assert . commandWorked ( coll . insert ( { inf : Infinity , nan : NaN } ) ) ;
1212
13- [ "off" , "alwaysOn" ] . forEach ( ( mode ) => {
14- assert . commandWorked (
15- db . adminCommand ( { configureFailPoint : 'disablePipelineOptimization' , mode : mode } ) ) ;
13+ try {
14+ [ "alwaysOn" , "off" ] . forEach ( ( mode ) => {
15+ assert . commandWorked (
16+ db . adminCommand ( { configureFailPoint : 'disablePipelineOptimization' , mode : mode } ) ) ;
1617
17- // TODO SERVER-43034: include $add and $sum.
18- [ "$multiply" ] . forEach ( ( op ) => {
19- ( function testCommutativityWithConstArguments ( ) {
20- specials . forEach ( ( special ) => {
21- numbers . forEach ( ( num ) => {
22- const expected = [ {
23- a : ( num instanceof NumberDecimal ? NumberDecimal ( special . val ) : special . val )
24- } ] ;
25- assert . eq ( expected ,
26- coll . aggregate ( [ { $project : { a : { [ op ] : [ special . val , num ] } , _id : 0 } } ] )
27- . toArray ( ) ) ;
28- assert . eq ( expected ,
29- coll . aggregate ( [ { $project : { a : { [ op ] : [ num , special . val ] } , _id : 0 } } ] )
30- . toArray ( ) ) ;
18+ // TODO SERVER-43034: include $add and $sum.
19+ [ "$multiply" ] . forEach ( ( op ) => {
20+ ( function testCommutativityWithConstArguments ( ) {
21+ specials . forEach ( ( special ) => {
22+ numbers . forEach ( ( num ) => {
23+ const expected = [ {
24+ a : ( num instanceof NumberDecimal ? NumberDecimal ( special . val )
25+ : special . val )
26+ } ] ;
27+ assert . eq (
28+ expected ,
29+ coll . aggregate ( [ { $project : { a : { [ op ] : [ special . val , num ] } , _id : 0 } } ] )
30+ . toArray ( ) ) ;
31+ assert . eq (
32+ expected ,
33+ coll . aggregate ( [ { $project : { a : { [ op ] : [ num , special . val ] } , _id : 0 } } ] )
34+ . toArray ( ) ) ;
35+ } ) ;
3136 } ) ;
32- } ) ;
33- } ) ( ) ;
37+ } ) ( ) ;
3438
35- ( function testCommutativityWithNonConstArgument ( ) {
36- specials . forEach ( ( special ) => {
37- numbers . forEach ( ( num ) => {
38- const expected = [ {
39- a : ( num instanceof NumberDecimal ? NumberDecimal ( special . val ) : special . val )
40- } ] ;
41- assert . eq ( expected ,
42- coll . aggregate ( [ { $project : { a : { [ op ] : [ special . path , num ] } , _id : 0 } } ] )
43- . toArray ( ) ) ;
44- assert . eq ( expected ,
45- coll . aggregate ( [ { $project : { a : { [ op ] : [ num , special . path ] } , _id : 0 } } ] )
46- . toArray ( ) ) ;
39+ ( function testCommutativityWithNonConstArgument ( ) {
40+ specials . forEach ( ( special ) => {
41+ numbers . forEach ( ( num ) => {
42+ const expected = [ {
43+ a : ( num instanceof NumberDecimal ? NumberDecimal ( special . val )
44+ : special . val )
45+ } ] ;
46+ assert . eq (
47+ expected ,
48+ coll . aggregate ( [ { $project : { a : { [ op ] : [ special . path , num ] } , _id : 0 } } ] )
49+ . toArray ( ) ) ;
50+ assert . eq (
51+ expected ,
52+ coll . aggregate ( [ { $project : { a : { [ op ] : [ num , special . path ] } , _id : 0 } } ] )
53+ . toArray ( ) ) ;
54+ } ) ;
4755 } ) ;
48- } ) ;
49- } ) ( ) ;
56+ } ) ( ) ;
57+ } ) ;
5058 } ) ;
51- } ) ;
59+ } finally {
60+ assert . commandWorked (
61+ db . adminCommand ( { configureFailPoint : 'disablePipelineOptimization' , mode : 'off' } ) ) ;
62+ }
5263} ) ( ) ;
0 commit comments