[PATCH 6/9] CLI: refactor dumping of tags.
[notmuch-archives.git] / ca / 6f77f5fa5d208f1575915fe2213086f9b7a4b3
1 Return-Path: <amdragon@mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 260E5431FD0\r
6         for <notmuch@notmuchmail.org>; Thu, 20 Jan 2011 22:39:06 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id vb7Iq-+YL-GI for <notmuch@notmuchmail.org>;\r
16         Thu, 20 Jan 2011 22:39:05 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
18         [18.9.25.12])\r
19         by olra.theworths.org (Postfix) with ESMTP id 15899431FB6\r
20         for <notmuch@notmuchmail.org>; Thu, 20 Jan 2011 22:39:05 -0800 (PST)\r
21 X-AuditID: 1209190c-b7ba9ae0000009f8-0c-4d392a08d2ef\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-1.mit.edu (Symantec Brightmail Gateway) with\r
24         SMTP id CB.B4.02552.80A293D4; Fri, 21 Jan 2011 01:39:04 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id p0L6d3aZ004971; \r
27         Fri, 21 Jan 2011 01:39:03 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p0L6d2Bd004787\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Fri, 21 Jan 2011 01:39:03 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1PgAeE-0000zO-Ie; Fri, 21 Jan 2011 01:39:02 -0500\r
37 Date: Fri, 21 Jan 2011 01:39:02 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 2.5/8] Query parser tests for NEAR and ADJ operators.\r
41 Message-ID: <20110121063902.GJ13226@mit.edu>\r
42 References: <1295165458-9573-1-git-send-email-amdragon@mit.edu>\r
43         <1295165458-9573-3-git-send-email-amdragon@mit.edu>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 Content-Disposition: inline\r
47 In-Reply-To: <1295165458-9573-3-git-send-email-amdragon@mit.edu>\r
48 User-Agent: Mutt/1.5.20 (2009-06-14)\r
49 X-Brightmail-Tracker: AAAAAA==\r
50 Cc: amdragon@mit.edu\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Fri, 21 Jan 2011 06:39:06 -0000\r
64 \r
65 ---\r
66 This is intended to be applied after patch 2/8 in this series,\r
67 id:1295165458-9573-3-git-send-email-amdragon@mit.edu\r
68 \r
69  test/qparser                              |    5 ++\r
70  test/qparser.expected-output/near-and-adj |   83 +++++++++++++++++++++++++++++\r
71  test/qparser.expected-output/operators    |   12 ++++\r
72  test/qparser.expected-output/probs        |    6 ++\r
73  4 files changed, 106 insertions(+), 0 deletions(-)\r
74  create mode 100644 test/qparser.expected-output/near-and-adj\r
75 \r
76 diff --git a/test/qparser b/test/qparser\r
77 index 0e7b022..7ed5c97 100755\r
78 --- a/test/qparser\r
79 +++ b/test/qparser\r
80 @@ -24,6 +24,11 @@ output=$(../qparser-test < $EXPECTED/operators)\r
81  expected=$(cat $EXPECTED/operators)\r
82  test_expect_equal "$output" "$expected"\r
83  \r
84 +test_begin_subtest "Near and adj"\r
85 +output=$(../qparser-test < $EXPECTED/near-and-adj)\r
86 +expected=$(cat $EXPECTED/near-and-adj)\r
87 +test_expect_equal "$output" "$expected"\r
88 +\r
89  test_begin_subtest "Probs"\r
90  output=$(../qparser-test < $EXPECTED/probs)\r
91  expected=$(cat $EXPECTED/probs)\r
92 diff --git a/test/qparser.expected-output/near-and-adj b/test/qparser.expected-output/near-and-adj\r
93 new file mode 100644\r
94 index 0000000..0da4689\r
95 --- /dev/null\r
96 +++ b/test/qparser.expected-output/near-and-adj\r
97 @@ -0,0 +1,83 @@\r
98 +x near y\r
99 +[lex]    "x" NEAR "y"\r
100 +[parse]  (NEAR "x" (NEAR "y"))\r
101 +[gen]    (x:(pos=1) NEAR 11 y:(pos=2))\r
102 +\r
103 +x near y near z\r
104 +[lex]    "x" NEAR "y" NEAR "z"\r
105 +[parse]  (NEAR "x" (NEAR "y" (NEAR "z")))\r
106 +[gen]    (x:(pos=1) NEAR 12 y:(pos=2) NEAR 12 z:(pos=3))\r
107 +\r
108 +x near/2 y\r
109 +[lex]    "x" NEAR/2 "y"\r
110 +[parse]  (NEAR "x" (NEAR/2 "y"))\r
111 +[gen]    (x:(pos=1) NEAR 3 y:(pos=2))\r
112 +\r
113 +x near/2 y near z\r
114 +[lex]    "x" NEAR/2 "y" NEAR "z"\r
115 +[parse]  (NEAR "x" (NEAR/2 "y" (NEAR "z")))\r
116 +[gen]    (x:(pos=1) NEAR 4 y:(pos=2) NEAR 4 z:(pos=3))\r
117 +\r
118 +x near y near/2 z\r
119 +[lex]    "x" NEAR "y" NEAR/2 "z"\r
120 +[parse]  (NEAR "x" (NEAR "y" (NEAR/2 "z")))\r
121 +[gen]    (x:(pos=1) NEAR 4 y:(pos=2) NEAR 4 z:(pos=3))\r
122 +\r
123 +x near/0 y\r
124 +[lex]    "x" "near/0" "y"\r
125 +[parse]  (AND (AND "x" "near/0") "y")\r
126 +[gen]    (x:(pos=1) AND (near:(pos=2) PHRASE 2 0:(pos=3)) AND y:(pos=4))\r
127 +\r
128 +x near/2z y\r
129 +[lex]    "x" "near/2z" "y"\r
130 +[parse]  (AND (AND "x" "near/2z") "y")\r
131 +[gen]    (x:(pos=1) AND (near:(pos=2) PHRASE 2 2z:(pos=3)) AND y:(pos=4))\r
132 +\r
133 +# The first query below is Xapian-compatible; while the secnd one\r
134 +# isn't.  In both cases, Xapian initially sees "near" as a NEAR\r
135 +# operator, but in the first case the trailing y is a syntax error,\r
136 +# which cases Xapian to reparse with no flags.\r
137 +x near/z y\r
138 +[lex]    "x" "near/z" "y"\r
139 +[parse]  (AND (AND "x" "near/z") "y")\r
140 +[gen]    (x:(pos=1) AND (near:(pos=2) PHRASE 2 z:(pos=3)) AND y:(pos=4))\r
141 +\r
142 +x near/z\r
143 +[lex]    "x" "near/z"\r
144 +[parse]  (AND "x" "near/z")\r
145 +[gen]    (x:(pos=1) AND (near:(pos=2) PHRASE 2 z:(pos=3)))\r
146 +[xapian] (x:(pos=1) NEAR 11 z:(pos=2))\r
147 +\r
148 +x adj y adj z\r
149 +[lex]    "x" ADJ "y" ADJ "z"\r
150 +[parse]  (ADJ "x" (ADJ "y" (ADJ "z")))\r
151 +[gen]    (x:(pos=1) PHRASE 12 y:(pos=2) PHRASE 12 z:(pos=3))\r
152 +\r
153 +# Syntax errors\r
154 +# These are all Xapian-incompatible because they're syntax errors.\r
155 +(x) NEAR y\r
156 +[lex]    BRA "x" KET NEAR "y"\r
157 +[parse]  (AND (AND "x" "NEAR") "y")\r
158 +[gen]    (x:(pos=1) AND near:(pos=2) AND y:(pos=3))\r
159 +\r
160 +x NEAR (y)\r
161 +[lex]    "x" NEAR BRA "y" KET\r
162 +[parse]  (AND (AND "x" "NEAR") "y")\r
163 +[gen]    (x:(pos=1) AND near:(pos=2) AND y:(pos=3))\r
164 +\r
165 +x NEAR y NEAR (z)\r
166 +[lex]    "x" NEAR "y" NEAR BRA "z" KET\r
167 +[parse]  (AND (AND (NEAR "x" (NEAR "y")) "NEAR") "z")\r
168 +[gen]    ((x:(pos=1) NEAR 11 y:(pos=2)) AND near:(pos=3) AND z:(pos=4))\r
169 +[xapian] (x:(pos=1) AND near:(pos=2) AND y:(pos=3) AND near:(pos=4) AND z:(pos=5))\r
170 +\r
171 +x NEAR y ADJ z\r
172 +[lex]    "x" NEAR "y" ADJ "z"\r
173 +[parse]  (AND (AND (NEAR "x" (NEAR "y")) "ADJ") "z")\r
174 +[gen]    ((x:(pos=1) NEAR 11 y:(pos=2)) AND adj:(pos=3) AND z:(pos=4))\r
175 +[xapian] (x:(pos=1) AND near:(pos=2) AND y:(pos=3) AND adj:(pos=4) AND z:(pos=5))\r
176 +\r
177 +NEAR x\r
178 +[lex]    NEAR "x"\r
179 +[parse]  (AND "NEAR" "x")\r
180 +[gen]    (near:(pos=1) AND x:(pos=2))\r
181 diff --git a/test/qparser.expected-output/operators b/test/qparser.expected-output/operators\r
182 index 788f007..3d69f9b 100644\r
183 --- a/test/qparser.expected-output/operators\r
184 +++ b/test/qparser.expected-output/operators\r
185 @@ -143,3 +143,15 @@ x OR @\r
186  [parse]  (OR "x" "@")\r
187  [gen]    x:(pos=1)\r
188  [xapian] error Syntax: <expression> OR <expression>\r
189 +\r
190 +@ NEAR x\r
191 +[lex]    "@" NEAR "x"\r
192 +[parse]  (NEAR "@" (NEAR "x"))\r
193 +[gen]    x:(pos=1)\r
194 +[xapian] (near:(pos=1) AND x:(pos=2))\r
195 +\r
196 +x NEAR @\r
197 +[lex]    "x" NEAR "@"\r
198 +[parse]  (NEAR "x" (NEAR "@"))\r
199 +[gen]    x:(pos=1)\r
200 +[xapian] (x:(pos=1) AND near:(pos=2))\r
201 diff --git a/test/qparser.expected-output/probs b/test/qparser.expected-output/probs\r
202 index 3c166f7..8f50cdc 100644\r
203 --- a/test/qparser.expected-output/probs\r
204 +++ b/test/qparser.expected-output/probs\r
205 @@ -10,6 +10,12 @@\r
206  [gen]    ((x:(pos=1) OR y:(pos=2)) AND z:(pos=3))\r
207  [xapian] (x:(pos=1) AND or:(pos=2) AND y:(pos=3) AND and:(pos=4) AND z:(pos=5))\r
208  \r
209 +# Near binds tighter than hate\r
210 +x -y NEAR z\r
211 +[lex]    "x" HATE "y" NEAR "z"\r
212 +[parse]  (AND "x" (NOT (NEAR "y" (NEAR "z"))))\r
213 +[gen]    (x:(pos=1) AND_NOT (y:(pos=2) NEAR 11 z:(pos=3)))\r
214 +\r
215  # Empty subexpression after prefix\r
216  # Incompatible; Xapian treats as a syntax error.\r
217  prob:() AND x\r
218 -- \r
219 1.7.2.3\r
220 \r