mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 16:55:40 +00:00
Add divide by zero test
This commit is contained in:
parent
0b951fb6a4
commit
16997769e0
@ -36,3 +36,21 @@ a: 4.8
|
||||
b: 2.5
|
||||
```
|
||||
|
||||
## Number division by zero
|
||||
Dividing by zero results in +Inf or -Inf
|
||||
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
a: 1
|
||||
b: -1
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq '.a = .a / 0 | .b = .b / 0' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a: !!float +Inf
|
||||
b: !!float -Inf
|
||||
```
|
||||
|
||||
|
||||
@ -39,6 +39,15 @@ var divideOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], (doc)::{a: 4.8, b: 2.5}\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Number division by zero",
|
||||
subdescription: "Dividing by zero results in +Inf or -Inf",
|
||||
document: `{a: 1, b: -1}`,
|
||||
expression: `.a = .a / 0 | .b = .b / 0`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::{a: !!float +Inf, b: !!float -Inf}\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
description: "Custom types: that are really strings",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user