diff options
author | Tony Cook <tony@develop-help.com> | 2020-11-17 14:20:41 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2020-11-24 13:35:21 +1100 |
commit | 7274dea4b81e86585fcc4c4377c1a9918de3f4af (patch) | |
tree | dc1d088126c21d5d2903dc6ebed85d1758a5422e /t/io | |
parent | 18b3ff2673bbc5f9b37c6d9b6c912f882537ddc2 (diff) | |
download | perl-7274dea4b81e86585fcc4c4377c1a9918de3f4af.tar.gz |
*ctl: test we handle the buffer as bytes
Previously this had the "unicode bug", an upgraded string would
be treated as the encoding of that string, rather than the raw
bytes.
Diffstat (limited to 't/io')
-rw-r--r-- | t/io/sem.t | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/t/io/sem.t b/t/io/sem.t index 8d2c7bbe36..ff3df5f496 100644 --- a/t/io/sem.t +++ b/t/io/sem.t @@ -76,5 +76,16 @@ else { @semvals = unpack("s!*", $semvals); is($semvals[$sem2set], $semval, "Checking value of semaphore $sem2set after fetch into originally UTF-8 buffer"); + + # second that we treat it as bytes on input + @semvals = ( 0 ) x $nsem; + $semvals[$sem2set] = $semval + 1; + $semvals = pack "s!*", @semvals; + utf8::upgrade($semvals); + # eval{} since it would crash due to the UTF-8 form being longer + ok(eval { semctl($id, "ignored", SETALL, $semvals) }, + "set all semaphores from an upgraded string"); + is(semctl($id, $sem2set, GETVAL, $ignored), $semval+1, + "test value set from UTF-8"); } |