+
+if [ "${NOTMUCH_HAVE_SFSEXP-0}" = "1" ]; then
+
+ test_query_syntax '(and "wonderful" "wizard")' 'wonderful and wizard'
+ test_query_syntax '(or "php" "wizard")' 'php or wizard'
+ test_query_syntax 'wizard' 'wizard'
+ test_query_syntax 'Wizard' 'Wizard'
+ test_query_syntax '(attachment notmuch-help.patch)' 'attachment:notmuch-help.patch'
+
+fi
+
+add_email_corpus duplicate
+
+ID1=debian/2.6.1.dfsg-4-1-g87ea161@87ea161e851dfb1ea324af00e4ecfccc18875e15
+
+test_begin_subtest "format json, --duplicate=2, duplicate key"
+output=$(notmuch show --format=json --duplicate=2 id:${ID1})
+test_json_nodes <<<"$output" "dup:['duplicate']=2"
+
+test_begin_subtest "format json, subject, --duplicate=1"
+output=$(notmuch show --format=json --duplicate=1 id:${ID1})
+file=$(notmuch search --output=files id:${ID1} | head -n 1)
+subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
+test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""
+
+test_begin_subtest "format json, subject, --duplicate=2"
+output=$(notmuch show --format=json --duplicate=2 id:${ID1})
+file=$(notmuch search --output=files id:${ID1} | tail -n 1)
+subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
+test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""
+
+ID2=87r2geywh9.fsf@tethera.net
+for dup in {1..2}; do
+ test_begin_subtest "format json, body, --duplicate=${dup}"
+ output=$(notmuch show --format=json --duplicate=${dup} id:${ID2} | \
+ $NOTMUCH_PYTHON -B "$NOTMUCH_SRCDIR"/test/json_check_nodes.py "body:['body'][0]['content']" | \
+ grep '^# body')
+ test_expect_equal "$output" "# body ${dup}"
+done
+
+ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
+for dup in {1..5}; do
+ test_begin_subtest "format json, --duplicate=${dup}, 'duplicate' key"
+ output=$(notmuch show --format=json --duplicate=${dup} id:${ID3})
+ test_json_nodes <<<"$output" "dup:['duplicate']=${dup}"
+done
+