summaryrefslogtreecommitdiff
path: root/tests/parse.scm
blob: 8a6c87b8cb11be6896ac8092a4367ba5c251d07c (plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
(import (chibi)
        (chibi test)
        (chibi parse)
        (cook  debug)
        (cook  parse-internals))

(test-group "Amount"
  (test "with unit"
        (list 'amount 10 "l") (cook->list (parse amount "10%l")))
  (test "without unit"
        (list 'amount 10 #f)  (cook->list (parse amount "10"))))

(test-group "Quantity"
  (test "integer"  10   (parse quantity "10"))
  (test "float"    10.1 (parse quantity "10.1"))
  (test "fraction" 1/10 (parse quantity "1/10")))


(test-group "Official"
  (test "testBasicDirection"
        '(recipe (metadata ()) ((step ("Add a bit of chilli "))))
        (cook->list (parse-cook "Add a bit of chilli\n")))
  (test "testComments"
        '(recipe (metadata ()) ((comment " testing comments")))
        (cook->list (parse-cook "-- testing comments\n")))
  (test "testCommentsAfterIngredients"
        '(recipe (metadata ())
                 ((step ((ingredient "thyme" (amount 2 "sprigs"))
                         " " (comment " testing comments") "and some text "))))
        (cook->list
          (parse-cook "@thyme{2%sprigs} -- testing comments\nand some text\n")))
  (test "testCommentsWithIngredients"
        '(recipe (metadata ())
                 ((comment " testing comments")
                  (step ((ingredient "thyme" (amount 2 "sprigs")) " "))))
        (cook->list
          (parse-cook "-- testing comments\n@thyme{2%sprigs}\n")))
  ;(test "testDirectionsWithDegrees"
  ;      '()
  ;      (cook->list (parse-cook "Heat oven up to 200°C\n")))
  ;(test "testDirectionsWithNumbers"
  ;      '()
  ;      (cook->list (parse-cook "Heat 5L of water\n")))
  ;(test "testDirectionWithIngredient"
  ;      '()
  ;      (cook->list (parse-cook "Add @chilli{3%items}, @ginger{10%g} and @milk{1%l}.\n")))
  ;(test "testEquipmentMultipleWords"
  ;      '()
  ;      (cook->list (parse-cook "Fry in #frying pan{}\n")))
  ;(test "testEquipmentMultipleWordsWithLeadingNumber"
  ;      '()
  ;      (cook->list (parse-cook "Fry in #7-inch nonstick frying pan{ }\n")))
  ;(test "testEquipmentMultipleWordsWithSpaces"
  ;      '()
  ;      (cook->list (parse-cook "Fry in #frying pan{ }\n")))
  ;(test "testEquipmentOneWord"
  ;      '()
  ;      (cook->list (parse-cook "Simmer in #pan for some time\n")))
  ;(test "testEquipmentQuantity"
  ;      '()
  ;      (cook->list (parse-cook "#frying pan{2}\n")))
  ;(test "testEquipmentQuantityOneWord"
  ;      '()
  ;      (cook->list (parse-cook "#frying pan{three}\n")))
  ;(test "testEquipmentQuantityMultipleWords"
  ;      '()
  ;      (cook->list (parse-cook "#frying pan{two small}\n")))
  ;(test "testFractions"
  ;      '()
  ;      (cook->list (parse-cook "@milk{1/2%cup}\n")))
  ;(test "testFractionsInDirections"
  ;      '()
  ;      (cook->list (parse-cook "knife cut about every 1/2 inches\n")))
  ;(test "testFractionsLike"
  ;      '()
  ;      (cook->list (parse-cook "@milk{01/2%cup}\n")))
  ;(test "testFractionsWithSpaces"
  ;      '()
  ;      (cook->list (parse-cook "@milk{1 / 2 %cup}\n")))
  ;(test "testIngredientMultipleWordsWithLeadingNumber"
  ;      '()
  ;      (cook->list (parse-cook "Top with @1000 island dressing{ }\n")))
  ;(test "testIngredientWithEmoji"
  ;      '()
  ;      (cook->list (parse-cook "Add some @🧂\n")))
  ;(test "testIngredientExplicitUnits"
  ;      '()
  ;      (cook->list (parse-cook "@chilli{3%items}\n")))
  ;(test "testIngredientExplicitUnitsWithSpaces"
  ;      '()
  ;      (cook->list (parse-cook "@chilli{ 3 % items }\n")))
  ;(test "testIngredientImplicitUnits"
  ;      '()
  ;      (cook->list (parse-cook "@chilli{3}\n")))
  ;(test "testIngredientNoUnits"
  ;      '()
  ;      (cook->list (parse-cook "@chilli\n")))
  ;(test "testIngredientNoUnitsNotOnlyString"
  ;      '()
  ;      (cook->list (parse-cook "@5peppers\n")))
  ;(test "testIngredientWithNumbers"
  ;      '()
  ;      (cook->list (parse-cook "@tipo 00 flour{250%g}\n")))
  ;(test "testIngredientWithoutStopper"
  ;      '()
  ;      (cook->list (parse-cook "@chilli cut into pieces\n")))
  ;(test "testMetadata"
  ;      '()
  ;      (cook->list (parse-cook ">> sourced: babooshka\n")))
  ;(test "testMetadataBreak"
  ;      '()
  ;      (cook->list (parse-cook "hello >> sourced: babooshka\n")))
  ;(test "testMetadataMultiwordKey"
  ;      '()
  ;      (cook->list (parse-cook ">> cooking time: 30 mins\n")))
  ;(test "testMetadataMultiwordKeyWithSpaces"
  ;      '()
  ;      (cook->list (parse-cook ">>cooking time    :30 mins\n")))
  ;(test "testMultiLineDirections"
  ;      '()
  ;      (cook->list (parse-cook "Add a bit of chilli\nAdd a bit of hummus\n")))
  ;(test "testMultipleLines"
  ;      '()
  ;      (cook->list (parse-cook ">> Prep Time: 15 minutes\n>> Cook Time: 30 minutes\n")))
  ;(test "testMultiWordIngredient"
  ;      '()
  ;      (cook->list (parse-cook "@hot chilli{3}\n")))
  ;(test "testMultiWordIngredientNoAmount"
  ;      '()
  ;      (cook->list (parse-cook "@hot chilli{}\n")))
  ;(test "testMutipleIngredientsWithoutStopper"
  ;      '()
  ;      (cook->list (parse-cook "@chilli cut into pieces and @garlic\n")))
  ;(test "testQuantityAsText"
  ;      '()
  ;      (cook->list (parse-cook "@thyme{few%sprigs}\n")))
  ;(test "testQuantityDigitalString"
  ;      '()
  ;      (cook->list (parse-cook "@water{7 k }\n")))
  ;(test "testServings"
  ;      '()
  ;      (cook->list (parse-cook ">> servings: 1|2|3\n")))
  ;(test "testSlashInText"
  ;      '()
  ;      (cook->list (parse-cook "Preheat the oven to 200℃/Fan 180°C.\n")))
  ;(test "testTimerDecimal"
  ;      '()
  ;      (cook->list (parse-cook "Fry for ~{1.5%minutes}\n")))
  ;(test "testTimerFractional"
  ;      '()
  ;      (cook->list (parse-cook "Fry for ~{1/2%hour}\n")))
  ;(test "testTimerInteger"
  ;      '()
  ;      (cook->list (parse-cook "Fry for ~{10%minutes}\n")))
  ;(test "testTimerWithName"
  ;      '()
  ;      (cook->list (parse-cook "Fry for ~potato{42%minutes}\n")))
  ;(test "testSingleWordTimer"
  ;      '()
  ;      (cook->list (parse-cook "Let it ~rest after plating\n")))
  ;(test "testSingleWordTimerWithPunctuation"
  ;      '()
  ;      (cook->list (parse-cook "Let it ~rest, then serve\n")))
  ;(test "testSingleWordTimerWithUnicodePunctuation"
  ;      '()
  ;      (cook->list (parse-cook "Let it ~rest⸫ then serve\n")))
  ;(test "testTimerWithUnicodeWhitespace"
  ;      '()
  ;      (cook->list (parse-cook "Let it ~rest then serve\n")))
  ;(test "testInvalidMultiWordTimer"
  ;      '()
  ;      (cook->list (parse-cook "It is ~ {5}\n")))
  ;(test "testInvalidSingleWordTimer"
  ;      '()
  ;      (cook->list (parse-cook "It is ~ 5\n")))
  ;(test "testSingleWordIngredientWithPunctuation"
  ;      '()
  ;      (cook->list (parse-cook "Add some @chilli, then serve\n")))
  ;(test "testSingleWordIngredientWithUnicodePunctuation"
  ;      '()
  ;      (cook->list (parse-cook "Add @chilli⸫ then bake\n")))
  ;(test "testIngredientWithUnicodeWhitespace"
  ;      '()
  ;      (cook->list (parse-cook "Add @chilli then bake\n")))
  ;(test "testInvalidMultiWordIngredient"
  ;      '()
  ;      (cook->list (parse-cook "Message @ example{}\n")))
  ;(test "testInvalidSingleWordIngredient"
  ;      '()
  ;      (cook->list (parse-cook "Message me @ example\n")))
  ;(test "testSingleWordCookwareWithPunctuation"
  ;      '()
  ;      (cook->list (parse-cook "Place in #pot, then boil\n")))
  ;(test "testSingleWordCookwareWithUnicodePunctuation"
  ;      '()
  ;      (cook->list (parse-cook "Place in #pot⸫ then boil\n")))
  ;(test "testCookwareWithUnicodeWhitespace"
  ;      '()
  ;      (cook->list (parse-cook "Add to #pot then boil\n")))
  ;(test "testInvalidMultiWordCookware"
  ;      '(recipe (metadata ()) ((step ("Recipe # 10{}"))))
  ;      (cook->list (parse-cook "Recipe # 10{}\n")))
  ;(test "testInvalidSingleWordCookware"
  ;      '(recipe (metadata ()) ((step ("Recipe # 5"))))
  ;      (cook->list (parse-cook "Recipe # 5\n")))
  )