summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-08-11 00:37:31 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-08-11 00:37:35 +0200
commit472a3f33ef5785dfb600a9adf0f9862081786d64 (patch)
tree0924a9d04efaa49f9cae115a72a30849cdbd855f
parent552247c3aea2d5849f3a76c217db6eac0f022069 (diff)
tests: WIP add official tests
-rw-r--r--tests/parse.scm212
1 files changed, 181 insertions, 31 deletions
diff --git a/tests/parse.scm b/tests/parse.scm
index 28707a0..4959f5d 100644
--- a/tests/parse.scm
+++ b/tests/parse.scm
@@ -15,35 +15,185 @@
(test "float" 10.1 (parse quantity "10.1"))
(test "fraction" 1/10 (parse quantity "1/10")))
-;(define (test x y)
-; (display "Testing: ")
-; (display x)
-; (display " == ")
-; (display (cook->list y))
-; (newline))
-;(test 'NEWLINE (parse nl "\n\r\r\n"))
-;(test 'WHITESPACE (parse whitespace " \t aaaa aaa "))
-;(test 'COMMENT (parse comment "-- aasf ljalsfkjalsfdjalsfd\n"))
-;
-;(test 'BLOCK-COMMENT ;; TODO: Check greediness
-; (parse comment "[- aasfjal sfkjalsfdjalsfd\nashfajsdf\nsdfasf-]"))
-;
-;(test 'WORD (parse word "hola. adios"))
-;(test 'UNIT (parse unit "l"))
-;(test 'WORD-COMPONENT (parse-fully component "word{}"))
-;(test 'WORD-COMPONENT (parse-fully component "word{9%head}"))
-;(test 'WORD-COMPONENT (parse-fully component "word"))
-;(test 'MULTI-WORD-COMPONENT (parse-fully component "un multi word{}"))
-;(test 'MULTI-WORD-COMPONENT (parse-fully component "un multi word{10}"))
-;(test 'MULTI-WORD-COMPONENT (parse-fully component "un multi word{10%l}"))
-;(test 'MULTI-WORD-COMPONENT (parse-fully component "un multi word{80%mm}"))
-;(test 'NO-NAME-TIMER (parse-fully timer "~{}"))
-;(test 'MULTI-WORD-TIMER (parse-fully timer "~un multi word{10}"))
-;(test 'MULTI-WORD-TIMER (parse-fully timer "~un multi word{10%l}"))
-;(test 'MULTI-WORD-TIMER (parse-fully timer "~un multi word{80%mm}"))
-;(test 'NO-NAME-TIMER (parse-fully timer "~{12%min}"))
-;(test 'INGREDIENT (parse-fully ingredient "@potato{12%kg}"))
-;(test 'STEP (parse-fully step "un poco de texto seguido de ~un multi word{10}"))
-;(test 'RECIPE (parse recipe "this is a recipe with @coconut{1}\nAnd takes ~{2%min}\n"))
-;(test 'RECIPE (parse recipe ">> some: metadata\nthis is a recipe with @coconut{1}\nAnd takes ~{2%min}\n"))
+(test-group "Official"
+ (test "testBasicDirection"
+ (cook->list '(recipe (metadata ()) ((step ("Add a bit of chilli")))))
+ (parse-cook "Add a bit of chilli\n"))
+ (test "testComments"
+ (cook->list '(recipe (metadata ()) ((comment ("testing comments")))))
+ (parse-cook "-- testing comments\n"))
+ (test "testCommentsAfterIngredients"
+ (cook->list '())
+ (parse-cook "@thyme{2%sprigs} -- testing comments\nand some text\n"))
+ (test "testCommentsWithIngredients"
+ (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"
+ (cook->list '(recipe (metadata ()) ((step ("Recipe # 10{}")))))
+ (parse-cook "Recipe # 10{}\n"))
+ (test "testInvalidSingleWordCookware"
+ (cook->list '(recipe (metadata ()) ((step ("Recipe # 5")))))
+ (parse-cook "Recipe # 5\n")))