1df0bddaeSdrh# 2005 June 25 2df0bddaeSdrh# 3df0bddaeSdrh# The author disclaims copyright to this source code. In place of 4df0bddaeSdrh# a legal notice, here is a blessing: 5df0bddaeSdrh# 6df0bddaeSdrh# May you do good and not evil. 7df0bddaeSdrh# May you find forgiveness for yourself and forgive others. 8df0bddaeSdrh# May you share freely, never taking more than you give. 9df0bddaeSdrh# 10df0bddaeSdrh#*********************************************************************** 11df0bddaeSdrh# This file implements regression tests for SQLite library. The focus 12df0bddaeSdrh# of this file is testing the interaction of SQLite manifest types 13df0bddaeSdrh# with Tcl dual-representations. 14df0bddaeSdrh# 15d65e530bSdrh# $Id: types3.test,v 1.8 2008/04/28 13:02:58 drh Exp $ 16df0bddaeSdrh# 17df0bddaeSdrh 18df0bddaeSdrhset testdir [file dirname $argv0] 19df0bddaeSdrhsource $testdir/tester.tcl 20df0bddaeSdrh 21df0bddaeSdrh# A variable with only a string representation comes in as TEXT 22df0bddaeSdrhdo_test types3-1.1 { 23df0bddaeSdrh set V {} 24*0c13e9c7Sdan append V x 253bdca9c9Sdanielk1977 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 26df0bddaeSdrh} {string text} 27df0bddaeSdrh 28df0bddaeSdrh# A variable with an integer representation comes in as INTEGER 29df0bddaeSdrhdo_test types3-1.2 { 308cbadb02Sdanielk1977 set V [expr {int(1+2)}] 313bdca9c9Sdanielk1977 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 32df0bddaeSdrh} {int integer} 3399bcd30bSdrhset V [expr {1+12345678012345}] 3499bcd30bSdrhif {[tcl_variable_type V]=="wideInt"} { 35df0bddaeSdrh do_test types3-1.3 { 36df0bddaeSdrh set V [expr {1+123456789012345}] 373bdca9c9Sdanielk1977 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 38df0bddaeSdrh } {wideInt integer} 3999bcd30bSdrh} else { 4099bcd30bSdrh do_test types3-1.3 { 4199bcd30bSdrh set V [expr {1+123456789012345}] 4299bcd30bSdrh concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 4399bcd30bSdrh } {int integer} 4499bcd30bSdrh} 45df0bddaeSdrh 46df0bddaeSdrh# A double variable comes in as REAL 47df0bddaeSdrhdo_test types3-1.4 { 48df0bddaeSdrh set V [expr {1.0+1}] 493bdca9c9Sdanielk1977 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 50df0bddaeSdrh} {double real} 51df0bddaeSdrh 52df0bddaeSdrh# A byte-array variable comes in a BLOB if it has no string representation 53df0bddaeSdrh# or as TEXT if there is a string representation. 54df0bddaeSdrh# 55df0bddaeSdrhdo_test types3-1.5 { 56df0bddaeSdrh set V [binary format a3 abc] 573bdca9c9Sdanielk1977 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 58df0bddaeSdrh} {bytearray blob} 59df0bddaeSdrhdo_test types3-1.6 { 60df0bddaeSdrh set V "abc" 61df0bddaeSdrh binary scan $V a3 x 623bdca9c9Sdanielk1977 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 63df0bddaeSdrh} {bytearray text} 64df0bddaeSdrh 65df0bddaeSdrh# Check to make sure return values are of the right types. 66df0bddaeSdrh# 67ff890793Sdanielk1977ifcapable bloblit { 68df0bddaeSdrh do_test types3-2.1 { 69df0bddaeSdrh set V [db one {SELECT x'616263'}] 70df0bddaeSdrh tcl_variable_type V 71df0bddaeSdrh } bytearray 72ff890793Sdanielk1977} 73df0bddaeSdrhdo_test types3-2.2 { 74df0bddaeSdrh set V [db one {SELECT 123}] 75df0bddaeSdrh tcl_variable_type V 76df0bddaeSdrh} int 77d65e530bSdrhset Vx [expr {1+wide(123456789123456)}] 78df0bddaeSdrhdo_test types3-2.3 { 79df0bddaeSdrh set V [db one {SELECT 1234567890123456}] 80df0bddaeSdrh tcl_variable_type V 81d65e530bSdrh} [tcl_variable_type Vx] 828df447f0Sdrhdo_test types3-2.4.1 { 838df447f0Sdrh set V [db one {SELECT 1234567890123456.1}] 848df447f0Sdrh tcl_variable_type V 858a51256cSdrh} double 868df447f0Sdrhdo_test types3-2.4.2 { 878df447f0Sdrh set V [db one {SELECT 1234567890123.456}] 88df0bddaeSdrh tcl_variable_type V 89df0bddaeSdrh} double 90df0bddaeSdrhdo_test types3-2.5 { 91df0bddaeSdrh set V [db one {SELECT '1234567890123456.0'}] 92df0bddaeSdrh tcl_variable_type V 93df0bddaeSdrh} {} 94df0bddaeSdrhdo_test types3-2.6 { 95df0bddaeSdrh set V [db one {SELECT NULL}] 96df0bddaeSdrh tcl_variable_type V 97df0bddaeSdrh} {} 98df0bddaeSdrh 99df0bddaeSdrhfinish_test 100