Skip to content

Commit bc1b736

Browse files
author
Douglas Schrag
committed
Add tests for sprintf octal with precision
Test octal precision with and without the '#' flag. Ensure conformance with POSIX sprintf.
1 parent bc4ffab commit bc1b736

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

t/hll/06-sprintf.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ sub is($actual, $expected, $description) {
2222
}
2323
}
2424

25-
plan(280);
25+
plan(284);
2626

2727
is(nqp::sprintf('Walter Bishop', []), 'Walter Bishop', 'no directives' );
2828

@@ -89,6 +89,10 @@ is(nqp::sprintf('%o', [12]), '14', 'simple %o');
8989
is(nqp::sprintf('%o', [22.01]), '26', 'decimal %o');
9090
is(nqp::sprintf('%06o', [127]), '000177', '%o with 0-padding');
9191
is(nqp::sprintf('%#6o', [127]), ' 0177', '%o with space-padding and leading 0');
92+
is(nqp::sprintf('%.5o', [83]), '00123', '%o with precision');
93+
is(nqp::sprintf('%#.5o', [83]), '00123', '%o with precision, leading 0 not required');
94+
is(nqp::sprintf('%.5o', [5349]), '12345', '%o with insufficient precision');
95+
is(nqp::sprintf('%#.5o', [5349]), '012345', '%o with precision, required leading 0 added');
9296

9397
is(nqp::sprintf('%x', [0]), '0', 'simple %x');
9498
is(nqp::sprintf('%x', [12]), 'c', 'simple %x');

0 commit comments

Comments
 (0)