Cooklang ā README
Canonical tests for parsers
Datastructure
Every tests looks like this:
testBasicDirection: ā¹ 1
source: | ā¹ 2
Add a bit of chilli
result: ā¹ 3
steps:
-
- type: text ā¹ 4
value: "Add a bit of chilli"
metadata: ā¹ 5
"cooking time": 30 minsKey components:
Test name. It gives an idea what feature this test is testing and can be useful for debugging.
Source. Recipe text file as it'd provided by a user.
Result. Expected result of parsing. It consists of multiple steps and metadata.
Direction item. Every step consists of multiple direction items. There're four types:
texthasvaluewhich contains text used in step.ingredienthasname,quantityandunits, andoptional: truewhen marked with?(optionaldefaults tofalseand is omitted when false).cookwarehasnameandquantity, andoptionallike ingredients.timerhasname,quantityandunits.
Metadata is in key/value form.
Example usage in https://github.com/cooklang/CookInSwift.