mirror of
https://github.com/prometheus/prometheus
synced 2025-01-28 02:12:52 +00:00
Migrate literal tests to testing language.
This commit is contained in:
parent
eba07a7d3d
commit
3c22eded97
@ -926,86 +926,6 @@ func TestExpressions(t *testing.T) {
|
||||
`{a="aa", b="bb"} => 100 @[%v]`,
|
||||
},
|
||||
},
|
||||
{
|
||||
expr: `12.34e6`,
|
||||
output: []string{`scalar: 12340000 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `12.34e+6`,
|
||||
output: []string{`scalar: 12340000 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `12.34e-6`,
|
||||
output: []string{`scalar: 0.00001234 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `1+1`,
|
||||
output: []string{`scalar: 2 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `1-1`,
|
||||
output: []string{`scalar: 0 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `1 - -1`,
|
||||
output: []string{`scalar: 2 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `.2`,
|
||||
output: []string{`scalar: 0.2 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `+0.2`,
|
||||
output: []string{`scalar: 0.2 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `-0.2e-6`,
|
||||
output: []string{`scalar: -0.0000002 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `+Inf`,
|
||||
output: []string{`scalar: +Inf @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `inF`,
|
||||
output: []string{`scalar: +Inf @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `-inf`,
|
||||
output: []string{`scalar: -Inf @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `NaN`,
|
||||
output: []string{`scalar: NaN @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `nan`,
|
||||
output: []string{`scalar: NaN @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `2.`,
|
||||
output: []string{`scalar: 2 @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999`,
|
||||
shouldFail: true,
|
||||
},
|
||||
{
|
||||
expr: `1 / 0`,
|
||||
output: []string{`scalar: +Inf @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `-1 / 0`,
|
||||
output: []string{`scalar: -Inf @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `0 / 0`,
|
||||
output: []string{`scalar: NaN @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `1 % 0`,
|
||||
output: []string{`scalar: NaN @[%v]`},
|
||||
},
|
||||
{
|
||||
expr: `http_requests{group="canary", instance="0", job="api-server"} / 0`,
|
||||
output: []string{
|
||||
|
56
promql/testdata/literals.test
vendored
Normal file
56
promql/testdata/literals.test
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
eval instant at 50m 12.34e6
|
||||
12340000
|
||||
|
||||
eval instant at 50m 12.34e+6
|
||||
12340000
|
||||
|
||||
eval instant at 50m 12.34e-6
|
||||
0.00001234
|
||||
|
||||
eval instant at 50m 1+1
|
||||
2
|
||||
|
||||
eval instant at 50m 1-1
|
||||
0
|
||||
|
||||
eval instant at 50m 1 - -1
|
||||
2
|
||||
|
||||
eval instant at 50m .2
|
||||
0.2
|
||||
|
||||
eval instant at 50m +0.2
|
||||
0.2
|
||||
|
||||
eval instant at 50m -0.2e-6
|
||||
-0.0000002
|
||||
|
||||
eval instant at 50m +Inf
|
||||
+Inf
|
||||
|
||||
eval instant at 50m inF
|
||||
+Inf
|
||||
|
||||
eval instant at 50m -inf
|
||||
-Inf
|
||||
|
||||
eval instant at 50m NaN
|
||||
NaN
|
||||
|
||||
eval instant at 50m nan
|
||||
NaN
|
||||
|
||||
eval instant at 50m 2.
|
||||
2
|
||||
|
||||
eval instant at 50m 1 / 0
|
||||
+Inf
|
||||
|
||||
eval instant at 50m -1 / 0
|
||||
-Inf
|
||||
|
||||
eval instant at 50m 0 / 0
|
||||
NaN
|
||||
|
||||
eval instant at 50m 1 % 0
|
||||
NaN
|
Loading…
Reference in New Issue
Block a user