Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/cse.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / cse.test` 200 lines ยท 5681 bytes Raw Blame History 1 # 2008 April 1 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # 12 # Test cases designed to exercise and verify the logic for 13 # factoring constant expressions out of loops and for 14 # common subexpression eliminations. 15 # 16 # $Id: cse.test,v 1.6 2008/08/04 03:51:24 danielk1977 Exp $ 17 # 18 19 set testdir [file dirname $argv0] 20 source $testdir/tester.tcl 21 set testprefix cse 22 23 do_test cse-1.1 { 24 execsql { 25 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d, e, f); 26 INSERT INTO t1 VALUES(1,11,12,13,14,15); 27 INSERT INTO t1 VALUES(2,21,22,23,24,25); 28 } 29 execsql { 30 SELECT b, -b, ~b, NOT b, NOT NOT b, b-b, b+b, b*b, b/b, b FROM t1 31 } 32 } {11 -11 -12 0 1 0 22 121 1 11 21 -21 -22 0 1 0 42 441 1 21} 33 do_test cse-1.2 { 34 execsql { 35 SELECT b, b%b, b==b, b!=b, b49} {set r [expr {99-$r}]} 151 lappend colset a$j a$r 152 lappend answer $j $r 153 } 154 set sql "SELECT [join $colset ,] FROM t2" 155 do_test cse-2.2.$i { 156 # explain $::sql 157 execsql $::sql 158 } $answer 159 } 160 161 #------------------------------------------------------------------------- 162 # Ticket `fd1bda016d1a` 163 # 164 reset_db 165 do_execsql_test 3.0 { 166 CREATE TABLE t1(a TEXT, b); 167 INSERT INTO t1 VALUES('hello', 0); 168 INSERT INTO t1 VALUES('world', 0); 169 170 CREATE TABLE t2(x TEXT); 171 INSERT INTO t2 VALUES('hello'); 172 INSERT INTO t2 VALUES('world'); 173 174 CREATE TABLE t3(y); 175 INSERT INTO t3 VALUES(1000); 176 } {} 177 178 do_execsql_test 3.1 { 179 SELECT 1000 = y FROM t3 180 } {1} 181 182 do_execsql_test 3.2 { 183 SELECT 1000 IN (SELECT x FROM t2), 1000 = y FROM t3 184 } {0 1} 185 186 do_execsql_test 3.3 { 187 SELECT 0 IN (SELECT a), (SELECT a LIMIT 0) FROM t1 188 } {0 {} 0 {}} 189 190 do_execsql_test 3.4 { 191 SELECT 0 IN (SELECT a) FROM t1 WHERE a = 'hello' OR (SELECT a LIMIT 0); 192 } {0} 193 194 do_execsql_test 3.5 { 195 CREATE TABLE v0(v1 VARCHAR0); 196 INSERT INTO v0 VALUES(2), (3); 197 SELECT 0 IN(SELECT v1) FROM v0 WHERE v1 = 2 OR(SELECT v1 LIMIT 0); 198 } {0} 199 200 finish_test