Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit f4e4866

Browse files
committed
Remove strongcheck dependency & generated tests
1 parent 31bbcfc commit f4e4866

File tree

8 files changed

+12
-437
lines changed

8 files changed

+12
-437
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ import Text.Markdown.SlamDown.Pretty
3434
Module documentation is [published on
3535
Pursuit](http://pursuit.purescript.org/packages/purescript-markdown).
3636

37-
### Tests
38-
39-
The tests use [purescript-strongcheck](http://github.com/purescript-contrib/purescript-strongcheck) to verify that an arbitrary `SlamDown` document can be rendered as a `String` and then parsed to a `SlamDown` equal to the original.
40-
4137
## Features
4238

4339
In general, SlamDown is a subset of [CommonMark](http://spec.commonmark.org/), supporting the following features:

bower.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
"purescript-precise": "^3.0.1",
3333
"purescript-prelude": "^4.0.1",
3434
"purescript-strings": "^4.0.0",
35-
"purescript-strongcheck": "^4.1.1",
3635
"purescript-unicode": "^4.0.1",
3736
"purescript-validation": "^4.0.0"
37+
},
38+
"devDependencies": {
39+
"purescript-assert": "^4.0.0"
3840
}
3941
}

src/Text/Markdown/SlamDown/Syntax.purs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import Prelude
1212
import Data.Eq (class Eq1)
1313
import Data.List as L
1414
import Data.Ord (class Ord1)
15-
import Test.StrongCheck.Arbitrary as SCA
16-
import Test.StrongCheck.Gen as Gen
1715
import Text.Markdown.SlamDown.Syntax.Block (Block(..), CodeBlockType(..), ListType(..)) as SDB
1816
import Text.Markdown.SlamDown.Syntax.FormField (class Value, Expr(..), FormField, FormFieldP(..), TextBox(..), TimePrecision(..), getLiteral, getUnevaluated, renderValue, stringValue, transFormField, transTextBox, traverseFormField, traverseTextBox) as SDF
1917
import Text.Markdown.SlamDown.Syntax.Inline (Inline(..), LinkTarget(..)) as SDI
@@ -36,6 +34,3 @@ derive instance ord1SlamDownP ∷ Ord1 SlamDownP
3634

3735
derive newtype instance semigroupSlamDownPSemigroup (SlamDownP a)
3836
derive newtype instance monoidSlamDownPMonoid (SlamDownP a)
39-
40-
instance arbitrarySlamDownP ∷ (SCA.Arbitrary a, Eq a) SCA.Arbitrary (SlamDownP a) where
41-
arbitrary = SlamDown <<< L.fromFoldable <$> Gen.arrayOf SCA.arbitrary

src/Text/Markdown/SlamDown/Syntax/Block.purs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import Prelude
99
import Data.Eq (class Eq1)
1010
import Data.List as L
1111
import Data.Ord (class Ord1)
12-
import Test.StrongCheck.Arbitrary as SCA
13-
import Test.StrongCheck.Gen as Gen
1412
import Text.Markdown.SlamDown.Syntax.Inline (Inline)
1513

1614
data Block a
@@ -38,22 +36,6 @@ derive instance eq1Block ∷ Eq1 Block
3836
derive instance ordBlockOrd a Ord (Block a)
3937
derive instance ord1BlockOrd1 Block
4038

41-
-- | Nota bene: this does not generate any recursive structure
42-
instance arbitraryBlock ∷ (SCA.Arbitrary a, Eq a) SCA.Arbitrary (Block a) where
43-
arbitrary = do
44-
k ← Gen.chooseInt 0 6
45-
case k of
46-
0Paragraph <$> listOf SCA.arbitrary
47-
1Header <$> SCA.arbitrary <*> listOf SCA.arbitrary
48-
2 → pure $ Blockquote L.Nil
49-
3Lst <$> SCA.arbitrary <*> listOf (pure L.Nil)
50-
4CodeBlock <$> SCA.arbitrary <*> listOf SCA.arbitrary
51-
5LinkReference <$> SCA.arbitrary <*> SCA.arbitrary
52-
_ → pure Rule
53-
54-
listOf f a. (Monad f) Gen.GenT f a Gen.GenT f (L.List a)
55-
listOf = map L.fromFoldable <<< Gen.arrayOf
56-
5739
data ListType
5840
= Bullet String
5941
| Ordered String
@@ -65,11 +47,6 @@ instance showListType ∷ Show ListType where
6547
derive instance eqListTypeEq ListType
6648
derive instance ordListTypeOrd ListType
6749

68-
instance arbitraryListTypeSCA.Arbitrary ListType where
69-
arbitrary = do
70-
b ← SCA.arbitrary
71-
if b then Bullet <$> SCA.arbitrary else Ordered <$> SCA.arbitrary
72-
7350
data CodeBlockType
7451
= Indented
7552
| Fenced Boolean String
@@ -80,8 +57,3 @@ instance showCodeBlockType ∷ Show CodeBlockType where
8057

8158
derive instance eqCodeBlockTypeEq CodeBlockType
8259
derive instance ordCodeBlockTypeOrd CodeBlockType
83-
84-
instance arbitraryCodeBlockTypeSCA.Arbitrary CodeBlockType where
85-
arbitrary = do
86-
b ← SCA.arbitrary
87-
if b then pure Indented else Fenced <$> SCA.arbitrary <*> SCA.arbitrary

src/Text/Markdown/SlamDown/Syntax/FormField.purs

Lines changed: 0 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Text.Markdown.SlamDown.Syntax.FormField
1414

1515
import Prelude
1616

17-
import Data.Array as A
1817
import Data.Eq (class Eq1, eq1)
1918
import Data.Functor.Compose (Compose(..))
2019
import Data.Identity (Identity(..))
@@ -23,10 +22,6 @@ import Data.Maybe as M
2322
import Data.Newtype (unwrap)
2423
import Data.Ord (class Ord1, compare1)
2524
import Data.Traversable as TR
26-
import Data.Tuple (uncurry)
27-
import Partial.Unsafe (unsafePartial)
28-
import Test.StrongCheck.Arbitrary as SCA
29-
import Test.StrongCheck.Gen as Gen
3025
import Text.Markdown.SlamDown.Syntax.TextBox (TextBox(..), TimePrecision(..), transTextBox, traverseTextBox) as TB
3126
import Text.Markdown.SlamDown.Syntax.Value (class Value, renderValue, stringValue) as Value
3227

@@ -123,15 +118,6 @@ instance functorArbIdentity ∷ Functor ArbIdentity where
123118
map f (ArbIdentity x) =
124119
ArbIdentity $ f x
125120

126-
instance arbitraryArbIdentity ∷ (SCA.Arbitrary a) SCA.Arbitrary (ArbIdentity a) where
127-
arbitrary =
128-
ArbIdentity <$>
129-
SCA.arbitrary
130-
131-
instance coarbitraryArbIdentity ∷ (SCA.Coarbitrary a) SCA.Coarbitrary (ArbIdentity a) where
132-
coarbitrary (ArbIdentity x) =
133-
SCA.coarbitrary x
134-
135121
newtype ArbCompose f g a = ArbCompose (f (g a))
136122

137123
getArbCompose
@@ -146,141 +132,6 @@ instance functorArbCompose ∷ (Functor f, Functor g) ⇒ Functor (ArbCompose f
146132
ArbCompose $
147133
map (map f) x
148134

149-
instance arbitraryArbCompose ∷ (SCA.Arbitrary (f (g a))) SCA.Arbitrary (ArbCompose f g a) where
150-
arbitrary =
151-
ArbCompose <$>
152-
SCA.arbitrary
153-
154-
instance coarbitraryArbCompose ∷ (SCA.Coarbitrary (f (g a))) SCA.Coarbitrary (ArbCompose f g a) where
155-
coarbitrary (ArbCompose t) =
156-
SCA.coarbitrary t
157-
158-
unsafeElements a. L.List a Gen.Gen a
159-
unsafeElements =
160-
Gen.elements
161-
<$> (unsafePartial M.fromJust <<< L.head)
162-
<*> identity
163-
164-
instance arbitraryFormField ∷ (SCA.Arbitrary a, Eq a) SCA.Arbitrary (FormFieldP Expr a) where
165-
arbitrary = do
166-
k ← Gen.chooseInt 0 3
167-
case k of
168-
0TextBox <<< TB.transTextBox getArbCompose <$> SCA.arbitrary
169-
1do
170-
xse ← genExpr $ distinctListOf1 SCA.arbitrary
171-
case xse of
172-
Literal xs → do
173-
x ← Literal <$> unsafeElements xs
174-
pure $ RadioButtons x xse
175-
Unevaluated e → do
176-
x ← Unevaluated <$> genUnevaluated
177-
pure $ RadioButtons x xse
178-
2do
179-
xse ← genExpr $ distinctListOf1 SCA.arbitrary
180-
case xse of
181-
Literal xs → do
182-
ys ← Literal <$> distinctListOf (unsafeElements xs)
183-
pure $ CheckBoxes ys xse
184-
Unevaluated e → do
185-
yse ← Unevaluated <$> genUnevaluated
186-
pure $ CheckBoxes yse xse
187-
_ → do
188-
xse ← genExpr $ distinctListOf1 SCA.arbitrary
189-
case xse of
190-
Literal xs → do
191-
mx ← genMaybe $ Literal <$> unsafeElements xs
192-
pure $ DropDown mx xse
193-
Unevaluated e → do
194-
mx ← genMaybe $ Unevaluated <$> genUnevaluated
195-
pure $ DropDown mx xse
196-
197-
instance arbitraryFormFieldIdentity ∷ (SCA.Arbitrary a, Eq a) SCA.Arbitrary (FormFieldP Identity a) where
198-
arbitrary = do
199-
k ← Gen.chooseInt 0 3
200-
case k of
201-
0TextBox <<< TB.transTextBox (\(ArbCompose x) → Compose $ map getArbIdentity x) <$> SCA.arbitrary
202-
1do
203-
xs ← distinctListOf1 $ getArbIdentity <$> SCA.arbitrary
204-
x ← unsafeElements xs
205-
pure $ RadioButtons x $ TR.sequence xs
206-
2do
207-
xs ← map TR.sequence <<< distinctListOf1 $ getArbIdentity <$> SCA.arbitrary
208-
ys ← TR.traverse (distinctListOf <<< unsafeElements) xs
209-
pure $ CheckBoxes ys xs
210-
_ → do
211-
xs ← distinctListOf1 $ getArbIdentity <$> SCA.arbitrary
212-
mx ← genMaybe $ unsafeElements xs
213-
pure $ DropDown mx $ TR.sequence xs
214-
215-
216-
genMaybe
217-
a
218-
. Gen.Gen a
219-
Gen.Gen (M.Maybe a)
220-
genMaybe gen = do
221-
b ← SCA.arbitrary
222-
if b then M.Just <$> gen else pure M.Nothing
223-
224-
instance coarbitraryFormFieldIdentity ∷ (SCA.Coarbitrary a) SCA.Coarbitrary (FormFieldP Identity a) where
225-
coarbitrary field =
226-
case field of
227-
TextBox tb → SCA.coarbitrary $ TB.transTextBox (unwrap >>> map (unwrap >>> ArbIdentity) >>> ArbCompose) tb
228-
RadioButtons x xs → \gen → do
229-
_← SCA.coarbitrary (ArbIdentity $ unwrap x) gen
230-
SCA.coarbitrary (ArbIdentity $ unwrap xs) gen
231-
CheckBoxes sel xs → \gen → do
232-
_← SCA.coarbitrary (ArbIdentity $ unwrap sel) gen
233-
SCA.coarbitrary (ArbIdentity $ unwrap xs) gen
234-
DropDown mx xs → \gen → do
235-
_← SCA.coarbitrary (ArbIdentity <<< unwrap <$> mx) gen
236-
SCA.coarbitrary (ArbIdentity $ unwrap xs) gen
237-
238-
listOf1
239-
f a
240-
. Monad f
241-
Gen.GenT f a
242-
Gen.GenT f (L.List a)
243-
listOf1 =
244-
map (L.fromFoldable <<< uncurry A.cons)
245-
<<< Gen.arrayOf1
246-
247-
listOf
248-
f a
249-
. (Monad f)
250-
Gen.GenT f a
251-
Gen.GenT f (L.List a)
252-
listOf =
253-
map L.fromFoldable
254-
<<< Gen.arrayOf
255-
256-
listOfLength
257-
f a
258-
. (Monad f)
259-
Int
260-
Gen.GenT f a
261-
Gen.GenT f (L.List a)
262-
listOfLength i =
263-
map L.fromFoldable
264-
<<< Gen.vectorOf i
265-
266-
distinctListOf1
267-
f a
268-
. Monad f
269-
Eq a
270-
Gen.GenT f a
271-
Gen.GenT f (L.List a)
272-
distinctListOf1 =
273-
map (map L.nub) listOf1
274-
275-
distinctListOf
276-
f a
277-
. Monad f
278-
Eq a
279-
Gen.GenT f a
280-
Gen.GenT f (L.List a)
281-
distinctListOf =
282-
map (map L.nub) listOf
283-
284135
data Expr a
285136
= Literal a
286137
| Unevaluated String
@@ -310,16 +161,3 @@ derive instance eq1 ∷ Eq1 Expr
310161

311162
derive instance ord1ExprOrd1 Expr
312163
derive instance ordExprOrd a Ord (Expr a)
313-
314-
genExpr a. Gen.Gen a Gen.Gen (Expr a)
315-
genExpr g = do
316-
b ← SCA.arbitrary
317-
if b then Literal <$> g else Unevaluated <$> genUnevaluated
318-
319-
genUnevaluated Gen.Gen String
320-
genUnevaluated = do
321-
x ← SCA.arbitrary
322-
pure $ " " <> x <> " "
323-
324-
instance arbitraryExpr ∷ (SCA.Arbitrary a) SCA.Arbitrary (Expr a) where
325-
arbitrary = genExpr SCA.arbitrary

src/Text/Markdown/SlamDown/Syntax/Inline.purs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import Data.Eq (class Eq1)
99
import Data.List as L
1010
import Data.Maybe as M
1111
import Data.Ord (class Ord1)
12-
import Test.StrongCheck.Arbitrary as SCA
13-
import Test.StrongCheck.Gen as Gen
1412
import Text.Markdown.SlamDown.Syntax.FormField (FormField)
1513

1614
data Inline a
@@ -46,23 +44,6 @@ derive instance eq1Inline ∷ Eq1 Inline
4644
derive instance ordInlineOrd a Ord (Inline a)
4745
derive instance ord1InlineOrd1 Inline
4846

49-
-- | Nota bene: this does not generate any recursive structure
50-
instance arbitraryInline ∷ (SCA.Arbitrary a, Eq a) SCA.Arbitrary (Inline a) where
51-
arbitrary = do
52-
k ← Gen.chooseInt 0 10
53-
case k of
54-
0Str <$> SCA.arbitrary
55-
1Entity <$> SCA.arbitrary
56-
2 → pure Space
57-
3 → pure SoftBreak
58-
4 → pure LineBreak
59-
5Code <$> SCA.arbitrary <*> SCA.arbitrary
60-
6FormField <$> SCA.arbitrary <*> SCA.arbitrary <*> SCA.arbitrary
61-
7 → pure (Emph L.Nil)
62-
8 → pure (Strong L.Nil)
63-
9Link L.Nil <$> SCA.arbitrary
64-
_ → Image L.Nil <$> SCA.arbitrary
65-
6647
data LinkTarget
6748
= InlineLink String
6849
| ReferenceLink (M.Maybe String)
@@ -73,8 +54,3 @@ derive instance ordLinkTarget ∷ Ord LinkTarget
7354
instance showLinkTargetShow LinkTarget where
7455
show (InlineLink uri) = "(InlineLink " <> show uri <> ")"
7556
show (ReferenceLink tgt) = "(ReferenceLink " <> show tgt <> ")"
76-
77-
instance arbitraryLinkTargetSCA.Arbitrary LinkTarget where
78-
arbitrary = do
79-
b ← SCA.arbitrary
80-
if b then InlineLink <$> SCA.arbitrary else ReferenceLink <$> SCA.arbitrary

src/Text/Markdown/SlamDown/Syntax/TextBox.purs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import Data.Identity (Identity(..))
1414
import Data.Newtype (unwrap)
1515
import Data.Ord (class Ord1)
1616

17-
import Test.StrongCheck.Arbitrary as SCA
18-
import Test.StrongCheck.Data.ArbDateTime as ADT
19-
import Test.StrongCheck.Gen as Gen
20-
2117
data TimePrecision
2218
= Minutes
2319
| Seconds
@@ -29,16 +25,6 @@ instance showTimePrecision ∷ Show TimePrecision where
2925
show Minutes = "Minutes"
3026
show Seconds = "Seconds"
3127

32-
instance arbitraryTimePrecisionSCA.Arbitrary TimePrecision where
33-
arbitrary =
34-
Gen.chooseInt 0 1 <#> case _ of
35-
0Minutes
36-
_ → Seconds
37-
38-
instance coarbitraryTimePrecisionSCA.Coarbitrary TimePrecision where
39-
coarbitrary Minutes = SCA.coarbitrary 1
40-
coarbitrary Seconds = SCA.coarbitrary 2
41-
4228
data TextBox f
4329
= PlainText (f String)
4430
| Numeric (f HN.HugeNum)
@@ -73,29 +59,5 @@ instance showTextBox ∷ (Show (f String), Show (f HN.HugeNum), Show (f DT.Time)
7359
derive instance eqTextBoxEq1 f Eq (TextBox f)
7460
derive instance ordTextBoxOrd1 f Ord (TextBox f)
7561

76-
instance arbitraryTextBox ∷ (Functor f, SCA.Arbitrary (f String), SCA.Arbitrary (f Number), SCA.Arbitrary (f ADT.ArbTime), SCA.Arbitrary (f ADT.ArbDate), SCA.Arbitrary (f ADT.ArbDateTime)) SCA.Arbitrary (TextBox f) where
77-
arbitrary = do
78-
i ← Gen.chooseInt 0 5
79-
case i of
80-
0PlainText <$> SCA.arbitrary
81-
1Numeric <<< map HN.fromNumber <$> SCA.arbitrary
82-
2Date <<< map ADT.runArbDate <$> SCA.arbitrary
83-
3Time <$> SCA.arbitrary <*> (map (eraseMillis <<< ADT.runArbTime) <$> SCA.arbitrary)
84-
4DateTime <$> SCA.arbitrary <*> (map (DT.modifyTime eraseMillis <<< ADT.runArbDateTime) <$> SCA.arbitrary)
85-
_ → PlainText <$> SCA.arbitrary
86-
87-
instance coarbitraryTextBox ∷ (Functor f, SCA.Coarbitrary (f String), SCA.Coarbitrary (f Number), SCA.Coarbitrary (f ADT.ArbDate), SCA.Coarbitrary (f ADT.ArbTime), SCA.Coarbitrary (f ADT.ArbDateTime)) SCA.Coarbitrary (TextBox f) where
88-
coarbitrary =
89-
case _ of
90-
PlainText d -> SCA.coarbitrary d
91-
Numeric d -> SCA.coarbitrary $ HN.toNumber <$> d
92-
Date d -> SCA.coarbitrary (ADT.ArbDate <$> d)
93-
Time prec d -> do
94-
_ ← SCA.coarbitrary prec
95-
SCA.coarbitrary (ADT.ArbTime <$> d)
96-
DateTime prec d -> do
97-
_ ← SCA.coarbitrary prec
98-
SCA.coarbitrary (ADT.ArbDateTime <$> d)
99-
10062
eraseMillis DT.Time DT.Time
10163
eraseMillis (DT.Time h m s _) = DT.Time h m s bottom

0 commit comments

Comments
 (0)