sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / test / tkt-a8a0d2996a.test
| 1 | # 2014-03-24 |
| 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 | # Tests to verify that arithmetic operators do not change the type of |
| 13 | # input operands. Ticket [a8a0d2996a] |
| 14 | # |
| 15 | |
| 16 | set testdir [file dirname $argv0] |
| 17 | source $testdir/tester.tcl |
| 18 | set testprefix tkt-a8a0d2996a |
| 19 | |
| 20 | do_execsql_test 1.0 { |
| 21 | CREATE TABLE t(x,y); |
| 22 | INSERT INTO t VALUES('1','1'); |
| 23 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1'; |
| 24 | } {text text} |
| 25 | do_execsql_test 1.1 { |
| 26 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1'; |
| 27 | } {text text} |
| 28 | do_execsql_test 1.2 { |
| 29 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1'; |
| 30 | } {text text} |
| 31 | do_execsql_test 1.3 { |
| 32 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1'; |
| 33 | } {text text} |
| 34 | do_execsql_test 1.4 { |
| 35 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1'; |
| 36 | } {text text} |
| 37 | |
| 38 | do_execsql_test 2.0 { |
| 39 | UPDATE t SET x='1xyzzy'; |
| 40 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1'; |
| 41 | } {text text} |
| 42 | do_execsql_test 2.1 { |
| 43 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1'; |
| 44 | } {text text} |
| 45 | do_execsql_test 2.2 { |
| 46 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1'; |
| 47 | } {text text} |
| 48 | do_execsql_test 2.3 { |
| 49 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1'; |
| 50 | } {text text} |
| 51 | do_execsql_test 2.4 { |
| 52 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1'; |
| 53 | } {text text} |
| 54 | |
| 55 | |
| 56 | do_execsql_test 3.0 { |
| 57 | UPDATE t SET x='1.0'; |
| 58 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1'; |
| 59 | } {text text} |
| 60 | do_execsql_test 3.1 { |
| 61 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1'; |
| 62 | } {text text} |
| 63 | do_execsql_test 3.2 { |
| 64 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1'; |
| 65 | } {text text} |
| 66 | do_execsql_test 3.3 { |
| 67 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1'; |
| 68 | } {text text} |
| 69 | do_execsql_test 3.4 { |
| 70 | SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1'; |
| 71 | } {text text} |
| 72 | |
| 73 | do_execsql_test 4.0 { |
| 74 | SELECT 1+1.; |
| 75 | } {2.0} |
| 76 | do_execsql_test 4.1 { |
| 77 | SELECT '1.23e64'/'1.0000e+62'; |
| 78 | } {123.0} |
| 79 | do_execsql_test 4.2 { |
| 80 | SELECT '100x'+'-2y'; |
| 81 | } {98} |
| 82 | do_execsql_test 4.3 { |
| 83 | SELECT '100x'+'4.5y'; |
| 84 | } {104.5} |
| 85 | do_execsql_test 4.4 { |
| 86 | SELECT '-9223372036854775807x'-'1x'; |
| 87 | } {-9223372036854775808} |
| 88 | do_execsql_test 4.5 { |
| 89 | SELECT '9223372036854775806x'+'1x'; |
| 90 | } {9223372036854775807} |
| 91 | do_execsql_test 4.6 { |
| 92 | SELECT '1234x'/'10y', '1234x'/'10.y', '1234x'/'1e1y'; |
| 93 | } {123 123.4 123.4} |
| 94 | |
| 95 | finish_test |