OLD | NEW |
1 # 2014 June 17 | 1 # 2014 June 17 |
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 #************************************************************************* |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 proc do_syntax_test {tn expr res} { | 27 proc do_syntax_test {tn expr res} { |
28 set ::se_expr $expr | 28 set ::se_expr $expr |
29 do_execsql_test $tn {SELECT fts5_expr($se_expr)} [list $res] | 29 do_execsql_test $tn {SELECT fts5_expr($se_expr)} [list $res] |
30 } | 30 } |
31 | 31 |
32 foreach {tn expr res} { | 32 foreach {tn expr res} { |
33 1 {abc} {"abc"} | 33 1 {abc} {"abc"} |
34 2 {abc ""} {"abc"} | 34 2 {abc ""} {"abc"} |
35 3 {""} {} | 35 3 {""} {} |
36 4 {abc OR ""} {"abc"} | 36 4 {abc OR ""} {"abc" OR ""} |
37 5 {abc NOT ""} {"abc"} | 37 5 {abc NOT ""} {"abc" NOT ""} |
38 6 {abc AND ""} {"abc"} | 38 6 {abc AND ""} {"abc" AND ""} |
39 7 {"" OR abc} {"abc"} | 39 7 {"" OR abc} {"" OR "abc"} |
40 8 {"" NOT abc} {"abc"} | 40 8 {"" NOT abc} {"" NOT "abc"} |
41 9 {"" AND abc} {"abc"} | 41 9 {"" AND abc} {"" AND "abc"} |
42 10 {abc + "" + def} {"abc" + "def"} | 42 10 {abc + "" + def} {"abc" + "def"} |
43 11 {abc "" def} {"abc" AND "def"} | 43 11 {abc "" def} {"abc" AND "def"} |
44 12 {r+e OR w} {"r" + "e" OR "w"} | 44 12 {r+e OR w} {"r" + "e" OR "w"} |
| 45 |
| 46 13 {a AND b NOT c} {"a" AND ("b" NOT "c")} |
| 47 14 {a OR b NOT c} {"a" OR ("b" NOT "c")} |
| 48 15 {a NOT b AND c} {("a" NOT "b") AND "c"} |
| 49 16 {a NOT b OR c} {("a" NOT "b") OR "c"} |
| 50 |
| 51 17 {a AND b OR c} {("a" AND "b") OR "c"} |
| 52 18 {a OR b AND c} {"a" OR ("b" AND "c")} |
| 53 |
45 } { | 54 } { |
46 do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res] | 55 do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res] |
47 } | 56 } |
48 | 57 |
49 do_catchsql_test 2.1 { | 58 do_catchsql_test 2.1 { |
50 SELECT fts5_expr() | 59 SELECT fts5_expr() |
51 } {1 {wrong number of arguments to function fts5_expr}} | 60 } {1 {wrong number of arguments to function fts5_expr}} |
52 | 61 |
53 do_catchsql_test 2.1 { | 62 do_catchsql_test 2.1 { |
54 SELECT fts5_expr_tcl() | 63 SELECT fts5_expr_tcl() |
55 } {1 {wrong number of arguments to function fts5_expr_tcl}} | 64 } {1 {wrong number of arguments to function fts5_expr_tcl}} |
56 | 65 |
| 66 |
| 67 do_execsql_test 3.0 { |
| 68 CREATE VIRTUAL TABLE e1 USING fts5(text, tokenize = 'porter unicode61'); |
| 69 INSERT INTO e1 VALUES ("just a few words with a / inside"); |
| 70 } |
| 71 do_execsql_test 3.1 { |
| 72 SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '"just"' ORDER BY rank; |
| 73 } {1 -1e-06} |
| 74 do_execsql_test 3.2 { |
| 75 SELECT rowid FROM e1 WHERE e1 MATCH '"/" OR "just"' |
| 76 } 1 |
| 77 do_execsql_test 3.3 { |
| 78 SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '"/" OR "just"' ORDER BY rank; |
| 79 } {1 -1e-06} |
| 80 |
| 81 |
| 82 |
57 finish_test | 83 finish_test |
58 | 84 |
59 | 85 |
60 | 86 |
OLD | NEW |