diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2023-02-24 10:02:50 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-02-28 11:11:21 -0500 |
commit | 8b77f9bfceb456115f63349ad0ff66a5cea7ab59 (patch) | |
tree | 5fc4cb971d4ce84177d1de266f799edf4c3e49eb /testsuite/tests | |
parent | 0c200ab78c814cb5d1efaf426f0d3d91ceab9f4d (diff) | |
download | haskell-8b77f9bfceb456115f63349ad0ff66a5cea7ab59.tar.gz |
JS: fix for overlap with copyMutableByteArray# (#23033)
The code wasn't taking into account some kind of overlap.
cgrun070 has been extended to test the missing case.
Diffstat (limited to 'testsuite/tests')
4 files changed, 24 insertions, 4 deletions
diff --git a/testsuite/tests/codeGen/should_run/CopySmallArray.hs b/testsuite/tests/codeGen/should_run/CopySmallArray.hs index e3a5143ac8..26f244c490 100644 --- a/testsuite/tests/codeGen/should_run/CopySmallArray.hs +++ b/testsuite/tests/codeGen/should_run/CopySmallArray.hs @@ -76,12 +76,21 @@ test_copyMutableArray = -- Perform a copy where the source and destination part overlap. test_copyMutableArrayOverlap :: String test_copyMutableArrayOverlap = - let arr = runST $ do + let arr1 = runST $ do marr <- fromList inp -- Overlap of two elements copyMutableArray marr 5 marr 7 8 unsafeFreezeArray marr - in shows (toList arr (length inp)) "\n" + arr2 = runST $ do + marr <- fromList inp + -- Overlap of two elements + -- Offset 1 > offset 2 (cf #23033) + copyMutableArray marr 7 marr 5 8 + unsafeFreezeArray marr + in shows (toList arr1 (length inp)) + . showChar '\n' + . shows (toList arr2 (length inp)) + $ "\n" where -- This case was known to fail at some point. inp = [0,169,196,9,16,25,36,16,25,81,100,121,144,169,196] diff --git a/testsuite/tests/codeGen/should_run/CopySmallArray.stdout b/testsuite/tests/codeGen/should_run/CopySmallArray.stdout index 86ad8a276c..3308687344 100644 --- a/testsuite/tests/codeGen/should_run/CopySmallArray.stdout +++ b/testsuite/tests/codeGen/should_run/CopySmallArray.stdout @@ -3,6 +3,7 @@ [-1,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961,1024,1089,1156,1225,1296,1369,1444,1521,1600,1681,1764,1849,1936,2025,2116,2209,2304,2401,2500,2601,2704,2809,2916,3025,3136,3249,3364,3481,3600,3721,3844,3969,4096,4225,4356,4489,4624,4761,4900,5041,5184,5329,5476,5625,5776,5929,6084,6241,6400,6561,6724,6889,7056,7225,7396,7569,7744,7921,8100,8281,8464,8649,8836,9025,9216,9409,9604,9801,10000,10201,10404,10609,10816,11025,11236,11449,11664,11881,12100,12321,12544,12769,12996,13225,13456,13689,13924,14161,14400,14641,14884,15129,15376,15625,15876,16129,16384,-1] [0,169,196,9,16,25,36,25,36,16,25,81,100,121,144] +[0,169,196,9,16,16,25,81,100,121,144,169,196,169,196] [1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961,1024,1089,1156,1225,1296,1369,1444,1521,1600,1681,1764,1849,1936,2025,2116,2209,2304,2401,2500,2601,2704,2809,2916,3025,3136,3249,3364,3481,3600,3721,3844,3969,4096,4225,4356,4489,4624,4761,4900,5041,5184,5329,5476,5625,5776,5929,6084,6241,6400,6561,6724,6889,7056,7225,7396,7569,7744,7921,8100,8281,8464,8649,8836,9025,9216,9409,9604,9801,10000,10201,10404,10609,10816,11025,11236,11449,11664,11881,12100,12321,12544,12769,12996,13225,13456,13689,13924,14161,14400,14641,14884,15129,15376,15625,15876,16129,16384] diff --git a/testsuite/tests/codeGen/should_run/cgrun070.hs b/testsuite/tests/codeGen/should_run/cgrun070.hs index 6d16141202..6ada2e6083 100644 --- a/testsuite/tests/codeGen/should_run/cgrun070.hs +++ b/testsuite/tests/codeGen/should_run/cgrun070.hs @@ -74,12 +74,21 @@ test_copyMutableByteArray = -- Perform a copy where the source and destination part overlap. test_copyMutableByteArrayOverlap :: String test_copyMutableByteArrayOverlap = - let arr = runST $ do + let arr1 = runST $ do marr <- fromList inp -- Overlap of two elements copyMutableByteArray marr 5 marr 7 8 unsafeFreezeByteArray marr - in shows (toList arr (length inp)) "\n" + arr2 = runST $ do + marr <- fromList inp + -- Overlap of two elements + -- Offset 1 > offset 2 (cf #23033) + copyMutableByteArray marr 7 marr 5 8 + unsafeFreezeByteArray marr + in shows (toList arr1 (length inp)) + . showChar '\n' + . shows (toList arr2 (length inp)) + $ "\n" where -- This case was known to fail at some point. inp = [0,169,196,9,16,25,36,16,25,81,100,121,144,169,196] diff --git a/testsuite/tests/codeGen/should_run/cgrun070.stdout b/testsuite/tests/codeGen/should_run/cgrun070.stdout index 4c62f485cc..b0cbd43567 100644 --- a/testsuite/tests/codeGen/should_run/cgrun070.stdout +++ b/testsuite/tests/codeGen/should_run/cgrun070.stdout @@ -3,6 +3,7 @@ [255,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,255] [0,169,196,9,16,25,36,25,36,16,25,81,100,121,144] +[0,169,196,9,16,16,25,81,100,121,144,169,196,169,196] [255,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,255] |