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