OLD | NEW |
1 # 2015 May 30 | 1 # 2015 May 30 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #************************************************************************* | 10 #************************************************************************* |
11 # | 11 # |
12 # This file contains automatically generated tests for various types | 12 # This file contains automatically generated tests for various types |
13 # of MATCH expressions. | 13 # of MATCH expressions. |
14 # | 14 # |
15 | 15 |
16 source [file join [file dirname [info script]] fts5_common.tcl] | 16 source [file join [file dirname [info script]] fts5_common.tcl] |
17 set testprefix fts5auto | 17 set testprefix fts5auto |
18 | 18 |
19 # If SQLITE_ENABLE_FTS5 is defined, omit this file. | 19 # If SQLITE_ENABLE_FTS5 is defined, omit this file. |
20 ifcapable !fts5 { | 20 ifcapable !fts5 { |
21 finish_test | 21 finish_test |
22 return | 22 return |
23 } | 23 } |
24 | 24 |
25 | |
26 set data { | 25 set data { |
27 -4026076 | 26 -4026076 |
28 {n x w k b p x b n t t d s} {f j j s p j o} | 27 {n x w k b p x b n t t d s} {f j j s p j o} |
29 {w v i y r} {i p y s} | 28 {w v i y r} {i p y s} |
30 {a o q v e n q r} {q v g u c y a z y} | 29 {a o q v e n q r} {q v g u c y a z y} |
31 3995120 | 30 3995120 |
32 {c} {e e w d t} | 31 {c} {e e w d t} |
33 {x c p f w r s m l r b f d} {g g u e} | 32 {x c p f w r s m l r b f d} {g g u e} |
34 {s n u t d v p d} {b k v p m f} | 33 {s n u t d v p d} {b k v p m f} |
35 -2913881 | 34 -2913881 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 {v a z o i e n l x l r} {r u f o r k w m d w} | 224 {v a z o i e n l x l r} {r u f o r k w m d w} |
226 {k s} {r f e j q p w} | 225 {k s} {r f e j q p w} |
227 } | 226 } |
228 | 227 |
229 do_execsql_test 1.0 { | 228 do_execsql_test 1.0 { |
230 CREATE VIRTUAL TABLE tt USING fts5(a, b, c, d, e, f); | 229 CREATE VIRTUAL TABLE tt USING fts5(a, b, c, d, e, f); |
231 } {} | 230 } {} |
232 | 231 |
233 fts5_aux_test_functions db | 232 fts5_aux_test_functions db |
234 | 233 |
235 proc matchdata {expr tbl collist {order ASC}} { | 234 proc do_auto_test {tn tbl expr} { |
236 | |
237 set cols "" | |
238 foreach e $collist { | |
239 append cols ", '$e'" | |
240 } | |
241 | |
242 set tclexpr [db one [subst -novar { | |
243 SELECT fts5_expr_tcl( | |
244 $expr, 'nearset $cols -pc ::pc' [set cols] | |
245 ) | |
246 }]] | |
247 set res [list] | |
248 | |
249 db eval "SELECT rowid, * FROM $tbl ORDER BY rowid $order" x { | |
250 set cols [list] | |
251 foreach col $x(*) { | |
252 if {$col != "rowid"} { lappend cols $x($col) } | |
253 } | |
254 # set cols [list $a $b $c $d $e $f] | |
255 set ::pc 0 | |
256 set rowdata [eval $tclexpr] | |
257 if {$rowdata != ""} { lappend res $x(rowid) $rowdata } | |
258 } | |
259 | |
260 set res | |
261 } | |
262 | |
263 proc do_auto_test {tn tbl cols expr} { | |
264 foreach order {asc desc} { | 235 foreach order {asc desc} { |
265 set res [matchdata $expr $tbl $cols $order] | 236 set res [fts5_poslist_data $expr $tbl $order] |
266 set testname "$tn.[string range $order 0 0].rows=[expr [llength $res]/2]" | 237 set testname "$tn.[string range $order 0 0].rows=[expr [llength $res]/2]" |
267 | 238 |
268 set ::autotest_expr $expr | 239 set ::autotest_expr $expr |
269 do_execsql_test $testname [subst -novar { | 240 do_execsql_test $testname [subst -novar { |
270 SELECT rowid, fts5_test_poslist([set tbl]) FROM [set tbl] | 241 SELECT rowid, fts5_test_poslist([set tbl]) FROM [set tbl] |
271 WHERE [set tbl] MATCH $::autotest_expr ORDER BY rowid [set order] | 242 WHERE [set tbl] MATCH $::autotest_expr ORDER BY rowid [set order] |
272 }] $res | 243 }] $res |
273 } | 244 } |
274 | |
275 | |
276 } | 245 } |
277 | 246 |
278 #------------------------------------------------------------------------- | 247 #------------------------------------------------------------------------- |
279 # | 248 # |
280 | 249 |
281 for {set fold 0} {$fold < 3} {incr fold} { | 250 for {set fold 0} {$fold < 3} {incr fold} { |
282 switch $fold { | 251 switch $fold { |
283 0 { set map {} } | 252 0 { set map {} } |
284 1 { set map { | 253 1 { set map { |
285 a a b a c b d b e c f c g d h d | 254 a a b a c b d b e c f c g d h d |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 B.1 { a NOT b } | 294 B.1 { a NOT b } |
326 B.2 { a NOT a:b } | 295 B.2 { a NOT a:b } |
327 B.3 { a OR (b AND c) } | 296 B.3 { a OR (b AND c) } |
328 B.4 { a OR (b AND {a b c}:c) } | 297 B.4 { a OR (b AND {a b c}:c) } |
329 B.5 { a OR "b c" } | 298 B.5 { a OR "b c" } |
330 B.6 { a OR b OR c } | 299 B.6 { a OR b OR c } |
331 | 300 |
332 C.1 { a OR (b AND "b c") } | 301 C.1 { a OR (b AND "b c") } |
333 C.2 { a OR (b AND "z c") } | 302 C.2 { a OR (b AND "z c") } |
334 } { | 303 } { |
335 do_auto_test 3.$fold.$tn tt {a b c d e f} $expr | 304 do_auto_test 3.$fold.$tn tt $expr |
336 } | 305 } |
337 } | 306 } |
338 | 307 |
339 proc replace_elems {list args} { | 308 proc replace_elems {list args} { |
340 set ret $list | 309 set ret $list |
341 foreach {idx elem} $args { | 310 foreach {idx elem} $args { |
342 set ret [lreplace $ret $idx $idx $elem] | 311 set ret [lreplace $ret $idx $idx $elem] |
343 } | 312 } |
344 set ret | 313 set ret |
345 } | 314 } |
(...skipping 13 matching lines...) Expand all Loading... |
359 } {} | 328 } {} |
360 | 329 |
361 foreach {tn expr} { | 330 foreach {tn expr} { |
362 1 x | 331 1 x |
363 2 y | 332 2 y |
364 3 z | 333 3 z |
365 | 334 |
366 4 {c1 : x} 5 {c2 : x} 6 {c3 : x} | 335 4 {c1 : x} 5 {c2 : x} 6 {c3 : x} |
367 7 {c1 : y} 8 {c2 : y} 9 {c3 : y} | 336 7 {c1 : y} 8 {c2 : y} 9 {c3 : y} |
368 10 {c1 : z} 11 {c2 : z} 12 {c3 : z} | 337 10 {c1 : z} 11 {c2 : z} 12 {c3 : z} |
369 | |
370 | |
371 } { | 338 } { |
372 breakpoint | 339 do_auto_test 4.$tn yy $expr |
373 do_auto_test 4.$tn yy {c1 c2 c3} $expr | |
374 } | 340 } |
375 | 341 |
376 | 342 |
377 | 343 |
378 finish_test | 344 finish_test |
379 | 345 |
OLD | NEW |