Results for builtin-printf.test.sh

statusoshosh_.pyosh_.cc
pass 292318
ok 555
N-I 877
FAIL 1813
total434343
caseoshosh_.pyosh_.ccdescription
0pass pass pass printf with no args
1pass FAIL FAIL printf -v %s
detailsdetails
2pass pass pass printf -v %q
3pass FAIL FAIL printf -v a[1]
detailsdetails
4pass pass pass printf -v syntax error
5pass FAIL FAIL dynamic declare instead of %s
detailsdetails
6ok ok ok dynamic declare instead of %q
detailsdetailsdetails
7ok ok ok printf -v dynamic scope
detailsdetailsdetails
8pass pass pass printf with too few arguments
9pass pass pass printf with too many arguments
10pass pass pass printf width strings
11pass pass pass printf integer
12N-I N-I N-I printf %6.4d -- precision means something different for integers !?
detailsdetailsdetails
13pass pass FAIL printf %6.4s does both truncation and padding
details
14pass pass pass printf %6.0s and %0.0s
15pass pass pass printf %6.s and %0.s
16pass pass pass printf %*.*s (width/precision from args)
17pass pass pass unsigned / octal / hex
18ok ok ok empty string (osh is more strict)
detailsdetailsdetails
19pass pass pass No char after ' (osh is more strict)
20FAIL FAIL FAIL Unicode char with ' (osh is more strict)
detailsdetailsdetails
21N-I N-I N-I negative numbers with unsigned / octal / hex
detailsdetailsdetails
22N-I N-I N-I printf floating point (not required, but they all implement it)
detailsdetailsdetails
23N-I N-I N-I printf floating point with - and 0
detailsdetailsdetails
24N-I N-I N-I printf eE fF gG
detailsdetailsdetails
25pass FAIL FAIL printf backslash escapes
detailsdetails
26pass FAIL FAIL printf octal backslash escapes
detailsdetails
27pass FAIL FAIL printf unicode backslash escapes
detailsdetails
28pass pass pass printf invalid backslash escape (is ignored)
29pass pass pass printf % escapes
30pass pass pass printf %b backslash escaping
31pass pass pass printf %b with \c early return
32N-I FAIL FAIL printf %c -- doesn't respect UTF-8! Bad.
detailsdetailsdetails
33ok ok ok printf invalid format
detailsdetailsdetails
34pass pass pass printf %q
35pass pass pass printf %6q (width)
36N-I N-I N-I printf + and space flags
detailsdetailsdetails
37N-I N-I N-I printf # flag
detailsdetailsdetails
38ok ok ok Runtime error for invalid integer
detailsdetailsdetails
39pass pass FAIL %(strftime format)T
details
40pass pass FAIL %(strftime format)T doesn't respect TZ if not exported
details
41pass pass FAIL %(strftime format)T TZ in environ but not in shell's memory
details
42pass pass FAIL %10.5(strftime format)T
details
70 passed, 15 OK, 22 not implemented, 0 BUG, 22 failed, 0 timeouts, 0 cases skipped
1 failed under osh

Details on runs that didn't PASS

osh_.py1 printf -v %s

[osh_.py stdout] Expected "['hello there']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "$foo"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh_.cc1 printf -v %s

[osh_.cc stdout] Expected "['hello there']\n", got ''
[osh_.cc status] Expected 0, got 127

stdout:
stderr: 
  argv.py "$foo"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh_.py3 printf -v a[1]

[osh_.py stdout] Expected "status=0\n['a', 'foo', 'c']\n", got 'status=0\n'
[osh_.py status] Expected 0, got 127

stdout:
status=0
stderr:
  argv.py "${a[@]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
osh_.cc3 printf -v a[1]

[osh_.cc stdout] Expected "status=0\n['a', 'foo', 'c']\n", got 'status=0\n'
[osh_.cc status] Expected 0, got 127

stdout:
status=0
stderr:
  argv.py "${a[@]}"
  ^~~~~~~
[ stdin ]:5: 'argv.py' not found
osh_.py5 dynamic declare instead of %s

[osh_.py stdout] Expected "['hello there']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "$foo"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh_.cc5 dynamic declare instead of %s

[osh_.cc stdout] Expected "['hello there']\n", got ''
[osh_.cc status] Expected 0, got 127

stdout:
stderr: 
  argv.py "$foo"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
osh6 dynamic declare instead of %q

stdout:
$'"quoted" with spaces and \\'
stderr:
osh_.py6 dynamic declare instead of %q

stdout:
$'"quoted" with spaces and \\'
stderr:
osh_.cc6 dynamic declare instead of %q

stdout:
$'"quoted" with spaces and \\'
stderr:
osh7 printf -v dynamic scope

stdout:
dollar=dollar
--
dollar='$'
mylocal=mylocal
--
dollar='$'
mylocal=
stderr:
osh_.py7 printf -v dynamic scope

stdout:
dollar=dollar
--
dollar='$'
mylocal=mylocal
--
dollar='$'
mylocal=
stderr:
osh_.cc7 printf -v dynamic scope

stdout:
dollar=dollar
--
dollar='$'
mylocal=mylocal
--
dollar='$'
mylocal=
stderr:
osh12 printf %6.4d -- precision means something different for integers !?

stdout:
stderr: 
  [%6.4d]\n
      ^
(source.ArgvWord word_spid:2):1: printf precision can't be specified with type 'd'
osh_.py12 printf %6.4d -- precision means something different for integers !?

stdout:
stderr: 
  [%6.4d]\n
      ^
(source.ArgvWord word_spid:2):1: printf precision can't be specified with type 'd'
osh_.cc12 printf %6.4d -- precision means something different for integers !?

stdout:
stderr: 
  [%6.4d]\n
      ^
TODO:1: dynamic_fmt_dummy
osh_.cc13 printf %6.4s does both truncation and padding

[osh_.cc stdout] Expected '[ foo]\n[ foo]\n[foo ]\n[spam-eggs]\n[ spam]\n[spam ]\n', got '[ foo]\n[ foo\x00]\n[foo\x00 ]\n[spam-eggs]\n[ spam]\n[spam ]\n'

stdout:
[   foo]
[  foo]
[foo  ]
[spam-eggs]
[  spam]
[spam  ]
stderr:
osh18 empty string (osh is more strict)

stdout:
stderr: 
  printf '%d\n' ''
                ^
[ stdin ]:1: printf expected an integer, got ''
osh_.py18 empty string (osh is more strict)

stdout:
stderr: 
  printf '%d\n' ''
                ^
[ stdin ]:1: printf expected an integer, got ''
osh_.cc18 empty string (osh is more strict)

stdout:
stderr: 
  printf '%d\n' ''
                ^
[ stdin ]:1: printf expected an integer, got ''
osh20 Unicode char with ' (osh is more strict)

[osh stdout] Expected '3bc\n', got 'ce\n'

stdout:
ce
stderr:
osh_.py20 Unicode char with ' (osh is more strict)

[osh_.py stdout] Expected '3bc\n', got 'ce\n'

stdout:
ce
stderr:
osh_.cc20 Unicode char with ' (osh is more strict)

[osh_.cc stdout] Expected '3bc\n', got 'ce\n'

stdout:
ce
stderr:
osh21 negative numbers with unsigned / octal / hex

stdout:
stderr: 
  [%u]\n
    ^
(source.ArgvWord word_spid:2):1: fatal: Can't format negative number -42 with %u
osh_.py21 negative numbers with unsigned / octal / hex

stdout:
stderr: 
  [%u]\n
    ^
(source.ArgvWord word_spid:2):1: fatal: Can't format negative number -42 with %u
osh_.cc21 negative numbers with unsigned / octal / hex

stdout:
stderr: 
  printf '[%u]\n' -42
  ^~~~~~
[ stdin ]:1: fatal: Can't format negative number -42 with %u
osh22 printf floating point (not required, but they all implement it)

stdout:
stderr: 
  [%f]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support floating point
  [%.2f]\n
      ^
(source.ArgvWord word_spid:13):1: osh printf doesn't support floating point
  [%8.2f]\n
       ^
(source.ArgvWord word_spid:26):1: osh printf doesn't support floating point
  [%-8.2f]\n
        ^
(source.ArgvWord word_spid:40):1: osh printf doesn't support floating point
  [%-f]\n
     ^
(source.ArgvWord word_spid:55):1: osh printf doesn't support floating point
  [%-f]\n
     ^
(source.ArgvWord word_spid:67):1: osh printf doesn't support floating point
osh_.py22 printf floating point (not required, but they all implement it)

stdout:
stderr: 
  [%f]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support floating point
  [%.2f]\n
      ^
(source.ArgvWord word_spid:13):1: osh printf doesn't support floating point
  [%8.2f]\n
       ^
(source.ArgvWord word_spid:26):1: osh printf doesn't support floating point
  [%-8.2f]\n
        ^
(source.ArgvWord word_spid:40):1: osh printf doesn't support floating point
  [%-f]\n
     ^
(source.ArgvWord word_spid:55):1: osh printf doesn't support floating point
  [%-f]\n
     ^
(source.ArgvWord word_spid:67):1: osh printf doesn't support floating point
osh_.cc22 printf floating point (not required, but they all implement it)

stdout:
stderr: 
  [%f]\n
    ^
TODO:1: osh printf doesn't support floating point
  [%.2f]\n
      ^
TODO:1: osh printf doesn't support floating point
  [%8.2f]\n
       ^
TODO:1: osh printf doesn't support floating point
  [%-8.2f]\n
        ^
TODO:1: osh printf doesn't support floating point
  [%-f]\n
     ^
TODO:1: osh printf doesn't support floating point
  [%-f]\n
     ^
TODO:1: osh printf doesn't support floating point
osh23 printf floating point with - and 0

stdout:
---
stderr:
  [%8.4f]\n
       ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support floating point
  [%08.4f]\n
        ^
(source.ArgvWord word_spid:16):1: osh printf doesn't support floating point
  [%8.04f]\n
       ^
(source.ArgvWord word_spid:31):1: Expected a printf format character
  [%08.04f]\n
        ^
(source.ArgvWord word_spid:48):1: Expected a printf format character
  [%-8.4f]\n
        ^
(source.ArgvWord word_spid:67):1: osh printf doesn't support floating point
  [%-08.4f]\n
         ^
(source.ArgvWord word_spid:82):1: osh printf doesn't support floating point
  [%-8.04f]\n
        ^
(source.ArgvWord word_spid:98):1: Expected a printf format character
  [%-08.04f]\n
         ^
(source.ArgvWord word_spid:113):1: Expected a printf format character
osh_.py23 printf floating point with - and 0

stdout:
---
stderr:
  [%8.4f]\n
       ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support floating point
  [%08.4f]\n
        ^
(source.ArgvWord word_spid:16):1: osh printf doesn't support floating point
  [%8.04f]\n
       ^
(source.ArgvWord word_spid:31):1: Expected a printf format character
  [%08.04f]\n
        ^
(source.ArgvWord word_spid:48):1: Expected a printf format character
  [%-8.4f]\n
        ^
(source.ArgvWord word_spid:67):1: osh printf doesn't support floating point
  [%-08.4f]\n
         ^
(source.ArgvWord word_spid:82):1: osh printf doesn't support floating point
  [%-8.04f]\n
        ^
(source.ArgvWord word_spid:98):1: Expected a printf format character
  [%-08.04f]\n
         ^
(source.ArgvWord word_spid:113):1: Expected a printf format character
osh_.cc23 printf floating point with - and 0

stdout:
---
stderr:
  [%8.4f]\n
       ^
TODO:1: osh printf doesn't support floating point
  [%08.4f]\n
        ^
TODO:1: osh printf doesn't support floating point
  [%8.04f]\n
       ^
TODO:1: Expected a printf format character
  [%08.04f]\n
        ^
TODO:1: Expected a printf format character
  [%-8.4f]\n
        ^
TODO:1: osh printf doesn't support floating point
  [%-08.4f]\n
         ^
TODO:1: osh printf doesn't support floating point
  [%-8.04f]\n
        ^
TODO:1: Expected a printf format character
  [%-08.04f]\n
         ^
TODO:1: Expected a printf format character
osh24 printf eE fF gG

stdout:
stderr: 
  [%e]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support floating point
  [%E]\n
    ^
(source.ArgvWord word_spid:13):1: osh printf doesn't support floating point
  [%f]\n
    ^
(source.ArgvWord word_spid:24):1: osh printf doesn't support floating point
  [%g]\n
    ^
(source.ArgvWord word_spid:35):1: osh printf doesn't support floating point
  [%G]\n
    ^
(source.ArgvWord word_spid:46):1: osh printf doesn't support floating point
osh_.py24 printf eE fF gG

stdout:
stderr: 
  [%e]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support floating point
  [%E]\n
    ^
(source.ArgvWord word_spid:13):1: osh printf doesn't support floating point
  [%f]\n
    ^
(source.ArgvWord word_spid:24):1: osh printf doesn't support floating point
  [%g]\n
    ^
(source.ArgvWord word_spid:35):1: osh printf doesn't support floating point
  [%G]\n
    ^
(source.ArgvWord word_spid:46):1: osh printf doesn't support floating point
osh_.cc24 printf eE fF gG

stdout:
stderr: 
  [%e]\n
    ^
TODO:1: osh printf doesn't support floating point
  [%E]\n
    ^
TODO:1: osh printf doesn't support floating point
  [%f]\n
    ^
TODO:1: osh printf doesn't support floating point
  [%g]\n
    ^
TODO:1: osh printf doesn't support floating point
  [%G]\n
    ^
TODO:1: osh printf doesn't support floating point
osh_.py25 printf backslash escapes

[osh_.py stdout] Expected "['a\\tb']\n['\\xe2\\x98\\xa0']\n['$e']\n['\\x1f7']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "$(printf 'a\tb')"
  ^~~~~~~
[ stdin ]:1: 'argv.py' not found
  argv.py "$(printf '\xE2\x98\xA0')"
  ^~~~~~~
[ stdin ]:2: 'argv.py' not found
  argv.py "$(printf '\044e')"
  ^~~~~~~
[ stdin ]:3: 'argv.py' not found
  argv.py "$(printf '\0377')"  # out of range
  ^~~~~~~
[ stdin ]:4: 'argv.py' not found
osh_.cc25 printf backslash escapes

[osh_.cc stdout] Expected "['a\\tb']\n['\\xe2\\x98\\xa0']\n['$e']\n['\\x1f7']\n", got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.py26 printf octal backslash escapes

[osh_.py stdout] Expected "['\\x1f7']\n['\\xff']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "$(printf '\0377')"
  ^~~~~~~
[ stdin ]:1: 'argv.py' not found
  argv.py "$(printf '\377')"
  ^~~~~~~
[ stdin ]:2: 'argv.py' not found
osh_.cc26 printf octal backslash escapes

[osh_.cc stdout] Expected "['\\x1f7']\n['\\xff']\n", got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.py27 printf unicode backslash escapes

[osh_.py stdout] Expected "['\\xe2\\x98\\xa0']\n['\\xd9\\x9f']\n", got ''
[osh_.py status] Expected 0, got 127

stdout:
stderr: 
  argv.py "$(printf '\u2620')"
  ^~~~~~~
[ stdin ]:1: 'argv.py' not found
  argv.py "$(printf '\U0000065f')"
  ^~~~~~~
[ stdin ]:2: 'argv.py' not found
osh_.cc27 printf unicode backslash escapes

[osh_.cc stdout] Expected "['\\xe2\\x98\\xa0']\n['\\xd9\\x9f']\n", got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh32 printf %c -- doesn't respect UTF-8! Bad.

stdout:
[μμ]
0
stderr:
  %c
   ^
(source.ArgvWord word_spid:24):1: osh printf doesn't support single characters (bytes)
osh_.py32 printf %c -- doesn't respect UTF-8! Bad.

[osh_.py stdout] Expected '[\xce\xbc\xce\xbc]\n0\n', got '[\xce\xbc\xce\xbc]\n'
[osh_.py status] Expected 0, got 127

stdout:
[μμ]
stderr:
  printf '%c' "$twomu" | wc --bytes
                         ^~
[ stdin ]:3: 'wc' not found
  %c
   ^
(source.ArgvWord word_spid:24):1: osh printf doesn't support single characters (bytes)
osh_.cc32 printf %c -- doesn't respect UTF-8! Bad.

[osh_.cc stdout] Expected '[\xce\xbc\xce\xbc]\n0\n', got '[\xce\xbc\xce\xbc]\n'
[osh_.cc status] Expected 0, got -6

stdout:
[μμ]
stderr:
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh33 printf invalid format

stdout:
status=2
status=2
stderr:
  %z
   ^
(source.ArgvWord word_spid:2):1: Invalid printf format character
  %-z
    ^
(source.ArgvWord word_spid:17):1: Invalid printf format character
osh_.py33 printf invalid format

stdout:
status=2
status=2
stderr:
  %z
   ^
(source.ArgvWord word_spid:2):1: Invalid printf format character
  %-z
    ^
(source.ArgvWord word_spid:17):1: Invalid printf format character
osh_.cc33 printf invalid format

stdout:
status=2
status=2
stderr:
  %z
   ^
TODO:1: Invalid printf format character
  %-z
    ^
TODO:1: Invalid printf format character
osh36 printf + and space flags

stdout:
stderr: 
  [%+d]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support the '+' flag
  [%+d]\n
    ^
(source.ArgvWord word_spid:13):1: osh printf doesn't support the '+' flag
  [% d]\n
    ^
(source.ArgvWord word_spid:24):1: osh printf doesn't support the ' ' flag
  [% d]\n
    ^
(source.ArgvWord word_spid:35):1: osh printf doesn't support the ' ' flag
osh_.py36 printf + and space flags

stdout:
stderr: 
  [%+d]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support the '+' flag
  [%+d]\n
    ^
(source.ArgvWord word_spid:13):1: osh printf doesn't support the '+' flag
  [% d]\n
    ^
(source.ArgvWord word_spid:24):1: osh printf doesn't support the ' ' flag
  [% d]\n
    ^
(source.ArgvWord word_spid:35):1: osh printf doesn't support the ' ' flag
osh_.cc36 printf + and space flags

stdout:
stderr: 
  [%+d]\n
    ^
TODO:1: osh printf doesn't support the '+' flag
  [%+d]\n
    ^
TODO:1: osh printf doesn't support the '+' flag
  [% d]\n
    ^
TODO:1: osh printf doesn't support the ' ' flag
  [% d]\n
    ^
TODO:1: osh printf doesn't support the ' ' flag
osh37 printf # flag

stdout:
---
stderr:
  [%#o][%#o]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support the '#' flag
  [%#x][%#x]\n
    ^
(source.ArgvWord word_spid:15):1: osh printf doesn't support the '#' flag
  [%#X][%#X]\n
    ^
(source.ArgvWord word_spid:28):1: osh printf doesn't support the '#' flag
  [%.0f][%#.0f]\n
      ^
(source.ArgvWord word_spid:45):1: osh printf doesn't support floating point
  [%g][%#g]\n
    ^
(source.ArgvWord word_spid:60):1: osh printf doesn't support floating point
osh_.py37 printf # flag

stdout:
---
stderr:
  [%#o][%#o]\n
    ^
(source.ArgvWord word_spid:2):1: osh printf doesn't support the '#' flag
  [%#x][%#x]\n
    ^
(source.ArgvWord word_spid:15):1: osh printf doesn't support the '#' flag
  [%#X][%#X]\n
    ^
(source.ArgvWord word_spid:28):1: osh printf doesn't support the '#' flag
  [%.0f][%#.0f]\n
      ^
(source.ArgvWord word_spid:45):1: osh printf doesn't support floating point
  [%g][%#g]\n
    ^
(source.ArgvWord word_spid:60):1: osh printf doesn't support floating point
osh_.cc37 printf # flag

stdout:
---
stderr:
  [%#o][%#o]\n
    ^
TODO:1: osh printf doesn't support the '#' flag
  [%#x][%#x]\n
    ^
TODO:1: osh printf doesn't support the '#' flag
  [%#X][%#X]\n
    ^
TODO:1: osh printf doesn't support the '#' flag
  [%.0f][%#.0f]\n
      ^
TODO:1: osh printf doesn't support floating point
  [%g][%#g]\n
    ^
TODO:1: osh printf doesn't support floating point
osh38 Runtime error for invalid integer

stdout:
status=1
status=1
stderr:
  printf '%d\n' $x
                ^~
[ stdin ]:2: printf expected an integer, got '3abc'
  printf '%d\n' xyz
                ^~~
[ stdin ]:4: printf expected an integer, got 'xyz'
osh_.py38 Runtime error for invalid integer

stdout:
status=1
status=1
stderr:
  printf '%d\n' $x
                ^~
[ stdin ]:2: printf expected an integer, got '3abc'
  printf '%d\n' xyz
                ^~~
[ stdin ]:4: printf expected an integer, got 'xyz'
osh_.cc38 Runtime error for invalid integer

stdout:
status=1
status=1
stderr:
  printf '%d\n' $x
                ^~
[ stdin ]:2: printf expected an integer, got '3abc'
  printf '%d\n' xyz
                ^~~
[ stdin ]:4: printf expected an integer, got 'xyz'
osh_.cc39 %(strftime format)T

[osh_.cc stdout] Expected '2019-05-16\n2019-05-15\nstatus=0\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:115: int posix::putenv(Str *, Str *): Assertion `0' failed.
osh_.cc40 %(strftime format)T doesn't respect TZ if not exported

[osh_.cc stdout] Expected 'not equal\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.cc41 %(strftime format)T TZ in environ but not in shell's memory

[osh_.cc stdout] Expected 'not equal\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:106: Tuple2<int, int> posix::pipe(): Assertion `0' failed.
osh_.cc42 %10.5(strftime format)T

[osh_.cc stdout] Expected '[ 2019-]\n[ 2019-]\nstatus=0\n', got ''
[osh_.cc status] Expected 0, got -6

stdout:
stderr: 
osh_eval.dbg: cpp/posix.h:115: int posix::putenv(Str *, Str *): Assertion `0' failed.