From 18657a960e125336f704ea058e25c27bd3900dcb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 19:28:19 +0200 Subject: Adding upstream version 3.40.1. Signed-off-by: Daniel Baumann --- test/cse.test | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 test/cse.test (limited to 'test/cse.test') diff --git a/test/cse.test b/test/cse.test new file mode 100644 index 0000000..3912bc3 --- /dev/null +++ b/test/cse.test @@ -0,0 +1,200 @@ +# 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.6 2008/08/04 03:51:24 danielk1977 Exp $ +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix cse + +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 +} + +#------------------------------------------------------------------------- +# Ticket fd1bda016d1a +# +reset_db +do_execsql_test 3.0 { + CREATE TABLE t1(a TEXT, b); + INSERT INTO t1 VALUES('hello', 0); + INSERT INTO t1 VALUES('world', 0); + + CREATE TABLE t2(x TEXT); + INSERT INTO t2 VALUES('hello'); + INSERT INTO t2 VALUES('world'); + + CREATE TABLE t3(y); + INSERT INTO t3 VALUES(1000); +} {} + +do_execsql_test 3.1 { + SELECT 1000 = y FROM t3 +} {1} + +do_execsql_test 3.2 { + SELECT 1000 IN (SELECT x FROM t2), 1000 = y FROM t3 +} {0 1} + +do_execsql_test 3.3 { + SELECT 0 IN (SELECT a), (SELECT a LIMIT 0) FROM t1 +} {0 {} 0 {}} + +do_execsql_test 3.4 { + SELECT 0 IN (SELECT a) FROM t1 WHERE a = 'hello' OR (SELECT a LIMIT 0); +} {0} + +do_execsql_test 3.5 { + CREATE TABLE v0(v1 VARCHAR0); + INSERT INTO v0 VALUES(2), (3); + SELECT 0 IN(SELECT v1) FROM v0 WHERE v1 = 2 OR(SELECT v1 LIMIT 0); +} {0} + +finish_test -- cgit v1.2.3