Skip to content

Commit

Permalink
Simplify sprintf("%d"|"%i") testing
Browse files Browse the repository at this point in the history
The results of all formats with "#" are the same to the results without
"#", so create those tests programatically.
  • Loading branch information
lizmat committed Apr 17, 2019
1 parent 78d5fe2 commit 2624c93
Showing 1 changed file with 4 additions and 78 deletions.
82 changes: 4 additions & 78 deletions S32-str/sprintf-d.t
Expand Up @@ -31,22 +31,6 @@ my @info = ( # |-----------|-----------|-----------|-----------|
'-+0', '', "+0", "+1", "+314", "-314",
'-0 ', '', " 0", " 1", " 314", "-314",
'-+0 ', '', "+0", "+1", "+314", "-314",
'#', '', "0", "1", "314", "-314",
'# ', '', " 0", " 1", " 314", "-314",
'#0', '', "0", "1", "314", "-314",
'#0 ', '', " 0", " 1", " 314", "-314",
'#+', '', "+0", "+1", "+314", "-314",
'#+ ', '', "+0", "+1", "+314", "-314",
'#+0', '', "+0", "+1", "+314", "-314",
'#+0 ', '', "+0", "+1", "+314", "-314",
'#-', '', "0", "1", "314", "-314",
'#-+', '', "+0", "+1", "+314", "-314",
'#- ', '', " 0", " 1", " 314", "-314",
'#-+ ', '', "+0", "+1", "+314", "-314",
'#-0', '', "0", "1", "314", "-314",
'#-+0', '', "+0", "+1", "+314", "-314",
'#-0 ', '', " 0", " 1", " 314", "-314",
'#-+0 ', '', "+0", "+1", "+314", "-314",

# no size, precision 0
'', '.0', "", "1", "314", "-314",
Expand All @@ -65,22 +49,6 @@ my @info = ( # |-----------|-----------|-----------|-----------|
'-+0', '.0', "+", "+1", "+314", "-314",
'-0 ', '.0', " ", " 1", " 314", "-314",
'-+0 ', '.0', "+", "+1", "+314", "-314",
'#', '.0', "", "1", "314", "-314",
'# ', '.0', " ", " 1", " 314", "-314",
'#0', '.0', "", "1", "314", "-314",
'#0 ', '.0', " ", " 1", " 314", "-314",
'#+', '.0', "+", "+1", "+314", "-314",
'#+ ', '.0', "+", "+1", "+314", "-314",
'#+0', '.0', "+", "+1", "+314", "-314",
'#+0 ', '.0', "+", "+1", "+314", "-314",
'#-', '.0', "", "1", "314", "-314",
'#-+', '.0', "+", "+1", "+314", "-314",
'#- ', '.0', " ", " 1", " 314", "-314",
'#-+ ', '.0', "+", "+1", "+314", "-314",
'#-0', '.0', "", "1", "314", "-314",
'#-+0', '.0', "+", "+1", "+314", "-314",
'#-0 ', '.0', " ", " 1", " 314", "-314",
'#-+0 ', '.0', "+", "+1", "+314", "-314",

# 2 positions, usually doesn't fit
'', 2, " 0", " 1", "314", "-314",
Expand All @@ -99,22 +67,6 @@ my @info = ( # |-----------|-----------|-----------|-----------|
'-+0', 2, "+0", "+1", "+314", "-314",
'-0 ', 2, " 0", " 1", " 314", "-314",
'-+0 ', 2, "+0", "+1", "+314", "-314",
'#', 2, " 0", " 1", "314", "-314",
'# ', 2, " 0", " 1", " 314", "-314",
'#0', 2, "00", "01", "314", "-314",
'#0 ', 2, " 0", " 1", " 314", "-314",
'#+', 2, "+0", "+1", "+314", "-314",
'#+ ', 2, "+0", "+1", "+314", "-314",
'#+0', 2, "+0", "+1", "+314", "-314",
'#+0 ', 2, "+0", "+1", "+314", "-314",
'#-', 2, "0 ", "1 ", "314", "-314",
'#-+', 2, "+0", "+1", "+314", "-314",
'#- ', 2, " 0", " 1", " 314", "-314",
'#-+ ', 2, "+0", "+1", "+314", "-314",
'#-0', 2, "0 ", "1 ", "314", "-314",
'#-+0', 2, "+0", "+1", "+314", "-314",
'#-0 ', 2, " 0", " 1", " 314", "-314",
'#-+0 ', 2, "+0", "+1", "+314", "-314",

# 8 positions, should always fit
'', 8, " 0", " 1", " 314", " -314",
Expand All @@ -133,21 +85,6 @@ my @info = ( # |-----------|-----------|-----------|-----------|
'-+0', 8, "+0 ", "+1 ", "+314 ", "-314 ",
'-0 ', 8, " 0 ", " 1 ", " 314 ", "-314 ",
'-+0 ', 8, "+0 ", "+1 ", "+314 ", "-314 ",
'#', 8, " 0", " 1", " 314", " -314",
'#0', 8, "00000000", "00000001", "00000314", "-0000314",
'#0 ', 8, " 0000000", " 0000001", " 0000314", "-0000314",
'#+', 8, " +0", " +1", " +314", " -314",
'#+ ', 8, " +0", " +1", " +314", " -314",
'#+0', 8, "+0000000", "+0000001", "+0000314", "-0000314",
'#+0 ', 8, "+0000000", "+0000001", "+0000314", "-0000314",
'#-', 8, "0 ", "1 ", "314 ", "-314 ",
'#-+', 8, "+0 ", "+1 ", "+314 ", "-314 ",
'#- ', 8, " 0 ", " 1 ", " 314 ", "-314 ",
'#-+ ', 8, "+0 ", "+1 ", "+314 ", "-314 ",
'#-0', 8, "0 ", "1 ", "314 ", "-314 ",
'#-+0', 8, "+0 ", "+1 ", "+314 ", "-314 ",
'#-0 ', 8, " 0 ", " 1 ", " 314 ", "-314 ",
'#-+0 ', 8, "+0 ", "+1 ", "+314 ", "-314 ",

# 8 positions with precision, precision fits sometimes
'', 8.2, " 00", " 01", " 314", " -314",
Expand All @@ -166,28 +103,17 @@ my @info = ( # |-----------|-----------|-----------|-----------|
'-+0', 8.2, "+00 ", "+01 ", "+314 ", "-314 ",
'-0 ', 8.2, " 00 ", " 01 ", " 314 ", "-314 ",
'-+0 ', 8.2, "+00 ", "+01 ", "+314 ", "-314 ",
'#', 8.2, " 00", " 01", " 314", " -314",
'#0', 8.2, " 00", " 01", " 314", " -314",
'#0 ', 8.2, " 00", " 01", " 314", " -314",
'#+', 8.2, " +00", " +01", " +314", " -314",
'#+ ', 8.2, " +00", " +01", " +314", " -314",
'#+0', 8.2, " +00", " +01", " +314", " -314",
'#+0 ', 8.2, " +00", " +01", " +314", " -314",
'#-', 8.2, "00 ", "01 ", "314 ", "-314 ",
'#-+', 8.2, "+00 ", "+01 ", "+314 ", "-314 ",
'#- ', 8.2, " 00 ", " 01 ", " 314 ", "-314 ",
'#-+ ', 8.2, "+00 ", "+01 ", "+314 ", "-314 ",
'#-0', 8.2, "00 ", "01 ", "314 ", "-314 ",
'#-+0', 8.2, "+00 ", "+01 ", "+314 ", "-314 ",
'#-0 ', 8.2, " 00 ", " 01 ", " 314 ", "-314 ",
'#-+0 ', 8.2, "+00 ", "+01 ", "+314 ", "-314 ",

).map: -> $flags, $size, $r0, $r1, $r4, $rm {
my @flat;
for $flags.comb.permutations>>.join -> $permuted {
@flat.append('%' ~ $permuted ~ $size ~ $_, $r0, $r1, $r4, $rm)
for <d i>;
}
for "#$flags".comb.permutations>>.join -> $permuted {
@flat.append('%' ~ $permuted ~ $size ~ $_, $r0, $r1, $r4, $rm)
for <d i>;
}
|@flat
}

Expand Down

0 comments on commit 2624c93

Please sign in to comment.