Skip to content

Commit

Permalink
Add variable precision tests for "%b|B"
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Apr 19, 2019
1 parent 6357b3c commit 3b52d99
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions S32-str/sprintf-b.t
Expand Up @@ -192,6 +192,95 @@ my @info = ( # |-----------|-----------|-----------|-----------|
|@flat
}

# tests using variable precision 0
@info.append( (
# no size, precision 0
'', '.*', "", "1", "100", "-100",
' ', '.*', "", " 1", " 100", "-100",
'0', '.*', "", "1", "100", "-100",
'0 ', '.*', "", " 1", " 100", "-100",
'+', '.*', "", "+1", "+100", "-100",
'+ ', '.*', "", "+1", "+100", "-100",
'+0', '.*', "", "+1", "+100", "-100",
'+0 ', '.*', "", "+1", "+100", "-100",
'-', '.*', "", "1", "100", "-100",
'-+', '.*', "", "+1", "+100", "-100",
'- ', '.*', "", " 1", " 100", "-100",
'-+ ', '.*', "", "+1", "+100", "-100",
'-0', '.*', "", "1", "100", "-100",
'-+0', '.*', "", "+1", "+100", "-100",
'-0 ', '.*', "", " 1", " 100", "-100",
'-+0 ', '.*', "", "+1", "+100", "-100",
'#', '.*', "", "0b1", "0b100", "-0b100",
'# ', '.*', "", " 0b1", " 0b100", "-0b100",
'#0', '.*', "", "0b1", "0b100", "-0b100",
'#0 ', '.*', "", " 0b1", " 0b100", "-0b100",
'#+', '.*', "", "+0b1", "+0b100", "-0b100",
'#+ ', '.*', "", "+0b1", "+0b100", "-0b100",
'#+0', '.*', "", "+0b1", "+0b100", "-0b100",
'#+0 ', '.*', "", "+0b1", "+0b100", "-0b100",
'#-', '.*', "", "0b1", "0b100", "-0b100",
'#-+', '.*', "", "+0b1", "+0b100", "-0b100",
'#- ', '.*', "", " 0b1", " 0b100", "-0b100",
'#-+ ', '.*', "", "+0b1", "+0b100", "-0b100",
'#-0', '.*', "", "0b1", "0b100", "-0b100",
'#-+0', '.*', "", "+0b1", "+0b100", "-0b100",
'#-0 ', '.*', "", " 0b1", " 0b100", "-0b100",
'#-+0 ', '.*', "", "+0b1", "+0b100", "-0b100",

).map: -> $flags, $size, $r0, $r1, $r4, $rm {
my @flat;
@flat.append(
'%' ~ $_ ~ $size ~ 'b',
($r0 => (0,0), $r1 => (0,1), $r4 => (0,4), $rm => (0,-4))
) for $flags.comb.permutations>>.join;
|@flat
} );

@info.append( (
# 8 positions with precision, precision fits sometimes
'', "8.*", " 00", " 01", " 100", " -100",
' ', "8.*", " 00", " 01", " 100", " -100",
'0', "8.*", " 00", " 01", " 100", " -100",
'0 ', "8.*", " 00", " 01", " 100", " -100",
'+', "8.*", " +00", " +01", " +100", " -100",
'+ ', "8.*", " +00", " +01", " +100", " -100",
'+0', "8.*", " +00", " +01", " +100", " -100",
'+0 ', "8.*", " +00", " +01", " +100", " -100",
'-', "8.*", "00 ", "01 ", "100 ", "-100 ",
'-+', "8.*", "+00 ", "+01 ", "+100 ", "-100 ",
'- ', "8.*", " 00 ", " 01 ", " 100 ", "-100 ",
'-+ ', "8.*", "+00 ", "+01 ", "+100 ", "-100 ",
'-0', "8.*", "00 ", "01 ", "100 ", "-100 ",
'-+0', "8.*", "+00 ", "+01 ", "+100 ", "-100 ",
'-0 ', "8.*", " 00 ", " 01 ", " 100 ", "-100 ",
'-+0 ', "8.*", "+00 ", "+01 ", "+100 ", "-100 ",
'#', "8.*", " 00", " 0b01", " 0b100", " -0b100",
'# ', "8.*", " 00", " 0b01", " 0b100", " -0b100",
'#0', "8.*", " 00", " 0b01", " 0b100", " -0b100",
'#0 ', "8.*", " 00", " 0b01", " 0b100", " -0b100",
'#+', "8.*", " +00", " +0b01", " +0b100", " -0b100",
'#+ ', "8.*", " +00", " +0b01", " +0b100", " -0b100",
'#+0', "8.*", " +00", " +0b01", " +0b100", " -0b100",
'#+0 ', "8.*", " +00", " +0b01", " +0b100", " -0b100",
'#-', "8.*", "00 ", "0b01 ", "0b100 ", "-0b100 ",
'#-+', "8.*", "+00 ", "+0b01 ", "+0b100 ", "-0b100 ",
'#- ', "8.*", " 00 ", " 0b01 ", " 0b100 ", "-0b100 ",
'#-+ ', "8.*", "+00 ", "+0b01 ", "+0b100 ", "-0b100 ",
'#-0', "8.*", "00 ", "0b01 ", "0b100 ", "-0b100 ",
'#-+0', "8.*", "+00 ", "+0b01 ", "+0b100 ", "-0b100 ",
'#-0 ', "8.*", " 00 ", " 0b01 ", " 0b100 ", "-0b100 ",
'#-+0 ', "8.*", "+00 ", "+0b01 ", "+0b100 ", "-0b100 ",

).map: -> $flags, $size, $r0, $r1, $r4, $rm {
my @flat;
@flat.append(
'%' ~ $_ ~ $size ~ 'b',
($r0 => (2,0), $r1 => (2,1), $r4 => (2,4), $rm => (2,-4))
) for $flags.comb.permutations>>.join;
|@flat
} );

plan @info/2;

for @info -> $format, @tests {
Expand Down

0 comments on commit 3b52d99

Please sign in to comment.