Skip to content

Commit

Permalink
Simplify sprintf("%u") 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 2624c93 commit 795a3b6
Showing 1 changed file with 2 additions and 47 deletions.
49 changes: 2 additions & 47 deletions S32-str/sprintf-u.t
Expand Up @@ -30,22 +30,6 @@ my @info = ( # |-----------|-----------|-----------|
'-+0', '', "0", "1", "314",
'-0 ', '', "0", "1", "314",
'-+0 ', '', "0", "1", "314",
'#', '', "0", "1", "314",
'# ', '', "0", "1", "314",
'#0', '', "0", "1", "314",
'#0 ', '', "0", "1", "314",
'#+', '', "0", "1", "314",
'#+ ', '', "0", "1", "314",
'#+0', '', "0", "1", "314",
'#+0 ', '', "0", "1", "314",
'#-', '', "0", "1", "314",
'#-+', '', "0", "1", "314",
'#- ', '', "0", "1", "314",
'#-+ ', '', "0", "1", "314",
'#-0', '', "0", "1", "314",
'#-+0', '', "0", "1", "314",
'#-0 ', '', "0", "1", "314",
'#-+0 ', '', "0", "1", "314",

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

# 8 positions, should always fit
'', 8, " 0", " 1", " 314",
Expand All @@ -98,26 +66,13 @@ my @info = ( # |-----------|-----------|-----------|
'-+0', 8, "0 ", "1 ", "314 ",
'-0 ', 8, "0 ", "1 ", "314 ",
'-+0 ', 8, "0 ", "1 ", "314 ",
'#', 8, " 0", " 1", " 314",
'#0', 8, "00000000", "00000001", "00000314",
'#0 ', 8, "00000000", "00000001", "00000314",
'#+', 8, " 0", " 1", " 314",
'#+ ', 8, " 0", " 1", " 314",
'#+0', 8, "00000000", "00000001", "00000314",
'#+0 ', 8, "00000000", "00000001", "00000314",
'#-', 8, "0 ", "1 ", "314 ",
'#-+', 8, "0 ", "1 ", "314 ",
'#- ', 8, "0 ", "1 ", "314 ",
'#-+ ', 8, "0 ", "1 ", "314 ",
'#-0', 8, "0 ", "1 ", "314 ",
'#-+0', 8, "0 ", "1 ", "314 ",
'#-0 ', 8, "0 ", "1 ", "314 ",
'#-+0 ', 8, "0 ", "1 ", "314 ",

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

Expand Down

0 comments on commit 795a3b6

Please sign in to comment.