Commit 2c000dce authored by Mathieu Giraud's avatar Mathieu Giraud

demo/json.should, demo/tests/concepts.json: json testing

see #51
parent 13289ff7
cat demo/tests/concepts.json
# Testing json output with regular should tests is not very convenient
$ Regular text,
rl1:directions.*east
# With the 'j' modifier, data is interpreted as a json file
$ With 'j' and a single ':', tests are on the keys
j:concepts.directions
j:concepts.wuxing.earth
j0:concepts.winds
j:numbers[3].meaning
j0:numbers[2].meaning
$ Tests can further be on number of elements in arrays and objects
j>2:numbers
j<7:concepts.winds
j4:concepts.directions
j5:concepts.wuxing
$ With a second ':', an expression is tested on the values
j:numbers:12
j:concepts.directions:rth
j:concepts.directions[2]:outh
j0:concepts.directions[3]:outh
j0:concepts.wuxing:st
$ The number of matching expressions can also be tested
j2:concepts.directions:st
j<7:concepts.winds:foo
$ Ignore case ('i') and regular expressions ('r') apply to the expression
ji:concepts.directions:RtH
jr:concepts.directions:no.th
jr>1:concepts.directions:e.*?st
$ Data that are not parsed as json yield 0 occurrences
echo "hello, world"
j0:hello
{
"numbers" : [ 3, 7, 12, {"meaning": 42} ],
"concepts":
{
"directions" : [
"north",
"east",
"south",
"west"
],
"wuxing" : {
"fire": "火",
"water": "水",
"wood": "木",
"metal": "金",
"earth": "土"
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment