mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixes #223, float arguments to functions like scale should now work as expected
This commit is contained in:
parent
b2aca66e2d
commit
8aff6f50db
@ -365,7 +365,7 @@ function (_) {
|
|||||||
this.params.splice(index, 1);
|
this.params.splice(index, 1);
|
||||||
}
|
}
|
||||||
else if (this.def.params[index].type === 'int') {
|
else if (this.def.params[index].type === 'int') {
|
||||||
this.params[index] = parseInt(strValue, 10);
|
this.params[index] = parseFloat(strValue, 10);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.params[index] = strValue;
|
this.params[index] = strValue;
|
||||||
|
@ -71,7 +71,11 @@ define([
|
|||||||
expect(func.text).to.be('summarize(1h, sum)');
|
expect(func.text).to.be('summarize(1h, sum)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse numbers as float', function() {
|
||||||
|
var func = gfunc.createFuncInstance('scale');
|
||||||
|
func.updateParam('0.001', 0);
|
||||||
|
expect(func.params[0]).to.be(0.001);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when updating func param with optional second parameter', function() {
|
describe('when updating func param with optional second parameter', function() {
|
||||||
|
@ -88,6 +88,12 @@ define([
|
|||||||
expect(tokens[4].pos).to.be(20);
|
expect(tokens[4].pos).to.be(20);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle float parameters', function() {
|
||||||
|
var lexer = new Lexer("alias(metric, 0.002)");
|
||||||
|
var tokens = lexer.tokenize();
|
||||||
|
expect(tokens[4].type).to.be('number');
|
||||||
|
expect(tokens[4].value).to.be('0.002');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -139,6 +139,13 @@ define([
|
|||||||
expect(rootNode.type).to.be('function');
|
expect(rootNode.type).to.be('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handle float function arguments', function() {
|
||||||
|
var parser = new Parser('scale(test, 0.002)');
|
||||||
|
var rootNode = parser.getAst();
|
||||||
|
expect(rootNode.type).to.be('function');
|
||||||
|
expect(rootNode.params[1].type).to.be('number');
|
||||||
|
expect(rootNode.params[1].value).to.be(0.002);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user