diff options
Diffstat (limited to 'tests/custom/03_stdlib/27_sprintf')
-rw-r--r-- | tests/custom/03_stdlib/27_sprintf | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/custom/03_stdlib/27_sprintf b/tests/custom/03_stdlib/27_sprintf index 3edcd48..e1a3c5d 100644 --- a/tests/custom/03_stdlib/27_sprintf +++ b/tests/custom/03_stdlib/27_sprintf @@ -548,3 +548,24 @@ Supplying a non-string format value will yield an empty string result. -- Expect stdout -- "" -- End -- + + +Prefixing a format directive with `n$` will select the corresponding argument +with 1 referring to the first argument. Missing or out-of range arguments will +be treated as `null`. + +-- Testcase -- +{% + printf("%.J\n", [ + sprintf("%2$s", "foo", "bar", "baz"), + sprintf("%10$s", "foo", "bar", "baz") + ]); +%} +-- End -- + +-- Expect stdout -- +[ + "bar", + "(null)" +] +-- End -- |