|
|
|
@ -123,6 +123,26 @@ var testExpr = []struct { |
|
|
|
}}, |
|
|
|
}}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
input: "-some_metric", expected: &UnaryExpr{ |
|
|
|
|
|
|
|
Op: itemSUB, |
|
|
|
|
|
|
|
Expr: &VectorSelector{ |
|
|
|
|
|
|
|
Name: "some_metric", |
|
|
|
|
|
|
|
LabelMatchers: metric.LabelMatchers{ |
|
|
|
|
|
|
|
{Type: metric.Equal, Name: clientmodel.MetricNameLabel, Value: "some_metric"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
input: "+some_metric", expected: &UnaryExpr{ |
|
|
|
|
|
|
|
Op: itemADD, |
|
|
|
|
|
|
|
Expr: &VectorSelector{ |
|
|
|
|
|
|
|
Name: "some_metric", |
|
|
|
|
|
|
|
LabelMatchers: metric.LabelMatchers{ |
|
|
|
|
|
|
|
{Type: metric.Equal, Name: clientmodel.MetricNameLabel, Value: "some_metric"}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
input: "", |
|
|
|
input: "", |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
@ -192,13 +212,17 @@ var testExpr = []struct { |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
errMsg: "could not parse remaining input \"=~ 1\"...", |
|
|
|
errMsg: "could not parse remaining input \"=~ 1\"...", |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
input: "-some_metric", |
|
|
|
input: `-"string"`, |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
errMsg: "expected type scalar in unary expression, got vector", |
|
|
|
errMsg: `unary expression only allowed on expressions of type scalar or vector, got "string"`, |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
input: `-"string"`, |
|
|
|
input: `-test[5m]`, |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
errMsg: "expected type scalar in unary expression, got string", |
|
|
|
errMsg: `unary expression only allowed on expressions of type scalar or vector, got "matrix"`, |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
input: `*test`, |
|
|
|
|
|
|
|
fail: true, |
|
|
|
|
|
|
|
errMsg: "no valid expression found", |
|
|
|
}, |
|
|
|
}, |
|
|
|
// Vector binary operations.
|
|
|
|
// Vector binary operations.
|
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -950,18 +974,15 @@ var testExpr = []struct { |
|
|
|
input: "-=", |
|
|
|
input: "-=", |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
}, |
|
|
|
}, { |
|
|
|
{ |
|
|
|
|
|
|
|
input: "++-++-+-+-<", |
|
|
|
input: "++-++-+-+-<", |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
}, |
|
|
|
}, { |
|
|
|
{ |
|
|
|
|
|
|
|
input: "e-+=/(0)", |
|
|
|
input: "e-+=/(0)", |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
}, |
|
|
|
}, { |
|
|
|
{ |
|
|
|
|
|
|
|
input: "-If", |
|
|
|
input: "-If", |
|
|
|
fail: true, |
|
|
|
fail: true, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
errMsg: `no valid expression found`, |
|
|
|
|