diff --git a/src/functions.js b/src/functions.js index d493c946..c3fff7a4 100644 --- a/src/functions.js +++ b/src/functions.js @@ -293,6 +293,7 @@ const functions = (() => { } var result; + width = Math.trunc(width); var padLength = Math.abs(width) - length(str); if (padLength > 0) { var padding = (new Array(padLength + 1)).join(char); diff --git a/test/test-suite/groups/function-pad/case011.json b/test/test-suite/groups/function-pad/case011.json new file mode 100644 index 00000000..f7dbc539 --- /dev/null +++ b/test/test-suite/groups/function-pad/case011.json @@ -0,0 +1,6 @@ +{ + "expr": "$pad('foo', 5.7, ' ')", + "dataset": null, + "bindings": {}, + "result": "foo " +} \ No newline at end of file diff --git a/test/test-suite/groups/function-pad/case012.json b/test/test-suite/groups/function-pad/case012.json new file mode 100644 index 00000000..502d0754 --- /dev/null +++ b/test/test-suite/groups/function-pad/case012.json @@ -0,0 +1,6 @@ +{ + "expr": "$pad('foo', -5.7, ' ')", + "dataset": null, + "bindings": {}, + "result": " foo" +} \ No newline at end of file