Skip to content
Newer
Older
100644 72 lines (55 sloc) 3.18 KB
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
b97299f Test suite refactoring (spec/S29)
cosimo authored
2
3 use Test;
4
91d1b92 @moritz remove test for deprecated %C sprintf format
moritz authored
5 plan 43;
b97299f Test suite refactoring (spec/S29)
cosimo authored
6
b7f4853 point several smartlinks to the S32::Str specs
szabgab authored
7 # L<S32::Str/Str/"identical to" "C library sprintf">
b97299f Test suite refactoring (spec/S29)
cosimo authored
8
9 is sprintf("Hi"), "Hi", "sprintf() works with zero args";
56f8736 [gsoc_spectest] Moved elems.t to spec area, added smartlink. Added 25…
Auzon authored
10 is sprintf("%%"), "%", "sprintf() escapes % correctly";
b97299f Test suite refactoring (spec/S29)
cosimo authored
11 is sprintf("%03d", 3), "003", "sprintf() works with one arg";
12 is sprintf("%03d %02d", 3, 1), "003 01", "sprintf() works with two args";
13 is sprintf("%d %d %d", 3,1,4), "3 1 4", "sprintf() works with three args";
14 is sprintf("%d%d%d%d", 3,1,4,1), "3141", "sprintf() works with four args";
15
16 ok(eval('sprintf("%b",1)'), 'eval of sprintf() with %b');
17
18 is sprintf("%04b",3), '0011', '0-padded sprintf() with %b';
19 is sprintf("%4b",3), ' 11', '" "-padded sprintf() with %b';
20 is sprintf("%b",30), '11110', 'longer string, no padding';
21 is sprintf("%2b",30), '11110', 'padding specified, not needed';
22 is sprintf("%03b",7), '111', '0 padding, longer string';
23 is sprintf("%b %b",3,3), '11 11', 'two args %b';
56f8736 [gsoc_spectest] Moved elems.t to spec area, added smartlink. Added 25…
Auzon authored
24
25 is sprintf('%c', 97), 'a', '%c test';
26 is sprintf('%s', 'string'), 'string', '%s test';
27
28 is sprintf('%d', 12), '12', 'simple %d';
29 is sprintf('%d', -22), '-22', 'negative %d';
30 is sprintf('%04d', 32), '0032', '0-padded %d';
31 is sprintf('%04d', -42), '-042', '0-padded negative %d';
32 is sprintf('%i', -22), '-22', 'negative %i';
33 is sprintf('%04i', -42), '-042', '0-padded negative %i';
34
35 is sprintf('%u', 12), '12', 'simple %u';
36 is sprintf('%u', 22.01), '22', 'decimal %u';
37 is sprintf('%04u', 32), '0032', '0-padded %u';
38 is sprintf('%04u', 42.6), '0042', '0-padded decimal %u';
39
40 is sprintf('%o', 12), '14', 'simple %o';
41 is sprintf('%o', 22.01), '26', 'decimal %o';
42 is sprintf('%03o', 32), '040', '0-padded %o';
43 is sprintf('%03o', 42.6), '052', '0-padded decimal %o';
44
45 is sprintf('%x', 12), 'c', 'simple %x';
46 is sprintf('%x', 22.01), '16', 'decimal %x';
47 is sprintf('%03x', 32), '020', '0-padded %x';
48 is sprintf('%03x', 42.6), '02a', '0-padded decimal %x';
49 # tests for %X
759a089 [spec] Fix typo in test
bacek authored
50 is sprintf('%X', 12), 'C', 'simple %X';
56f8736 [gsoc_spectest] Moved elems.t to spec area, added smartlink. Added 25…
Auzon authored
51 is sprintf('%03X', 42.6), '02A', '0-padded decimal %X';
52
b7f4853 point several smartlinks to the S32::Str specs
szabgab authored
53 # L<S32::Str/"Str"/"The special directive, %n does not work in Perl 6">
8dc7d4b [t/spec] mark various tests that intentionally declare things that ar…
lwall authored
54 dies_ok(sub {my $x = sprintf('%n', 1234)}, '%n dies (Perl 5 compatibility)'); #OK not used
b25da6e [sprintf.t] Untodoed a passing test.
Kodi Arfer authored
55 #?rakudo todo "%p doesn't yet throw exception - but should it, or just Failure?"
8dc7d4b [t/spec] mark various tests that intentionally declare things that ar…
lwall authored
56 dies_ok(sub {my $x = sprintf('%p', 1234)}, '%p dies (Perl 5 compatibility)'); #OK not used
d3bb812 Tests for sprintf %s handling of NaN and Inf
leto authored
57
58 is sprintf('%s', NaN), NaN, 'sprintf %s handles NaN';
59 is sprintf('%s', -NaN), NaN, 'sprintf %s handles NaN';
60 is sprintf('%s', Inf), Inf, 'sprintf %s handles Inf';
61 is sprintf('%s', -Inf), -Inf, 'sprintf %s handles Inf';
8d3bb74 add tests for missing argument and %C format: RT #62316 and RT #60672
ron authored
62
632918e @flussence Oops, didn't realise skip comments were special. flussence--
flussence authored
63 #?rakudo skip "doesn't work in master (as of 2010-07)"
64 {
5f09039 @flussence Add a test for printf positional arg specifiers
flussence authored
65 is sprintf('%d %1$x %1$o', 12), '12 c 14', 'positional argument specifier $';
632918e @flussence Oops, didn't realise skip comments were special. flussence--
flussence authored
66 }
5f09039 @flussence Add a test for printf positional arg specifiers
flussence authored
67
207e6b4 [sprintf.t] Changes for RT #74610.
Kodi Arfer authored
68 # RT #74610
69 dies_ok {sprintf "%s"}, 'missing sprintf string argument';
8d3bb74 add tests for missing argument and %C format: RT #62316 and RT #60672
ron authored
70
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
71 # vim: ft=perl6
Something went wrong with that request. Please try again.