summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-02-02 14:43:53 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-04 16:14:47 -0500
commit8c18feba88aaa20b75b82c3fee7e8f742299461e (patch)
tree524c9aeb94a76cbb74e74025c4de82d2184bf0e5 /testsuite/tests/codeGen
parent1cf9616a379a084daaa4d7219ebb75aa3e358e05 (diff)
downloadhaskell-8c18feba88aaa20b75b82c3fee7e8f742299461e.tar.gz
primops: Fix documentation of setByteArray#
Previously the documentation was subtly incorrect regarding the bounds of the operation. Fix this and add a test asserting that a zero-length operation is in fact a no-op.
Diffstat (limited to 'testsuite/tests/codeGen')
-rw-r--r--testsuite/tests/codeGen/should_run/setByteArray.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/testsuite/tests/codeGen/should_run/setByteArray.hs b/testsuite/tests/codeGen/should_run/setByteArray.hs
index 099376cb4b..c9a1012ccd 100644
--- a/testsuite/tests/codeGen/should_run/setByteArray.hs
+++ b/testsuite/tests/codeGen/should_run/setByteArray.hs
@@ -12,12 +12,15 @@ main :: IO ()
main = do BA ba <- IO $ \s0 ->
case newByteArray# 8# s0 of
(# !s1, !mba #) ->
- case setByteArray# mba 0# 8# 65# s1 of
+ case setByteArray# mba 0# 8# 65# s1 of -- ASCII 'A'
!s2 ->
- case setByteArray# mba 1# 6# 67# s2 of
+ case setByteArray# mba 1# 6# 67# s2 of -- ASCII 'B'
!s3 ->
- case unsafeFreezeByteArray# mba s3 of
- (# s4, ba #) -> (# s4, BA ba #)
+ -- N.B. 0-length should be a no-op
+ case setByteArray# mba 2# 0# 68# s3 of -- ASCII 'C'
+ !s4 ->
+ case unsafeFreezeByteArray# mba s4 of
+ (# s5, ba #) -> (# s5, BA ba #)
let f (I# i) = putStrLn [C# (indexCharArray# ba i)]
mapM_ f [0..7]