Skip to content

Commit 35d53cd

Browse files
committed
Fix tests when run in developer mode
1 parent 3b725c1 commit 35d53cd

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/Data/Text/Internal/Encoding/Utf8.hs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ module Data.Text.Internal.Encoding.Utf8
3333
, validate4
3434
) where
3535

36-
#if defined(TEST_SUITE)
37-
# undef ASSERTS
38-
#endif
39-
40-
#if defined(ASSERTS)
41-
import Control.Exception (assert)
42-
#endif
4336
import Data.Bits ((.&.))
4437
import Data.Text.Internal.Unsafe.Char (ord)
4538
import Data.Text.Internal.Unsafe.Shift (shiftR)
@@ -62,9 +55,9 @@ between x y z = x >= y && x <= z
6255

6356
ord2 :: Char -> (Word8,Word8)
6457
ord2 c =
65-
#if defined(ASSERTS)
66-
assert (n >= 0x80 && n <= 0x07ff)
67-
#endif
58+
-- ord2 is used only in test suite to construct a deliberately invalid ByteString,
59+
-- actually violating the assertion, so it is commented out
60+
-- assert (n >= 0x80 && n <= 0x07ff)
6861
(x1,x2)
6962
where
7063
n = ord c
@@ -73,9 +66,9 @@ ord2 c =
7366

7467
ord3 :: Char -> (Word8,Word8,Word8)
7568
ord3 c =
76-
#if defined(ASSERTS)
77-
assert (n >= 0x0800 && n <= 0xffff)
78-
#endif
69+
-- ord3 is used only in test suite to construct a deliberately invalid ByteString,
70+
-- actually violating the assertion, so it is commented out
71+
-- assert (n >= 0x0800 && n <= 0xffff)
7972
(x1,x2,x3)
8073
where
8174
n = ord c
@@ -85,9 +78,9 @@ ord3 c =
8578

8679
ord4 :: Char -> (Word8,Word8,Word8,Word8)
8780
ord4 c =
88-
#if defined(ASSERTS)
89-
assert (n >= 0x10000)
90-
#endif
81+
-- ord4 is used only in test suite to construct a deliberately invalid ByteString,
82+
-- actually violating the assertion, so it is commented out
83+
-- assert (n >= 0x10000)
9184
(x1,x2,x3,x4)
9285
where
9386
n = ord c

src/Data/Text/Internal/Fusion/Common.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ compareLengthI (Stream next s0 len) n
322322
-- Note that @len@ tracks code units whereas we want to compare the length
323323
-- in code points. Specifically, a stream with hint @len@ may consist of
324324
-- anywhere from @len/2@ to @len@ code points.
325+
| n < 0 = GT
325326
| Just r <- compareSize len n' = r
326327
| otherwise = loop_cmp 0 s0
327328
where

0 commit comments

Comments
 (0)