From 3c22eded97e8b87cc9ebf178e187b8e72472befc Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Tue, 12 May 2015 12:25:03 +0200 Subject: [PATCH] Migrate literal tests to testing language. --- promql/promql_test.go | 80 ----------------------------------- promql/testdata/literals.test | 56 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 80 deletions(-) create mode 100644 promql/testdata/literals.test diff --git a/promql/promql_test.go b/promql/promql_test.go index acc2d8bfda..92ebeee9ba 100644 --- a/promql/promql_test.go +++ b/promql/promql_test.go @@ -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{ diff --git a/promql/testdata/literals.test b/promql/testdata/literals.test new file mode 100644 index 0000000000..ffca00e1cf --- /dev/null +++ b/promql/testdata/literals.test @@ -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 \ No newline at end of file