sl@0: # 2008 April 1 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # sl@0: # Test cases designed to exercise and verify the logic for sl@0: # factoring constant expressions out of loops and for sl@0: # common subexpression eliminations. sl@0: # sl@0: # $Id: cse.test,v 1.6 2008/08/04 03:51:24 danielk1977 Exp $ sl@0: # sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: do_test cse-1.1 { sl@0: execsql { sl@0: CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d, e, f); sl@0: INSERT INTO t1 VALUES(1,11,12,13,14,15); sl@0: INSERT INTO t1 VALUES(2,21,22,23,24,25); sl@0: } sl@0: execsql { sl@0: SELECT b, -b, ~b, NOT b, NOT NOT b, b-b, b+b, b*b, b/b, b FROM t1 sl@0: } sl@0: } {11 -11 -12 0 1 0 22 121 1 11 21 -21 -22 0 1 0 42 441 1 21} sl@0: do_test cse-1.2 { sl@0: execsql { sl@0: SELECT b, b%b, b==b, b!=b, b49} {set r [expr {99-$r}]} sl@0: lappend colset a$j a$r sl@0: lappend answer $j $r sl@0: } sl@0: set sql "SELECT [join $colset ,] FROM t2" sl@0: do_test cse-2.2.$i { sl@0: # explain $::sql sl@0: execsql $::sql sl@0: } $answer sl@0: } sl@0: sl@0: finish_test