Mercurial > vim
annotate src/testdir/test_format.vim @ 33986:a18b8310956a v9.0.2179
patch 9.0.2179: no filetype detection for execline scripts
Commit: https://github.com/vim/vim/commit/63210c214afa6589b6132bd060908a8711f4567f
Author: Mazunki Hoksaas <rolferen@gmail.com>
Date: Tue Dec 19 20:44:41 2023 +0100
patch 9.0.2179: no filetype detection for execline scripts
Problem: no filetype detection for execline scripts
Solution: Add filetype detection for execline
as a prior to adding syntax support for execline (see
https://github.com/djpohly/vim-execline/issues/2), i went ahead and made
the filetype detection for execline scripts.
closes: #13689
Signed-Off-By: Mazunki Hoksaas <rolferen@gmail.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 19 Dec 2023 21:00:03 +0100 |
parents | 5c12ca4dcd45 |
children | 0adcad161c46 |
rev | line source |
---|---|
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for expressions. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 source check.vim |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 import './vim9.vim' as v9 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 func Test_printf_pos_misc() |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 let lines =<< trim END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call assert_equal('123', printf('%1$d', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 call assert_equal('', printf('%1$.0d', 0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 call assert_equal('00005', printf('%1$5.5d', 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 call assert_equal('00005', printf('%1$*1$.5d', 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call assert_equal('00005', printf('%1$5.*1$d', 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 call assert_equal('00005', printf('%1$*1$.*1$d', 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal('00005', printf('%1$*10$.5d%2$.0d%3$.0d%4$.0d%5$.0d%6$.0d%7$.0d%8$.0d%9$.0d', 5, 0, 0, 0, 0, 0, 0, 0, 0, 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call assert_equal('00005', printf('%1$5.*10$d%2$.0d%3$.0d%4$.0d%5$.0d%6$.0d%7$.0d%8$.0d%9$.0d', 5, 0, 0, 0, 0, 0, 0, 0, 0, 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 call assert_equal('123', printf('%1$i', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 call assert_equal('123', printf('%1$D', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 call assert_equal('123', printf('%1$U', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call assert_equal('173', printf('%1$o', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 call assert_equal('173', printf('%1$O', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 call assert_equal('7b', printf('%1$x', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 call assert_equal('7B', printf('%1$X', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 call assert_equal('Printing 1 at width 1 gives: 1', 1->printf("Printing %1$d at width %1$d gives: %1$*1$d")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 call assert_equal('Printing 2 at width 2 gives: 2', 2->printf("Printing %1$d at width %1$d gives: %1$*1$d")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 call assert_equal('Printing 3 at width 3 gives: 3', 3->printf("Printing %1$d at width %1$d gives: %1$*1$d")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 call assert_equal('Printing 1 at width/precision 1.1 gives: 1', 1->printf("Printing %1$d at width/precision %1$d.%1$d gives: %1$*1$.*1$d")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 call assert_equal('Printing 2 at width/precision 2.2 gives: 02', 2->printf("Printing %1$d at width/precision %1$d.%1$d gives: %1$*1$.*1$d")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call assert_equal('Printing 3 at width/precision 3.3 gives: 003', 3->printf("Printing %1$d at width/precision %1$d.%1$d gives: %1$*1$.*1$d")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 call assert_equal('123', printf('%1$hd', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 call assert_equal('-123', printf('%1$hd', -123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call assert_equal('-1', printf('%1$hd', 0xFFFF)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call assert_equal('-1', printf('%1$hd', 0x1FFFFF)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call assert_equal('123', printf('%1$hu', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 call assert_equal('65413', printf('%1$hu', -123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_equal('65535', printf('%1$hu', 0xFFFF)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 call assert_equal('65535', printf('%1$hu', 0x1FFFFF)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 call assert_equal('123', printf('%1$ld', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 call assert_equal('-123', printf('%1$ld', -123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 call assert_equal('65535', printf('%1$ld', 0xFFFF)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 call assert_equal('131071', printf('%1$ld', 0x1FFFF)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 call assert_equal('{', printf('%1$c', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 call assert_equal('abc', printf('%1$s', 'abc')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 call assert_equal('abc', printf('%1$S', 'abc')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 call assert_equal('+123', printf('%1$+d', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 call assert_equal('-123', printf('%1$+d', -123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 call assert_equal('+123', printf('%1$+ d', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 call assert_equal(' 123', printf('%1$ d', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 call assert_equal(' 123', printf('%1$ d', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 call assert_equal('-123', printf('%1$ d', -123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 call assert_equal(' 123', printf('%2$*1$d', 5, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 call assert_equal('123 ', printf('%2$*1$d', -5, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 call assert_equal('00123', printf('%2$.*1$d', 5, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 call assert_equal(' 123', printf('%2$ *1$d', 5, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 call assert_equal(' +123', printf('%2$+ *1$d', 5, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 call assert_equal(' 123', printf('%1$*2$d', 123, 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 call assert_equal('123 ', printf('%1$*2$d', 123, -5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 call assert_equal('00123', printf('%1$.*2$d', 123, 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 call assert_equal(' 123', printf('%1$ *2$d', 123, 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 call assert_equal(' +123', printf('%1$+ *2$d', 123, 5)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 call assert_equal('foobar', printf('%2$.*1$s', 9, 'foobar')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 call assert_equal('foo', printf('%2$.*1$s', 3, 'foobar')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 call assert_equal('', printf('%2$.*1$s', 0, 'foobar')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 call assert_equal('foobar', printf('%2$.*1$s', -1, 'foobar')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 #" Unrecognized format specifier kept as-is. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 call assert_equal('_123', printf("%_%1$d", 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 #" Test alternate forms. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 call assert_equal('0x7b', printf('%1$#x', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 call assert_equal('0X7B', printf('%1$#X', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 call assert_equal('0173', printf('%1$#o', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 call assert_equal('0173', printf('%1$#O', 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 call assert_equal('abc', printf('%1$#s', 'abc')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 call assert_equal('abc', printf('%1$#S', 'abc')) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 call assert_equal('1%', printf('%1$d%%', 1)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 call assert_notequal('', printf('%1$p', "abc")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 call assert_notequal('', printf('%2$d %1$p %3$s', "abc", 2, "abc")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 #" Try argument re-use and argument swapping |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 call assert_equal('one two one', printf('%1$s %2$s %1$s', "one", "two")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 call assert_equal('Screen height: 400', printf('%1$s height: %2$d', "Screen", 400)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 call assert_equal('400 is: Screen height', printf('%2$d is: %1$s height', "Screen", 400)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 #" Try out lots of combinations of argument types to skip |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 call assert_equal('9 12345 7654321', printf('%2$ld %1$d %3$lu', 12345, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 call assert_equal('9 1234567 7654321', printf('%2$d %1$ld %3$lu', 1234567, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 call assert_equal('9 1234567 7654321', printf('%2$d %1$lld %3$lu', 1234567, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 call assert_equal('9 12345 7654321', printf('%2$ld %1$u %3$lu', 12345, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 call assert_equal('9 1234567 7654321', printf('%2$d %1$lu %3$lu', 1234567, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 call assert_equal('9 1234567 7654321', printf('%2$d %1$llu %3$lu', 1234567, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 call assert_equal('9 1234567 7654321', printf('%2$d %1$llu %3$lu', 1234567, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 call assert_equal('9 deadbeef 7654321', printf('%2$d %1$x %3$lu', 0xdeadbeef, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 call assert_equal('9 c 7654321', printf('%2$ld %1$c %3$lu', 99, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 call assert_equal('9 hi 7654321', printf('%2$ld %1$s %3$lu', "hi", 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 call assert_equal('9 0.000000e+00 7654321', printf('%2$ld %1$e %3$lu', 0.0, 9, 7654321)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 call v9.CheckLegacyAndVim9Success(lines) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 call v9.CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 1, 3, 4)"], "E767:") |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
110 call v9.CheckLegacyAndVim9Failure(["call printf('%2$d%d', 1, 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
111 call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$d', 1, 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
112 call v9.CheckLegacyAndVim9Failure(["call printf('%2$*1$d%d', 1, 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
113 call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$*1$d', 1, 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
114 call v9.CheckLegacyAndVim9Failure(["call printf('%2$.*1$d%d', 1, 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
115 call v9.CheckLegacyAndVim9Failure(["call printf('%d%2$.*1$d', 1, 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
116 call v9.CheckLegacyAndVim9Failure(["call printf('%1$%')"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
117 call v9.CheckLegacyAndVim9Failure(["call printf('%1$')"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
118 call v9.CheckLegacyAndVim9Failure(["call printf('%1$_')"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
119 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.*d', 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
120 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*.*2$d', 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
121 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*.*d', 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
122 call v9.CheckLegacyAndVim9Failure(["call printf('%*.*1$d', 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
123 call v9.CheckLegacyAndVim9Failure(["call printf('%*1$.*d', 3)"], "E1500:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
124 call v9.CheckLegacyAndVim9Failure(["call printf('%*1$.*1$d', 3)"], "E1500:") |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
126 call v9.CheckLegacyAndVim9Failure(["call printf('%2$d', 3, 3)"], "E1501:") |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
128 call v9.CheckLegacyAndVim9Failure(["call printf('%2$*1$d %1$ld', 3, 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
129 call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
130 call v9.CheckLegacyAndVim9Failure(["call printf('%1$p %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
131 call v9.CheckLegacyAndVim9Failure(["call printf('%1$f %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
132 call v9.CheckLegacyAndVim9Failure(["call printf('%1$lud %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
133 call v9.CheckLegacyAndVim9Failure(["call printf('%1$llud %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
134 call v9.CheckLegacyAndVim9Failure(["call printf('%1$lld %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
135 call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
136 call v9.CheckLegacyAndVim9Failure(["call printf('%1$c %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
137 call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$*1$d', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
138 call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %2$*1$d', 3, 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
139 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$ld', 3)"], "E1502:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
140 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$.*1$ld', 3)"], "E1502:") |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
142 call v9.CheckLegacyAndVim9Failure(["call printf('%1$d%2$d', 3)"], "E1503:") |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
144 call v9.CheckLegacyAndVim9Failure(["call printf('%1$d %1$s', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
145 call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$s', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
146 call v9.CheckLegacyAndVim9Failure(["call printf('%1$ud %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
147 call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$f', 3.0)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
148 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*1$d %1$ld', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
149 call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
150 call v9.CheckLegacyAndVim9Failure(["call printf('%1$p %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
151 call v9.CheckLegacyAndVim9Failure(["call printf('%1$f %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
152 call v9.CheckLegacyAndVim9Failure(["call printf('%1$lud %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
153 call v9.CheckLegacyAndVim9Failure(["call printf('%1$llud %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
154 call v9.CheckLegacyAndVim9Failure(["call printf('%1$lld %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
155 call v9.CheckLegacyAndVim9Failure(["call printf('%1$s %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
156 call v9.CheckLegacyAndVim9Failure(["call printf('%1$c %1$d', 3)"], "E1504:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
157 call v9.CheckLegacyAndVim9Failure(["call printf('%1$ld %1$d', 3)"], "E1504:") |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
158 |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
159 call v9.CheckLegacyAndVim9Failure(["call printf('%1$.2$d', 3)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
160 call v9.CheckLegacyAndVim9Failure(["call printf('%01$d', 3)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
161 call v9.CheckLegacyAndVim9Failure(["call printf('%01$0d', 3)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
162 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*2d', 3)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
163 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3.*2$d', 3)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
164 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.2$d', 3)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
165 call v9.CheckLegacyAndVim9Failure(["call printf('%1$*3$.*2d', 3)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
166 call v9.CheckLegacyAndVim9Failure(["call printf('%1$1$.5d', 5)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
167 call v9.CheckLegacyAndVim9Failure(["call printf('%1$5.1$d', 5)"], "E1505:") |
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
168 call v9.CheckLegacyAndVim9Failure(["call printf('%1$1$.1$d', 5)"], "E1505:") |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 endfunc |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 func Test_printf_pos_float() |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 let lines =<< trim END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
173 call assert_equal('1.000000', printf('%1$f', 1)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 call assert_equal('1.230000', printf('%1$f', 1.23)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 call assert_equal('1.230000', printf('%1$F', 1.23)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 call assert_equal('9999999.9', printf('%1$g', 9999999.9)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 call assert_equal('9999999.9', printf('%1$G', 9999999.9)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 call assert_equal('1.230000e+00', printf('%1$e', 1.23)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 call assert_equal('1.230000E+00', printf('%1$E', 1.23)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 call assert_equal('1.200000e-02', printf('%1$e', 0.012)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 call assert_equal('-1.200000e-02', printf('%1$e', -0.012)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 call assert_equal('0.33', printf('%1$.2f', 1.0 / 3.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 #" When precision is 0, the dot should be omitted. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 call assert_equal(' 2', printf('%1$*2$.f', 7.0 / 3.0, 3)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 call assert_equal(' 2', printf('%2$*1$.f', 3, 7.0 / 3.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 call assert_equal(' 2', printf('%1$*2$.g', 7.0 / 3.0, 3)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 call assert_equal(' 2', printf('%2$*1$.g', 3, 7.0 / 3.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 call assert_equal(' 2e+00', printf('%1$*2$.e', 7.0 / 3.0, 7)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 call assert_equal(' 2e+00', printf('%2$*1$.e', 7, 7.0 / 3.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 #" Float zero can be signed. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 call assert_equal('+0.000000', printf('%1$+f', 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 call assert_equal('0.000000', printf('%1$f', 1.0 / (1.0 / 0.0))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 call assert_equal('-0.000000', printf('%1$f', 1.0 / (-1.0 / 0.0))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 call assert_equal('0.0', printf('%1$s', 1.0 / (1.0 / 0.0))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 call assert_equal('-0.0', printf('%1$s', 1.0 / (-1.0 / 0.0))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 call assert_equal('0.0', printf('%1$S', 1.0 / (1.0 / 0.0))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 call assert_equal('-0.0', printf('%1$S', 1.0 / (-1.0 / 0.0))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 #" Float infinity can be signed. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 call assert_equal('inf', printf('%1$f', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 call assert_equal('-inf', printf('%1$f', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 call assert_equal('inf', printf('%1$g', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 call assert_equal('-inf', printf('%1$g', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
206 call assert_equal('inf', printf('%1$e', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 call assert_equal('-inf', printf('%1$e', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 call assert_equal('INF', printf('%1$F', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 call assert_equal('-INF', printf('%1$F', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
210 call assert_equal('INF', printf('%1$E', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
211 call assert_equal('-INF', printf('%1$E', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 call assert_equal('INF', printf('%1$E', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 call assert_equal('-INF', printf('%1$G', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 call assert_equal('+inf', printf('%1$+f', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 call assert_equal('-inf', printf('%1$+f', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
216 call assert_equal(' inf', printf('%1$ f', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 call assert_equal(' inf', printf('%1$*2$f', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 call assert_equal(' -inf', printf('%1$*2$f', -1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
219 call assert_equal(' inf', printf('%1$*2$g', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 call assert_equal(' -inf', printf('%1$*2$g', -1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
221 call assert_equal(' +inf', printf('%1$+*2$f', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
222 call assert_equal(' inf', printf('%1$ *2$f', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
223 call assert_equal(' +inf', printf('%1$+0*2$f', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
224 call assert_equal('inf ', printf('%1$-*2$f', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
225 call assert_equal('-inf ', printf('%1$-*2$f', -1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 call assert_equal('+inf ', printf('%1$-+*2$f', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 call assert_equal(' inf ', printf('%1$- *2$f', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
228 call assert_equal('-INF ', printf('%1$-*2$F', -1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
229 call assert_equal('+INF ', printf('%1$-+*2$F', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
230 call assert_equal(' INF ', printf('%1$- *2$F', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
231 call assert_equal('INF ', printf('%1$-*2$G', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 call assert_equal('-INF ', printf('%1$-*2$G', -1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
233 call assert_equal('INF ', printf('%1$-*2$E', 1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
234 call assert_equal('-INF ', printf('%1$-*2$E', -1.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
235 call assert_equal(' inf', printf('%2$*1$f', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
236 call assert_equal(' -inf', printf('%2$*1$f', 6, -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 call assert_equal(' inf', printf('%2$*1$g', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
238 call assert_equal(' -inf', printf('%2$*1$g', 6, -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
239 call assert_equal(' +inf', printf('%2$+*1$f', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
240 call assert_equal(' inf', printf('%2$ *1$f', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
241 call assert_equal(' +inf', printf('%2$+0*1$f', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
242 call assert_equal('inf ', printf('%2$-*1$f', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
243 call assert_equal('-inf ', printf('%2$-*1$f', 6, -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 call assert_equal('+inf ', printf('%2$-+*1$f', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
245 call assert_equal(' inf ', printf('%2$- *1$f', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
246 call assert_equal('-INF ', printf('%2$-*1$F', 6, -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
247 call assert_equal('+INF ', printf('%2$-+*1$F', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
248 call assert_equal(' INF ', printf('%2$- *1$F', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
249 call assert_equal('INF ', printf('%2$-*1$G', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 call assert_equal('-INF ', printf('%2$-*1$G', 6, -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 call assert_equal('INF ', printf('%2$-*1$E', 6, 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
252 call assert_equal('-INF ', printf('%2$-*1$E', 6, -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 call assert_equal('inf', printf('%1$s', 1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 call assert_equal('-inf', printf('%1$s', -1.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
255 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 #" Test special case where max precision is truncated at 340. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 call assert_equal('1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%1$.*2$f', 1.0, 330)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 call assert_equal('1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%2$.*1$f', 330, 1.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%1$.*2$f', 1.0, 340)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%2$.*1$f', 340, 1.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%1$.*2$f', 1.0, 350)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
262 call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%2$.*1$f', 350, 1.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
264 #" Float nan (not a number) has no sign. |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
265 call assert_equal('nan', printf('%1$f', sqrt(-1.0))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
266 call assert_equal('nan', printf('%1$f', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
267 call assert_equal('nan', printf('%1$f', -0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
268 call assert_equal('nan', printf('%1$g', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
269 call assert_equal('nan', printf('%1$e', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
270 call assert_equal('NAN', printf('%1$F', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
271 call assert_equal('NAN', printf('%1$G', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 call assert_equal('NAN', printf('%1$E', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
273 call assert_equal('NAN', printf('%1$F', -0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
274 call assert_equal('NAN', printf('%1$G', -0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
275 call assert_equal('NAN', printf('%1$E', -0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
276 call assert_equal(' nan', printf('%1$*2$f', 0.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 call assert_equal(' nan', printf('%1$0*2$f', 0.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
278 call assert_equal('nan ', printf('%1$-*2$f', 0.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
279 call assert_equal('nan ', printf('%1$- *2$f', 0.0 / 0.0, 6)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 call assert_equal(' nan', printf('%2$*1$f', 6, 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 call assert_equal(' nan', printf('%2$0*1$f', 6, 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 call assert_equal('nan ', printf('%2$-*1$f', 6, 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
283 call assert_equal('nan ', printf('%2$- *1$f', 6, 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
284 call assert_equal('nan', printf('%1$s', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
285 call assert_equal('nan', printf('%1$s', -0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
286 call assert_equal('nan', printf('%1$S', 0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
287 call assert_equal('nan', printf('%1$S', -0.0 / 0.0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
288 END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
289 call v9.CheckLegacyAndVim9Success(lines) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
290 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
291 call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
292 endfunc |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
293 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
294 func Test_printf_pos_errors() |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
295 call v9.CheckLegacyAndVim9Failure(['echo printf("%1$d", {})'], 'E728:') |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
296 call v9.CheckLegacyAndVim9Failure(['echo printf("%1$d", [])'], 'E745:') |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
297 call v9.CheckLegacyAndVim9Failure(['echo printf("%1$d", 1, 2)'], 'E767:') |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
298 call v9.CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:') |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
299 call v9.CheckLegacyAndVim9Failure(['echo printf("%1$s")'], 'E1503:') |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
300 call v9.CheckLegacyAndVim9Failure(['echo printf("%1$d", 1.2)'], 'E805:') |
33383
5c12ca4dcd45
patch 9.0.1950: Vim9: error codes spread out
Christian Brabandt <cb@256bit.org>
parents:
32775
diff
changeset
|
301 call v9.CheckLegacyAndVim9Failure(['echo printf("%1$f")'], 'E1503:') |
32775
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
302 endfunc |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
303 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
304 func Test_printf_pos_64bit() |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
305 let lines =<< trim END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
306 call assert_equal("123456789012345", printf('%1$d', 123456789012345)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
308 call v9.CheckLegacyAndVim9Success(lines) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
309 endfunc |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
310 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
311 func Test_printf_pos_spec_s() |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
312 let lines =<< trim END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
313 #" number |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
314 call assert_equal("1234567890", printf('%1$s', 1234567890)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
315 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
316 #" string |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
317 call assert_equal("abcdefgi", printf('%1$s', "abcdefgi")) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
318 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
319 #" float |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
320 call assert_equal("1.23", printf('%1$s', 1.23)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
321 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
322 #" list |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
323 VAR lvalue = [1, 'two', ['three', 4]] |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
324 call assert_equal(string(lvalue), printf('%1$s', lvalue)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
325 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
326 #" dict |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
327 VAR dvalue = {'key1': 'value1', 'key2': ['list', 'lvalue'], 'key3': {'dict': 'lvalue'}} |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
328 call assert_equal(string(dvalue), printf('%1$s', dvalue)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
329 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
330 #" funcref |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
331 call assert_equal('printf', printf('%1$s', 'printf'->function())) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
332 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
333 #" partial |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
334 call assert_equal(string(function('printf', ['%1$s'])), printf('%1$s', function('printf', ['%1$s']))) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
335 END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
336 call v9.CheckLegacyAndVim9Success(lines) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
337 endfunc |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
338 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
339 func Test_printf_pos_spec_b() |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
340 let lines =<< trim END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
341 call assert_equal("0", printf('%1$b', 0)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
342 call assert_equal("00001100", printf('%1$0*2$b', 12, 8)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
343 call assert_equal("11111111", printf('%1$0*2$b', 0xff, 8)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
344 call assert_equal(" 1111011", printf('%1$*2$b', 123, 10)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
345 call assert_equal("0001111011", printf('%1$0*2$b', 123, 10)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
346 call assert_equal(" 0b1111011", printf('%1$#*2$b', 123, 10)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
347 call assert_equal("0B01111011", printf('%1$#0*2$B', 123, 10)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
348 call assert_equal("00001100", printf('%2$0*1$b', 8, 12)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
349 call assert_equal("11111111", printf('%2$0*1$b', 8, 0xff)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
350 call assert_equal(" 1111011", printf('%2$*1$b', 10, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
351 call assert_equal("0001111011", printf('%2$0*1$b', 10, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
352 call assert_equal(" 0b1111011", printf('%2$#*1$b', 10, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
353 call assert_equal("0B01111011", printf('%2$#0*1$B', 10, 123)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
354 call assert_equal("1001001100101100000001011010010", printf('%1$b', 1234567890)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
355 call assert_equal("11100000100100010000110000011011101111101111001", printf('%1$b', 123456789012345)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
356 call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%1$b', -1)) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
357 END |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
358 call v9.CheckLegacyAndVim9Success(lines) |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
359 endfunc |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
360 |
2d5e8c46508b
patch 9.0.1704: Cannot use positional arguments for printf()
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
361 " vim: shiftwidth=2 sts=2 expandtab |