summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/parse.scm455
1 files changed, 286 insertions, 169 deletions
diff --git a/tests/parse.scm b/tests/parse.scm
index e004a1b..2c1573b 100644
--- a/tests/parse.scm
+++ b/tests/parse.scm
@@ -40,172 +40,289 @@
(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")))
- )
+ (test "testDirectionsWithDegrees"
+ '(recipe (metadata ())
+ ((step ("Heat oven up to 200°C"))))
+ (cook->list (parse-cook "Heat oven up to 200°C\n")))
+
+ (test "testDirectionsWithNumbers"
+ '(recipe (metadata ())
+ ((step ("Heat 5L of water"))))
+ (cook->list (parse-cook "Heat 5L of water\n")))
+
+ (test "testDirectionWithIngredient"
+ '(recipe (metadata ())
+ ((step ("Add " (ingredient "chilli" (amount 3 "items")) ", "
+ (ingredient "ginger" (amount 10 "g")) " and "
+ (ingredient "milk" (amount 1 "l")) "."))))
+ (cook->list (parse-cook "Add @chilli{3%items}, @ginger{10%g} and @milk{1%l}.\n")))
+
+ (test "testEquipmentMultipleWords"
+ '(recipe (metadata ())
+ ((step ("Fry in " (cookware "frying pan" #f)))))
+ (cook->list (parse-cook "Fry in #frying pan{}\n")))
+
+ (test "testEquipmentMultipleWordsWithLeadingNumber"
+ '(recipe (metadata ())
+ ((step ("Fry in " (cookware "7-inch nonstick frying pan" #f)))))
+ (cook->list (parse-cook "Fry in #7-inch nonstick frying pan{ }\n")))
+
+ (test "testEquipmentMultipleWordsWithSpaces"
+ '(recipe (metadata ())
+ ((step ("Fry in " (cookware "frying pan" #f)))))
+ (cook->list (parse-cook "Fry in #frying pan{ }\n")))
+
+ (test "testEquipmentOneWord"
+ '(recipe (metadata ())
+ ((step ("Simmer in " (cookware "pan" #f) " for some time"))))
+ (cook->list (parse-cook "Simmer in #pan for some time\n")))
+
+ (test "testEquipmentQuantity"
+ '(recipe (metadata ())
+ ((step ((cookware "frying pan" (amount 2 #f))))))
+ (cook->list (parse-cook "#frying pan{2}\n")))
+
+ (test "testEquipmentQuantityOneWord"
+ '(recipe (metadata ())
+ ((step ((cookware "frying pan" (amount "three" #f))))))
+ (cook->list (parse-cook "#frying pan{three}\n")))
+
+ (test "testEquipmentQuantityMultipleWords"
+ '(recipe (metadata ())
+ ((step ((cookware "frying pan" (amount "two small" #f))))))
+ (cook->list (parse-cook "#frying pan{two small}\n")))
+
+ (test "testFractions"
+ '(recipe (metadata ())
+ ((step ((ingredient "milk" (amount 1/2 "cup"))))))
+ (cook->list (parse-cook "@milk{1/2%cup}\n")))
+
+ (test "testFractionsInDirections"
+ '(recipe (metadata ())
+ ((step ("knife cut about every 1/2 inches"))))
+ (cook->list (parse-cook "knife cut about every 1/2 inches\n")))
+
+ (test "testFractionsLike"
+ '(recipe (metadata ())
+ ((step ((ingredient "milk" (amount "01/2" "cup"))))))
+ (cook->list (parse-cook "@milk{01/2%cup}\n")))
+
+ (test "testFractionsWithSpaces"
+ '(recipe (metadata ())
+ ((step ((ingredient "milk" (amount 1/2 "cup"))))))
+ (cook->list (parse-cook "@milk{1 / 2 %cup}\n")))
+
+ (test "testIngredientMultipleWordsWithLeadingNumber"
+ '(recipe (metadata ())
+ ((step ("Top with " (ingredient "1000 island dressing" #f)))))
+ (cook->list (parse-cook "Top with @1000 island dressing{ }\n")))
+
+ (test "testIngredientWithEmoji"
+ '(recipe (metadata ())
+ ((step ("Add some " (ingredient "đŸ§‚" #f)))))
+ (cook->list (parse-cook "Add some @đŸ§‚\n")))
+
+ (test "testIngredientExplicitUnits"
+ '(recipe (metadata ())
+ ((step ((ingredient "chilli" (amount 3 "items"))))))
+ (cook->list (parse-cook "@chilli{3%items}\n")))
+
+ (test "testIngredientExplicitUnitsWithSpaces"
+ '(recipe (metadata ())
+ ((step ((ingredient "chilli" (amount 3 "items"))))))
+ (cook->list (parse-cook "@chilli{ 3 % items }\n")))
+
+ (test "testIngredientImplicitUnits"
+ '(recipe (metadata ())
+ ((step ((ingredient "chilli" (amount 3 #f))))))
+ (cook->list (parse-cook "@chilli{3}\n")))
+
+ (test "testIngredientNoUnits"
+ '(recipe (metadata ())
+ ((step ((ingredient "chilli" #f)))))
+ (cook->list (parse-cook "@chilli\n")))
+
+ (test "testIngredientNoUnitsNotOnlyString"
+ '(recipe (metadata ())
+ ((step ((ingredient "5peppers" #f)))))
+ (cook->list (parse-cook "@5peppers\n")))
+
+ (test "testIngredientWithNumbers"
+ '(recipe (metadata ())
+ ((step ((ingredient "tipo 00 flour" (amount 250 "g"))))))
+ (cook->list (parse-cook "@tipo 00 flour{250%g}\n")))
+
+ (test "testIngredientWithoutStopper"
+ '(recipe (metadata ())
+ ((step ((ingredient "chilli" #f) " cut into pieces"))))
+ (cook->list (parse-cook "@chilli cut into pieces\n")))
+
+ (test "testMetadata"
+ '(recipe (metadata (("sourced" . "babooshka")))
+ ())
+ (cook->list (parse-cook ">> sourced: babooshka\n")))
+
+ (test "testMetadataBreak"
+ '(recipe (metadata ())
+ ((step ("hello >> sourced: babooshka"))))
+ (cook->list (parse-cook "hello >> sourced: babooshka\n")))
+
+ (test "testMetadataMultiwordKey"
+ '(recipe (metadata (("cooking time" . "30 mins")))
+ ())
+ (cook->list (parse-cook ">> cooking time: 30 mins\n")))
+
+ (test "testMetadataMultiwordKeyWithSpaces"
+ '(recipe (metadata (("cooking time" . "30 mins")))
+ ())
+ (cook->list (parse-cook ">>cooking time :30 mins\n")))
+
+ (test "testMultiLineDirections"
+ '(recipe (metadata ())
+ ((step ("Add a bit of chilli"))
+ (step ("Add a bit of hummus"))))
+ (cook->list (parse-cook "Add a bit of chilli\n\nAdd a bit of hummus\n")))
+
+ (test "testMultipleLines"
+ ;; TODO Fails because of the order of the hash-map
+ '(recipe (metadata (("Prep Time" . "15 minutes")
+ ("Cook Time" . "30 minutes")))
+ ())
+ (cook->list (parse-cook ">> Prep Time: 15 minutes\n>> Cook Time: 30 minutes\n")))
+
+ (test "testMultiWordIngredient"
+ '(recipe (metadata ())
+ ((step ((ingredient "hot chilli" (amount 3 #f)) ))))
+ (cook->list (parse-cook "@hot chilli{3}\n")))
+
+ (test "testMultiWordIngredientNoAmount"
+ '(recipe (metadata ())
+ ((step ((ingredient "hot chilli" #f) ))))
+ (cook->list (parse-cook "@hot chilli{}\n")))
+
+ (test "testMutipleIngredientsWithoutStopper"
+ '(recipe (metadata ())
+ ((step ((ingredient "chilli" #f) " cut into pieces and "
+ (ingredient "garlic" #f)))))
+ (cook->list (parse-cook "@chilli cut into pieces and @garlic\n")))
+
+ (test "testQuantityAsText"
+ '(recipe (metadata ())
+ ((step ((ingredient "thyme" (amount "few" "sprigs"))))))
+ (cook->list (parse-cook "@thyme{few%sprigs}\n")))
+
+ (test "testQuantityDigitalString"
+ '(recipe (metadata ())
+ ((step ((ingredient "water" (amount "7 k" #f))))))
+ (cook->list (parse-cook "@water{7 k }\n")))
+
+ (test "testServings"
+ '(recipe (metadata (("servings" . "1|2|3")))
+ ())
+ (cook->list (parse-cook ">> servings: 1|2|3\n")))
+
+ (test "testSlashInText"
+ '(recipe (metadata ())
+ ((step ("Preheat the oven to 200℃/Fan 180°C."))))
+ (cook->list (parse-cook "Preheat the oven to 200℃/Fan 180°C.\n")))
+
+ (test "testTimerDecimal"
+ '(recipe (metadata ())
+ ((step ("Fry for " (timer #f (amount 1.5 "minutes"))))))
+ (cook->list (parse-cook "Fry for ~{1.5%minutes}\n")))
+
+ (test "testTimerFractional"
+ '(recipe (metadata ())
+ ((step ("Fry for " (timer #f (amount 1/2 "hour"))))))
+ (cook->list (parse-cook "Fry for ~{1/2%hour}\n")))
+
+ (test "testTimerInteger"
+ '(recipe (metadata ())
+ ((step ("Fry for " (timer #f (amount 10 "minutes"))))))
+ (cook->list (parse-cook "Fry for ~{10%minutes}\n")))
+
+ (test "testTimerWithName"
+ '(recipe (metadata ())
+ ((step ("Fry for " (timer "potato" (amount 42 "minutes"))))))
+ (cook->list (parse-cook "Fry for ~potato{42%minutes}\n")))
+
+ (test "testSingleWordTimer"
+ '(recipe (metadata ())
+ ((step ("Let it " (timer "rest" #f) " after plating"))))
+ (cook->list (parse-cook "Let it ~rest after plating\n")))
+
+ (test "testSingleWordTimerWithPunctuation"
+ '(recipe (metadata ())
+ ((step ("Let it " (timer "rest" #f) ", after plating"))))
+ (cook->list (parse-cook "Let it ~rest, then serve\n")))
+
+ (test "testSingleWordTimerWithUnicodePunctuation"
+ '(recipe (metadata ())
+ ((step ("Let it " (timer "rest" #f) "⸫ then serve"))))
+ (cook->list (parse-cook "Let it ~rest⸫ then serve\n")))
+
+ ; NOTE: the space is U+2009
+ (test "testTimerWithUnicodeWhitespace"
+ '(recipe (metadata ())
+ ((step ("Let it " (timer "rest" #f) " then serve"))))
+ (cook->list (parse-cook "Let it ~rest then serve\n")))
+
+ (test "testInvalidMultiWordTimer"
+ '(recipe (metadata ())
+ ((step ("It is ~ {5}"))))
+ (cook->list (parse-cook "It is ~ {5}\n")))
+
+ (test "testInvalidSingleWordTimer"
+ '(recipe (metadata ())
+ ((step ("It is ~ 5"))))
+ (cook->list (parse-cook "It is ~ 5\n")))
+
+ (test "testSingleWordIngredientWithPunctuation"
+ '(recipe (metadata ())
+ ((step ("Add some " (ingredient "chilli" #f) ", then serve"))))
+ (cook->list (parse-cook "Add some @chilli, then serve\n")))
+
+ (test "testSingleWordIngredientWithUnicodePunctuation"
+ '(recipe (metadata ())
+ ((step ("Add some " (ingredient "chilli" #f) "⸫ then bake"))))
+ (cook->list (parse-cook "Add @chilli⸫ then bake\n")))
+
+ ; NOTE: the space is U+2009
+ (test "testIngredientWithUnicodeWhitespace"
+ '(recipe (metadata ())
+ ((step ("Add some " (ingredient "chilli" #f) " then bake"))))
+ (cook->list (parse-cook "Add @chilli then bake\n")))
+
+ (test "testInvalidMultiWordIngredient"
+ '(recipe (metadata ())
+ ((step ("Message @ example{}"))))
+ (cook->list (parse-cook "Message @ example{}\n")))
+
+ (test "testInvalidSingleWordIngredient"
+ '(recipe (metadata ())
+ ((step ( "Message me @ example"))))
+ (cook->list (parse-cook "Message me @ example\n")))
+
+ (test "testSingleWordCookwareWithPunctuation"
+ '(recipe (metadata ())
+ ((step ( "Place in " (cookware "pot" #f) ", then boil"))))
+ (cook->list (parse-cook "Place in #pot, then boil\n")))
+
+ (test "testSingleWordCookwareWithUnicodePunctuation"
+ '(recipe (metadata ())
+ ((step ( "Place in " (cookware "pot" #f) "⸫ then boil"))))
+ (cook->list (parse-cook "Place in #pot⸫ then boil\n")))
+
+ ; NOTE: the space is U+2009
+ (test "testCookwareWithUnicodeWhitespace"
+ '(recipe (metadata ())
+ ((step ( "Place in " (cookware "pot" #f) " then boil"))))
+ (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"))))