Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit a99f472

Browse files
authored
PHPLIB-1342 Add tests on Arithmetic Expression Operators (#52)
1 parent 397ff5d commit a99f472

29 files changed

+973
-0
lines changed

generator/config/expression/abs.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ arguments:
1111
name: value
1212
type:
1313
- resolvesToNumber
14+
tests:
15+
-
16+
name: 'Example'
17+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/#example'
18+
pipeline:
19+
-
20+
$project:
21+
delta:
22+
$abs:
23+
$subtract:
24+
- '$startTemp'
25+
- '$endTemp'

generator/config/expression/ceil.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ arguments:
1313
- resolvesToNumber
1414
description: |
1515
If the argument resolves to a value of null or refers to a field that is missing, $ceil returns null. If the argument resolves to NaN, $ceil returns NaN.
16+
tests:
17+
-
18+
name: 'Example'
19+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/#example'
20+
pipeline:
21+
-
22+
$project:
23+
value: 1
24+
ceilingValue:
25+
$ceil: '$value'

generator/config/expression/divide.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,15 @@ arguments:
1717
name: divisor
1818
type:
1919
- resolvesToNumber
20+
tests:
21+
-
22+
name: 'Example'
23+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#example'
24+
pipeline:
25+
-
26+
$project:
27+
city: 1
28+
workdays:
29+
$divide:
30+
- '$hours'
31+
- 8

generator/config/expression/exp.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ arguments:
1111
name: exponent
1212
type:
1313
- resolvesToNumber
14+
tests:
15+
-
16+
name: 'Example'
17+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/#example'
18+
pipeline:
19+
-
20+
$project:
21+
effectiveRate:
22+
$subtract:
23+
-
24+
$exp: '$interestRate'
25+
- 1

generator/config/expression/floor.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ arguments:
1111
name: expression
1212
type:
1313
- resolvesToNumber
14+
tests:
15+
-
16+
name: 'Example'
17+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/#example'
18+
pipeline:
19+
-
20+
$project:
21+
value: 1
22+
floorValue:
23+
$floor: '$value'

generator/config/expression/ln.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ arguments:
1414
- resolvesToNumber
1515
description: |
1616
Any valid expression as long as it resolves to a non-negative number. For more information on expressions, see Expressions.
17+
tests:
18+
-
19+
name: 'Example'
20+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/#example'
21+
pipeline:
22+
-
23+
$project:
24+
x: '$year'
25+
y:
26+
$ln: '$sales'

generator/config/expression/log.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,18 @@ arguments:
1919
- resolvesToNumber
2020
description: |
2121
Any valid expression as long as it resolves to a positive number greater than 1.
22+
tests:
23+
-
24+
name: 'Example'
25+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/#example'
26+
pipeline:
27+
-
28+
$project:
29+
bitsNeeded:
30+
$floor:
31+
$add:
32+
- 1
33+
-
34+
$log:
35+
- '$int'
36+
- 2

generator/config/expression/log10.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ arguments:
1313
- resolvesToNumber
1414
description: |
1515
Any valid expression as long as it resolves to a non-negative number.
16+
tests:
17+
-
18+
name: 'Example'
19+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/#example'
20+
pipeline:
21+
-
22+
$project:
23+
pH:
24+
$multiply:
25+
- -1
26+
-
27+
$log10: '$H3O'

generator/config/expression/mod.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ arguments:
1717
name: divisor
1818
type:
1919
- resolvesToNumber
20+
tests:
21+
-
22+
name: 'Example'
23+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/#example'
24+
pipeline:
25+
-
26+
$project:
27+
remainder:
28+
$mod:
29+
- '$hours'
30+
- '$tasks'

generator/config/expression/multiply.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ arguments:
1515
description: |
1616
The arguments can be any valid expression as long as they resolve to numbers.
1717
Starting in MongoDB 6.1 you can optimize the $multiply operation. To improve performance, group references at the end of the argument list.
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/#example'
22+
pipeline:
23+
-
24+
$project:
25+
date: 1
26+
item: 1
27+
total:
28+
$multiply:
29+
- '$price'
30+
- '$quantity'

0 commit comments

Comments
 (0)