Skip to content

Commit cc4e892

Browse files
committed
Add unit tests.
1 parent f8470e5 commit cc4e892

File tree

4 files changed

+411
-25
lines changed

4 files changed

+411
-25
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"purescript-strings": "^0.7.0"
2525
},
2626
"devDependencies": {
27-
"purescript-assert": "~0.1.0",
28-
"purescript-console": "~0.1.0"
27+
"purescript-console": "~0.1.0",
28+
"purescript-super-spec": "~0.7.3"
2929
}
3030
}

src/Data/Char/Unicode.purs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Data.Maybe
2020
-- OtherLetter :: GeneralCategory
2121
-- ```
2222
--
23-
-- 'Eq' instance:
23+
-- `Eq` instance:
2424
--
2525
-- ```
2626
-- >>> UppercaseLetter == UppercaseLetter
@@ -29,28 +29,28 @@ import Data.Maybe
2929
-- False
3030
-- ```
3131
--
32-
-- 'Ord' instance:
32+
-- `Ord` instance:
3333
--
3434
-- ```
3535
-- >>> NonSpacingMark <= MathSymbol
3636
-- True
3737
-- ```
3838
--
39-
-- 'Enum' instance:
39+
-- `Enum` instance (TODO: this is not implemented yet):
4040
--
4141
-- ```
4242
-- >>> enumFromTo ModifierLetter SpacingCombiningMark
4343
-- [ModifierLetter,OtherLetter,NonSpacingMark,SpacingCombiningMark]
4444
-- ```
4545
--
46-
-- 'Show' instance:
46+
-- `Show` instance:
4747
--
4848
-- ```
4949
-- >>> show EnclosingMark
5050
-- "EnclosingMark"
5151
-- ```
5252
--
53-
-- 'Bounded' instance:
53+
-- `Bounded` instance:
5454
--
5555
-- ```
5656
-- >>> bottom :: GeneralCategory
@@ -258,30 +258,27 @@ instance boundedGeneralCategory :: Bounded GeneralCategory where
258258
bottom = UppercaseLetter
259259
top = NotAssigned
260260

261-
-- | The Unicode general category of the character. This relies on the
262-
-- 'Enum' instance of 'GeneralCategory', which must remain in the
263-
-- same order as the categories are presented in the Unicode
264-
-- standard.
261+
-- | The Unicode general category of the character.
265262
--
266263
-- #### __Examples__
267264
--
268265
-- Basic usage:
269266
--
270267
-- ```
271268
-- >>> generalCategory 'a'
272-
-- LowercaseLetter
269+
-- Just LowercaseLetter
273270
-- >>> generalCategory 'A'
274-
-- UppercaseLetter
271+
-- Just UppercaseLetter
275272
-- >>> generalCategory '0'
276-
-- DecimalNumber
273+
-- Just DecimalNumber
277274
-- >>> generalCategory '%'
278-
-- OtherPunctuation
275+
-- Just OtherPunctuation
279276
-- >>> generalCategory '♥'
280-
-- OtherSymbol
277+
-- Just OtherSymbol
281278
-- >>> generalCategory '\31'
282-
-- Control
279+
-- Just Control
283280
-- >>> generalCategory ' '
284-
-- Space
281+
-- Just Space
285282
-- ```
286283
generalCategory :: Char -> Maybe GeneralCategory
287284
generalCategory = map unicodeCatToGeneralCat <<< uGencat <<< toCharCode
@@ -368,8 +365,8 @@ isOctDigit c = let diff = (toCharCode c - toCharCode '0')
368365
-- i.e. `0..9, A..F, a..f`.
369366
isHexDigit :: Char -> Boolean
370367
isHexDigit c = isDigit c
371-
|| let diff = (toCharCode c - toCharCode 'A') in diff <= 5 && diff >= 0
372-
|| let diff = (toCharCode c - toCharCode 'a') in diff <= 5 && diff >= 0
368+
|| (let diff = (toCharCode c - toCharCode 'A') in diff <= 5 && diff >= 0)
369+
|| (let diff = (toCharCode c - toCharCode 'a') in diff <= 5 && diff >= 0)
373370

374371
-- | Selects Unicode punctuation characters, including various kinds
375372
-- of connectors, brackets and quotes.

0 commit comments

Comments
 (0)