limbo/testing/math.test
2025-01-20 00:21:23 +05:30

1341 lines
29 KiB
Tcl

#!/usr/bin/env tclsh
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Tolerance for floating point comparisons
# FIXME: When Limbo's floating point presentation matches to SQLite, this could/should be removed
set tolerance 1e-13
set overflow_tolerance 5e4
do_execsql_test add-int {
SELECT 10 + 1
} {11}
do_execsql_test add-float {
SELECT 10.1 + 0.3
} {10.4}
do_execsql_test add-int-float {
SELECT 10 + 0.1
} {10.1}
do_execsql_test add-agg-int-agg-int {
SELECT sum(1) + sum(2)
} {3}
do_execsql_test add-agg-int-agg-float {
SELECT sum(1) + sum(2.5)
} {3.5}
do_execsql_test add-agg-float-agg-int {
SELECT sum(1.5) + sum(2)
} {3.5}
foreach {testnum lhs rhs ans} {
1 'a' 'a' 0
2 'a' 10 10
3 10 'a' 10
4 'a' 11.0 11.0
5 11.0 'a' 11.0
7 '1' '2' 3
8 '1.0' '2' 3.0
9 '1.0' '3.0' 4.0
} {
do_execsql_test add-text-$testnum "SELECT $lhs + $rhs" $::ans
}
foreach {testnum lhs rhs ans} {
1 '9223372036854775807' '0' 9223372036854775807
2 '9223372036854775807' '1' 9.22337203685478e+18
3 9223372036854775807 0 9223372036854775807
4 9223372036854775807 1 9.22337203685478e+18
5 '-9223372036854775808' '0' -9223372036854775808
6 '-9223372036854775808' '-1' -9.22337203685478e+18
7 -9223372036854775808 0 -9223372036854775808
8 -9223372036854775808 -1 -9.22337203685478e+18
} {
do_execsql_test_tolerance add-overflow-$testnum "SELECT $lhs + $rhs" $::ans $overflow_tolerance
}
do_execsql_test subtract-int {
SELECT 10 - 1
} {9}
do_execsql_test subtract-float {
SELECT 10.2 - 0.1
} {10.1}
do_execsql_test subtract-int-float {
SELECT 10 - 0.1
} {9.9}
do_execsql_test subtract-agg-int-agg-int {
SELECT sum(3) - sum(1)
} {2}
do_execsql_test subtract-agg-int-agg-float {
SELECT sum(3) - sum(1.5)
} {1.5}
do_execsql_test subtract-agg-float-agg-int {
SELECT sum(3.5) - sum(1)
} {2.5}
foreach {testnum lhs rhs ans} {
1 'a' 'a' 0
2 'a' 10 -10
3 10 'a' 10
4 'a' 11.0 -11.0
5 11.0 'a' 11.0
7 '1' '2' -1
8 '1.0' '2' -1.0
9 '1.0' '3.0' -2.0
} {
do_execsql_test subtract-text-$testnum "SELECT $lhs - $rhs" $::ans
}
foreach {testnum lhs rhs ans} {
1 '9223372036854775807' '0' 9223372036854775807
2 '9223372036854775807' '-1' 9.22337203685478e+18
3 9223372036854775807 0 9223372036854775807
4 9223372036854775807 -1 9.22337203685478e+18
5 '-9223372036854775808' '0' -9223372036854775808
6 '-9223372036854775808' '1' -9.22337203685478e+18
7 -9223372036854775808 0 -9223372036854775808
8 -9223372036854775808 1 -9.22337203685478e+18
} {
do_execsql_test_tolerance subtract-overflow-$testnum "SELECT $lhs - $rhs" $::ans $overflow_tolerance
}
do_execsql_test multiply-int {
SELECT 10 * 2
} {20}
do_execsql_test multiply-float {
SELECT 10.2 * 2.2
} {22.44}
do_execsql_test multiply-int-float {
SELECT 10 * 1.45
} {14.5}
do_execsql_test multiply-float-int {
SELECT 1.45 * 10
} {14.5}
do_execsql_test multiply-agg-int-agg-int {
SELECT sum(2) * sum(3)
} {6}
do_execsql_test multiply-agg-int-agg-float {
SELECT sum(2) * sum(3.5)
} {7.0}
do_execsql_test multiply-agg-float-agg-int {
SELECT sum(2.5) * sum(3)
} {7.5}
foreach {testnum lhs rhs ans} {
1 'a' 'a' 0
2 'a' 10 0
3 10 'a' 0
4 'a' 11.0 0.0
5 11.0 'a' 0.0
7 '1' '2' 2
8 '1.0' '2' 2.0
9 '1.0' '3.0' 3.0
} {
do_execsql_test multiply-text-$testnum "SELECT $lhs * $rhs" $::ans
}
foreach {testnum lhs rhs ans} {
1 '9223372036854775807' '1' 9223372036854775807
2 '9223372036854775807' '2' 1.84467440737096e+19
3 9223372036854775807 1 9223372036854775807
4 9223372036854775807 2 1.84467440737096e+19
5 '-9223372036854775808' '1' -9223372036854775808
6 '-9223372036854775808' '2' -1.84467440737096e+19
7 -9223372036854775808 1 -9223372036854775808
8 -9223372036854775808 2 -1.84467440737096e+19
} {
do_execsql_test_tolerance multiply-overflow-$testnum "SELECT $lhs * $rhs" $::ans $overflow_tolerance
}
do_execsql_test divide-int {
SELECT 10 / 2
} {5}
do_execsql_test divide-int-no-fraction {
SELECT 10 / 3
} {3}
do_execsql_test divide-float {
SELECT 10.6 / 2.5
} {4.24}
do_execsql_test divide-int-float {
SELECT 10 / 4.0
} {2.5}
do_execsql_test divide-float-int {
SELECT 10.0 / 4
} {2.5}
do_execsql_test divide-by-zero {
SELECT 10 / 0
} {}
do_execsql_test divide-int-null {
SELECT 10 / null
} {}
do_execsql_test divide-null-int {
SELECT null / 10
} {}
do_execsql_test divide-null {
SELECT null / null
} {}
do_execsql_test divide-agg-int-agg-int {
SELECT sum(4) / sum(2)
} {2}
do_execsql_test divide-agg-int-agg-float {
SELECT sum(4) / sum(2.0)
} {2.0}
do_execsql_test divide-agg-float-agg-int {
SELECT sum(4.0) / sum(2)
} {2.0}
foreach {testnum lhs rhs ans} {
1 'a' 'a' {}
2 'a' 10 0
3 10 'a' {}
4 'a' 11.0 0.0
5 11.0 'a' {}
7 '1' '2' 0
8 '1.0' '2' 0.5
9 '1.0' '4.0' 0.25
} {
do_execsql_test divide-text-$testnum "SELECT $lhs / $rhs" $::ans
}
foreach {testnum lhs rhs ans} {
5 '-9223372036854775808' '0' {}
6 '-9223372036854775808' '-1' 9.22337203685478e+18
7 -9223372036854775808 0 {}
8 -9223372036854775808 -1 9.22337203685478e+18
} {
do_execsql_test_tolerance divide-overflow-$testnum "SELECT $lhs / $rhs" $::ans $overflow_tolerance
}
do_execsql_test add-agg-int {
SELECT sum(id) + 10 from products
} {76}
do_execsql_test add-int-agg {
SELECT 10 + sum(id) from products
} {76}
do_execsql_test add-agg-float {
SELECT sum(id) + 10.1 from products
} {76.1}
do_execsql_test add-float-agg {
SELECT 10.1 + sum(id) from products
} {76.1}
do_execsql_test add-agg-int-agg-int {
SELECT sum(id) + sum(id) from products
} {132}
do_execsql_test add-agg-float-agg-float {
SELECT sum(price) + sum(price) from products
} {1246.0}
do_execsql_test add-agg-int-agg-float {
SELECT sum(id) + sum(price) from products
} {689.0}
do_execsql_test add-agg-int-agg-float {
SELECT sum(id) + sum(price) from products
} {689.0}
do_execsql_test subtract-agg-int {
SELECT sum(id) - 10 from products
} {56}
do_execsql_test subtract-int-agg {
SELECT 10 - sum(id) from products
} {-56}
do_execsql_test subtract-agg-float {
SELECT sum(id) - 10.1 from products
} {55.9}
do_execsql_test subtract-float-agg {
SELECT 10.1 - sum(id) from products
} {-55.9}
do_execsql_test subtract-agg-int-agg-int {
SELECT sum(id) - sum(id) from products
} {0}
do_execsql_test subtract-agg-float-agg-float {
SELECT sum(price) - sum(price) from products
} {0.0}
do_execsql_test subtract-agg-int-agg-float {
SELECT sum(id) - sum(price) from products
} {-557.0}
do_execsql_test subtract-agg-float-agg-int {
SELECT sum(price) - sum(id) from products
} {557.0}
do_execsql_test multiply-agg-int {
SELECT sum(id) * 10 from products
} {660}
do_execsql_test multiply-int-agg {
SELECT 10 * sum(id) from products
} {660}
do_execsql_test multiply-agg-float {
SELECT sum(id) * 10.1 from products
} {666.6}
do_execsql_test multiply-float-agg {
SELECT 10.1 * sum(id) from products
} {666.6}
do_execsql_test multiply-agg-int-agg-int {
SELECT sum(id) * sum(id) from products
} {4356}
do_execsql_test multiply-agg-float-agg-float {
SELECT sum(price) * sum(price) from products
} {388129.0}
do_execsql_test multiply-agg-int-agg-float {
SELECT sum(id) * sum(price) from products
} {41118.0}
do_execsql_test multiply-agg-float-agg-int {
SELECT sum(price) * sum(id) from products
} {41118.0}
do_execsql_test divide-agg-int {
SELECT sum(id) / 10 from products
} {6}
do_execsql_test divide-int-agg {
SELECT 660 / sum(id) from products
} {10}
do_execsql_test divide-agg-float {
SELECT sum(id) / 1.5 from products
} {44.0}
do_execsql_test divide-float-agg {
SELECT 66.0 / sum(id) from products
} {1.0}
do_execsql_test divide-agg-int-agg-int {
SELECT sum(id) / sum(id) from products
} {1}
do_execsql_test divide-agg-float-agg-float {
SELECT sum(price) / sum(price) from products
} {1.0}
do_execsql_test divide-agg-int-agg-float {
SELECT sum(id) / min(price) from products
} {66.0}
do_execsql_test divide-agg-float-agg-int {
SELECT min(price) / min(id) from products
} {1.0}
do_execsql_test bitwise-and-int-null {
SELECT 1234 & NULL
} {}
do_execsql_test bitwise-and-int-int {
SELECT 1234 & 1234
} {1234}
do_execsql_test bitwise-and-int-float {
SELECT 660 & 261.8
} {4}
do_execsql_test bitwise-and-float-float {
SELECT 660.63 & 261.8
} {4}
do_execsql_test bitwise-and-float-int-rev {
SELECT 261.8 & 660
} {4}
do_execsql_test bitwise-and-int-agg-int {
SELECT 8261 & sum(id) from products
} {64}
do_execsql_test bitwise-and-int-agg-float {
SELECT 1036.6 & sum(id) from products
} {0}
do_execsql_test bitwise-and-int-agg-int-agg {
SELECT sum(id) & sum(id) from products
} {66}
foreach {testnum lhs rhs ans} {
1 'a' 'a' 0
2 'a' 10 0
3 10 'a' 0
4 'a' 11.0 0
5 11.0 'a' 0
7 '1' '2' 0
8 '1.0' '2' 0
9 '1.0' '4.0' 0
10 '1.0' '1.0' 1
11 '1' '1' 1
} {
do_execsql_test bitwise-and-text-$testnum "SELECT $lhs & $rhs" $::ans
}
do_execsql_test bitwise-or-int-null {
SELECT 1234 | NULL
} {}
do_execsql_test bitwise-or-null-int {
SELECT NULL | 1234
} {}
do_execsql_test bitwise-or-int-int {
SELECT 4321 | 1234
} {5363}
do_execsql_test bitwise-or-int-float {
SELECT 660 | 1234.0
} {1750}
do_execsql_test bitwise-or-int-agg {
SELECT 18823 | sum(id) from products
} {18887}
do_execsql_test bitwise-or-float-float {
SELECT 1234.6 | 5432.2
} {5626}
foreach {testnum lhs rhs ans} {
1 'a' 'a' 0
2 'a' 10 10
3 10 'a' 10
4 'a' 11.0 11
5 11.0 'a' 11
7 '1' '2' 3
8 '1.0' '2' 3
9 '1.0' '4.0' 5
10 '1.0' '1.0' 1
11 '1' '1' 1
} {
do_execsql_test bitwise-or-text-$testnum "SELECT $lhs | $rhs" $::ans
}
do_execsql_test bitwise-and-int-agg-int-agg {
SELECT sum(id) | sum(id) from products
} {66}
foreach {testname lhs rhs ans} {
int-int 1 2 4
int-neg_int 8 -2 2
int-float 1 4.0 16
int-text 1 'a' 1
int-text_float 1 '3.0' 8
int-text_int 1 '1' 2
int-null 1 NULL {}
int-int-overflow 1 64 0
int-int-underflow 1 -64 0
int-float-overflow 1 64.0 0
int-float-underflow 1 -64.0 0
} {
do_execsql_test shift-left-$testname "SELECT $lhs << $rhs" $::ans
}
foreach {testname lhs rhs ans} {
float-int 1.0 2 4
float-neg_int 8.0 -2 2
float-float 1.0 4.0 16
float-text 1.0 'a' 1
float-text_float 1.0 '3.0' 8
float-text_int 1.0 '1' 2
float-null 1.0 NULL {}
float-int-overflow 1.0 64 0
float-int-underflow 1.0 -64 0
float-float-overflow 1.0 64.0 0
float-float-underflow 1.0 -64.0 0
} {
do_execsql_test shift-left-$testname "SELECT $lhs << $rhs" $::ans
}
foreach {testname lhs rhs ans} {
text-int 'a' 2 0
text-float 'a' 4.0 0
text-text 'a' 'a' 0
text_int-text_int '1' '1' 2
text_int-text_float '1' '3.0' 8
text_int-text '1' 'a' 1
text_float-text_int '1.0' '1' 2
text_float-text_float '1.0' '3.0' 8
text_float-text '1.0' 'a' 1
text-null '1' NULL {}
} {
do_execsql_test shift-left-$testname "SELECT $lhs << $rhs" $::ans
}
foreach {testname lhs rhs ans} {
null-int NULL 2 {}
null-float NULL 4.0 {}
null-text NULL 'a' {}
null-null NULL NULL {}
} {
do_execsql_test shift-left-$testname "SELECT $lhs << $rhs" $::ans
}
foreach {testname lhs rhs ans} {
int-int 8 2 2
int-neg_int 8 -2 32
int-float 8 1.0 4
int-text 8 'a' 8
int-text_float 8 '3.0' 1
int-text_int 8 '1' 4
int-null 8 NULL {}
int-int-overflow 8 64 0
int-int-underflow 8 -64 0
int-float-overflow 8 64.0 0
int-float-underflow 8 -64.0 0
} {
do_execsql_test shift-right-$testname "SELECT $lhs >> $rhs" $::ans
}
foreach {testname lhs rhs ans} {
float-int 8.0 2 2
float-neg_int 8.0 -2 32
float-float 8.0 1.0 4
float-text 8.0 'a' 8
float-text_float 8.0 '3.0' 1
float-text_int 8.0 '1' 4
float-null 8.0 NULL {}
float-int-overflow 8.0 64 0
float-int-underflow 8.0 -64 0
float-float-overflow 8.0 64.0 0
float-float-underflow 8.0 -64.0 0
} {
do_execsql_test shift-right-$testname "SELECT $lhs >> $rhs" $::ans
}
foreach {testname lhs rhs ans} {
text-int 'a' 2 0
text-float 'a' 4.0 0
text-text 'a' 'a' 0
text_int-text_int '8' '1' 4
text_int-text_float '8' '3.0' 1
text_int-text '8' 'a' 8
text_float-text_int '8.0' '1' 4
text_float-text_float '8.0' '3.0' 1
text_float-text '8.0' 'a' 8
text-null '8' NULL {}
} {
do_execsql_test shift-right-$testname "SELECT $lhs >> $rhs" $::ans
}
foreach {testname lhs rhs ans} {
null-int NULL 2 {}
null-float NULL 4.0 {}
null-text NULL 'a' {}
null-null NULL NULL {}
} {
do_execsql_test shift-right-$testname "SELECT $lhs >> $rhs" $::ans
}
do_execsql_test bitwise-not-null {
SELECT ~NULL
} {}
do_execsql_test bitwise-not-int {
SELECT ~1234
} {-1235}
do_execsql_test bitwise-not-float {
SELECT ~823.34
} {-824}
do_execsql_test bitwise-not-text-float {
SELECT ~'823.34'
} {-824}
do_execsql_test bitwise-not-text-int {
SELECT ~'1234'
} {-1235}
do_execsql_test bitwise-not-scalar-float {
SELECT ~abs(693.9)
} {-694}
do_execsql_test bitwise-not-scalar-int {
SELECT ~abs(7566)
} {-7567}
do_execsql_test bitwise-not-agg-int {
SELECT ~sum(693)
} {-694}
do_execsql_test bitwise-not-agg-and-agg {
SELECT ~sum(693) & sum(-302)
} {-958}
do_execsql_test bitwise-not-agg-int {
SELECT ~sum(693)
} {-694}
do_execsql_test bitwise-not-zero {
SELECT ~0
} {-1}
foreach {testname lhs ans} {
int-1 1 0
int-2 2 0
int-3 0 1
float-1 1.0 0
float-2 2.0 0
float-3 0.0 1
text 'a' 1
text-int-1 '0' 1
text-int-2 '1' 0
text-float-1 '1.0' 0
text-float-2 '0.0' 1
null NULL {}
} {
do_execsql_test boolean-not "SELECT not $lhs" $::ans
}
do_execsql_test_tolerance pi {
SELECT pi()
} {3.14159265358979} $tolerance
do_execsql_test_tolerance acos-int {
SELECT acos(1)
} {0.0} $tolerance
do_execsql_test_tolerance acos-float {
SELECT acos(-0.5)
} {2.0943951023931957} $tolerance
do_execsql_test_tolerance acos-str {
SELECT acos('-0.5')
} {2.0943951023931957} $tolerance
do_execsql_test_tolerance acos-null {
SELECT acos(null)
} {} $tolerance
do_execsql_test_tolerance acosh-int {
SELECT acosh(1)
} {0.0} $tolerance
do_execsql_test_tolerance acosh-float {
SELECT acosh(1.5)
} {0.962423650119207} $tolerance
do_execsql_test_tolerance acosh-str {
SELECT acosh('1.5')
} {0.962423650119207} $tolerance
do_execsql_test_tolerance acosh-invalid {
SELECT acosh(0.99)
} {} $tolerance
do_execsql_test_tolerance acosh-null {
SELECT acosh(null)
} {} $tolerance
do_execsql_test_tolerance asin-int {
SELECT asin(1)
} {1.5707963267948966} $tolerance
do_execsql_test_tolerance asin-float {
SELECT asin(-0.5)
} {-0.5235987755982989} $tolerance
do_execsql_test_tolerance asin-str {
SELECT asin('-0.5')
} {-0.5235987755982989} $tolerance
do_execsql_test_tolerance asin-null {
SELECT asin(null)
} {} $tolerance
do_execsql_test_tolerance sin-int {
SELECT sin(1)
} {0.841470984807897} $tolerance
do_execsql_test_tolerance sin-float {
SELECT sin(-0.5)
} {-0.479425538604203} $tolerance
do_execsql_test_tolerance sin-str {
SELECT sin('-0.5')
} {-0.479425538604203} $tolerance
do_execsql_test_tolerance sin-null {
SELECT sin(null)
} {} $tolerance
do_execsql_test_tolerance sin-products-id {
SELECT sin(id) from products limit 5
} {0.8414709848078965
0.9092974268256817
0.1411200080598672
-0.7568024953079282
-0.9589242746631385} $tolerance
do_execsql_test_tolerance asinh-int {
SELECT asinh(1)
} {0.881373587019543} $tolerance
do_execsql_test_tolerance asinh-float {
SELECT asinh(-0.5)
} {-0.48121182505960347} $tolerance
do_execsql_test_tolerance asinh-str {
SELECT asinh('-0.5')
} {-0.48121182505960347} $tolerance
do_execsql_test_tolerance asinh-null {
SELECT asinh(null)
} {} $tolerance
do_execsql_test_tolerance atan-int {
SELECT atan(1)
} {0.7853981633974483} $tolerance
do_execsql_test_tolerance atan-float {
SELECT atan(-0.5)
} {-0.4636476090008061} $tolerance
do_execsql_test_tolerance atan-str {
SELECT atan('-0.5')
} {-0.4636476090008061} $tolerance
do_execsql_test_tolerance atan-null {
SELECT atan(null)
} {} $tolerance
do_execsql_test_tolerance tan-int {
SELECT tan(1)
} {1.5574077246549} $tolerance
do_execsql_test_tolerance tan-float {
SELECT tan(-0.5)
} {-0.54630248984379} $tolerance
do_execsql_test_tolerance tan-str {
SELECT tan('-0.5')
} {-0.54630248984379} $tolerance
do_execsql_test_tolerance tan-null {
SELECT tan(null)
} {} $tolerance
do_execsql_test_tolerance atanh-int {
SELECT atanh(0)
} {0.0} $tolerance
do_execsql_test_tolerance atanh-float {
SELECT atanh(-0.5)
} {-0.5493061443340548} $tolerance
do_execsql_test_tolerance atanh-str {
SELECT atanh('-0.5')
} {-0.5493061443340548} $tolerance
do_execsql_test_tolerance atanh-null {
SELECT atanh(null)
} {} $tolerance
do_execsql_test ceil-int {
SELECT ceil(1)
} {1}
do_execsql_test ceil-float {
SELECT ceil(-1.5)
} {-1.0}
do_execsql_test ceil-str {
SELECT ceil('1.5')
} {2.0}
do_execsql_test ceil-null {
SELECT ceil(null)
} {}
do_execsql_test ceiling-int {
SELECT ceiling(1)
} {1}
do_execsql_test ceiling-float {
SELECT ceiling(-1.5)
} {-1.0}
do_execsql_test ceiling-str {
SELECT ceiling('1.5')
} {2.0}
do_execsql_test ceiling-null {
SELECT ceiling(null)
} {}
do_execsql_test_tolerance cos-int {
SELECT cos(1)
} {0.54030230586814} $tolerance
do_execsql_test_tolerance cos-float {
SELECT cos(-0.5)
} {0.877582561890373} $tolerance
do_execsql_test_tolerance cos-str {
SELECT cos('-0.5')
} {0.877582561890373} $tolerance
do_execsql_test_tolerance cos-null {
SELECT cos(null)
} {} $tolerance
do_execsql_test_tolerance cosh-int {
SELECT cosh(1)
} {1.54308063481524} $tolerance
do_execsql_test_tolerance cosh-float {
SELECT cosh(-0.5)
} {1.12762596520638} $tolerance
do_execsql_test_tolerance cosh-str {
SELECT cosh('-0.5')
} {1.12762596520638} $tolerance
do_execsql_test_tolerance cosh-null {
SELECT cosh(null)
} {} $tolerance
do_execsql_test_tolerance degrees-int {
SELECT degrees(1)
} {57.2957795130823} $tolerance
do_execsql_test_tolerance degrees-float {
SELECT degrees(-0.5)
} {-28.6478897565412} $tolerance
do_execsql_test_tolerance degrees-str {
SELECT degrees('-0.5')
} {-28.6478897565412} $tolerance
do_execsql_test_tolerance degrees-null {
SELECT degrees(null)
} {} $tolerance
do_execsql_test_tolerance exp-int {
SELECT exp(1)
} {2.71828182845905} $tolerance
do_execsql_test_tolerance exp-float {
SELECT exp(-0.5)
} {0.606530659712633} $tolerance
do_execsql_test_tolerance exp-str {
SELECT exp('-0.5')
} {0.606530659712633} $tolerance
do_execsql_test_tolerance exp-null {
SELECT exp(null)
} {} $tolerance
do_execsql_test floor-int {
SELECT floor(1)
} {1}
do_execsql_test floor-float {
SELECT floor(-1.5)
} {-2.0}
do_execsql_test floor-str {
SELECT floor('1.5')
} {1.0}
do_execsql_test floor-null {
SELECT floor(null)
} {}
do_execsql_test_tolerance ln-int {
SELECT ln(1)
} {0.0} $tolerance
do_execsql_test_tolerance ln-float {
SELECT ln(0.5)
} {-0.693147180559945} $tolerance
do_execsql_test_tolerance ln-str {
SELECT ln('0.5')
} {-0.693147180559945} $tolerance
do_execsql_test_tolerance ln-negative {
SELECT ln(-0.5)
} {} $tolerance
do_execsql_test_tolerance ln-null {
SELECT ln(null)
} {} $tolerance
do_execsql_test_tolerance log10-int {
SELECT log10(1)
} {0.0} $tolerance
do_execsql_test_tolerance log10-float {
SELECT log10(0.5)
} {-0.301029995663981} $tolerance
do_execsql_test_tolerance log10-str {
SELECT log10('0.5')
} {-0.301029995663981} $tolerance
do_execsql_test_tolerance log10-negative {
SELECT log10(-0.5)
} {} $tolerance
do_execsql_test_tolerance log10-null {
SELECT log10(null)
} {} $tolerance
do_execsql_test_tolerance log2-int {
SELECT log2(1)
} {0.0} $tolerance
do_execsql_test_tolerance log2-float {
SELECT log2(0.5)
} {-1.0} $tolerance
do_execsql_test_tolerance log2-str {
SELECT log2('0.5')
} {-1.0} $tolerance
do_execsql_test_tolerance log2-negative {
SELECT log2(-0.5)
} {} $tolerance
do_execsql_test_tolerance log2-null {
SELECT log2(null)
} {} $tolerance
do_execsql_test_tolerance radians-int {
SELECT radians(1)
} {0.0174532925199433} $tolerance
do_execsql_test_tolerance radians-float {
SELECT radians(-0.5)
} {-0.00872664625997165} $tolerance
do_execsql_test_tolerance radians-str {
SELECT radians('-0.5')
} {-0.00872664625997165} $tolerance
do_execsql_test_tolerance radians-null {
SELECT radians(null)
} {} $tolerance
do_execsql_test_tolerance sinh-int {
SELECT sinh(1)
} {1.1752011936438} $tolerance
do_execsql_test_tolerance sinh-float {
SELECT sinh(-0.5)
} {-0.521095305493747} $tolerance
do_execsql_test_tolerance sinh-str {
SELECT sinh('-0.5')
} {-0.521095305493747} $tolerance
do_execsql_test_tolerance sinh-null {
SELECT sinh(null)
} {} $tolerance
do_execsql_test_tolerance sqrt-int {
SELECT sqrt(1)
} {1.0} $tolerance
do_execsql_test_tolerance sqrt-float {
SELECT sqrt(0.5)
} {0.707106781186548} $tolerance
do_execsql_test_tolerance sqrt-str {
SELECT sqrt('0.5')
} {0.707106781186548} $tolerance
do_execsql_test_tolerance sqrt-negative {
SELECT sqrt(-0.5)
} {} $tolerance
do_execsql_test_tolerance sqrt-null {
SELECT sqrt(null)
} {} $tolerance
do_execsql_test_tolerance tanh-int {
SELECT tanh(1)
} {0.761594155955765} $tolerance
do_execsql_test_tolerance tanh-float {
SELECT tanh(-0.5)
} {-0.46211715726001} $tolerance
do_execsql_test_tolerance tanh-str {
SELECT tanh('-0.5')
} {-0.46211715726001} $tolerance
do_execsql_test_tolerance tanh-null {
SELECT tanh(null)
} {} $tolerance
do_execsql_test trunc-int {
SELECT trunc(1)
} {1}
do_execsql_test trunc-float {
SELECT trunc(2.5)
} {2.0}
do_execsql_test trunc-float-negative {
SELECT trunc(-2.5)
} {-2.0}
do_execsql_test trunc-str {
SELECT trunc('2.5')
} {2.0}
do_execsql_test trunc-null {
SELECT trunc(null)
} {}
do_execsql_test_tolerance atan2-int-int {
SELECT atan2(5, -1)
} {1.76819188664478} $tolerance
do_execsql_test_tolerance atan2-int-float {
SELECT atan2(5, -1.5)
} {1.86225312127276} $tolerance
do_execsql_test_tolerance atan2-int-str {
SELECT atan2(5, '-1.5')
} {1.86225312127276} $tolerance
do_execsql_test_tolerance atan2-float-int {
SELECT atan2(5.5, 10)
} {0.502843210927861} $tolerance
do_execsql_test_tolerance atan2-float-float {
SELECT atan2(5.5, -1.5)
} {1.83704837594582} $tolerance
do_execsql_test_tolerance atan2-float-str {
SELECT atan2(5.5, '-1.5')
} {1.83704837594582} $tolerance
do_execsql_test_tolerance atan2-str-str {
SELECT atan2('5.5', '-1.5')
} {1.83704837594582} $tolerance
do_execsql_test atan2-null-int {
SELECT atan2(null, 5)
} {}
do_execsql_test atan2-int-null {
SELECT atan2(5, null)
} {}
do_execsql_test_tolerance mod-int-int {
SELECT mod(10, -3)
} {1.0} $tolerance
do_execsql_test_tolerance mod-int-float {
SELECT mod(5, -1.5)
} {0.5} $tolerance
do_execsql_test_tolerance mod-int-str {
SELECT mod(5, '-1.5')
} {0.5} $tolerance
do_execsql_test_tolerance mod-float-int {
SELECT mod(5.5, 2)
} {1.5} $tolerance
do_execsql_test_tolerance mod-float-float {
SELECT mod(5.5, -1.5)
} {1.0} $tolerance
do_execsql_test_tolerance mod-float-str {
SELECT mod(5.5, '-1.5')
} {1.0} $tolerance
do_execsql_test_tolerance mod-str-str {
SELECT mod('5.5', '-1.5')
} {1.0} $tolerance
do_execsql_test mod-null-int {
SELECT mod(null, 5)
} {}
do_execsql_test mod-int-null {
SELECT mod(5, null)
} {}
do_execsql_test mod-float-zero {
SELECT mod(1.5, 0)
} {}
do_execsql_test mod-products-id {
SELECT mod(products.id, 3) from products limit 5
} {1.0
2.0
0.0
1.0
2.0}
do_execsql_test mod-products-price-id {
SELECT mod(products.price, products.id) from products limit 5
} {0.0
0.0
0.0
1.0
4.0}
do_execsql_test_tolerance pow-int-int {
SELECT pow(5, -1)
} {0.2} $tolerance
do_execsql_test_tolerance pow-int-float {
SELECT pow(5, -1.5)
} {0.0894427190999916} $tolerance
do_execsql_test_tolerance pow-int-str {
SELECT pow(5, '-1.5')
} {0.0894427190999916} $tolerance
do_execsql_test_tolerance pow-float-int {
SELECT pow(5.5, 2)
} {30.25} $tolerance
do_execsql_test_tolerance pow-float-float {
SELECT pow(5.5, -1.5)
} {0.077527533220222} $tolerance
do_execsql_test_tolerance pow-float-str {
SELECT pow(5.5, '-1.5')
} {0.077527533220222} $tolerance
do_execsql_test_tolerance pow-str-str {
SELECT pow('5.5', '-1.5')
} {0.077527533220222} $tolerance
do_execsql_test pow-null-int {
SELECT pow(null, 5)
} {}
do_execsql_test pow-int-null {
SELECT pow(5, null)
} {}
do_execsql_test_tolerance power-int-int {
SELECT power(5, -1)
} {0.2} $tolerance
do_execsql_test_tolerance power-int-float {
SELECT power(5, -1.5)
} {0.0894427190999916} $tolerance
do_execsql_test_tolerance power-int-str {
SELECT power(5, '-1.5')
} {0.0894427190999916} $tolerance
do_execsql_test_tolerance power-float-int {
SELECT power(5.5, 2)
} {30.25} $tolerance
do_execsql_test_tolerance power-float-float {
SELECT power(5.5, -1.5)
} {0.077527533220222} $tolerance
do_execsql_test_tolerance power-float-str {
SELECT power(5.5, '-1.5')
} {0.077527533220222} $tolerance
do_execsql_test_tolerance power-str-str {
SELECT power('5.5', '-1.5')
} {0.077527533220222} $tolerance
do_execsql_test power-null-int {
SELECT power(null, 5)
} {}
do_execsql_test power-int-null {
SELECT power(5, null)
} {}
do_execsql_test_tolerance log-int {
SELECT log(1)
} {0.0} $tolerance
do_execsql_test_tolerance log-float {
SELECT log(1.5)
} {0.176091259055681} $tolerance
do_execsql_test_tolerance log-str {
SELECT log('1.5')
} {0.176091259055681} $tolerance
do_execsql_test log-negative {
SELECT log(-1.5)
} {}
do_execsql_test log-null {
SELECT log(null)
} {}
do_execsql_test_tolerance log-int-int {
SELECT log(5, 1)
} {0.0} $tolerance
do_execsql_test_tolerance log-int-float {
SELECT log(5, 1.5)
} {0.251929636412592} $tolerance
do_execsql_test_tolerance log-int-str {
SELECT log(5, '1.5')
} {0.251929636412592} $tolerance
do_execsql_test_tolerance log-float-int {
SELECT log(5.5, 10)
} {1.35068935021985} $tolerance
do_execsql_test_tolerance log-float-float {
SELECT log(5.5, 1.5)
} {0.237844588273313} $tolerance
do_execsql_test_tolerance log-float-str {
SELECT log(5.5, '1.5')
} {0.237844588273313} $tolerance
do_execsql_test_tolerance log-str-str {
SELECT log('5.5', '1.5')
} {0.237844588273313} $tolerance
do_execsql_test log-negative-negative {
SELECT log(-1.5, -1.5)
} {}
do_execsql_test log-float-negative {
SELECT log(1.5, -1.5)
} {}
do_execsql_test log-null-int {
SELECT log(null, 5)
} {}
do_execsql_test log-int-null {
SELECT log(5, null)
} {}
do_execsql_test mod-int-null {
SELECT 183 % null
} {}
do_execsql_test mod-int-0 {
SELECT 183 % 0
} {}
do_execsql_test mod-int-int {
SELECT 183 % 10
} { 3 }
do_execsql_test mod-int-float {
SELECT 38 % 10.35
} { 8.0 }
do_execsql_test mod-float-int {
SELECT 38.43 % 13
} { 12.0 }
do_execsql_test mod-0-float {
SELECT 0 % 12.0
} { 0.0 }
do_execsql_test mod-float-0 {
SELECT 23.14 % 0
} {}
do_execsql_test mod-float-float {
SELECT 23.14 % 12.0
} { 11.0 }
do_execsql_test mod-float-agg {
SELECT 23.14 % sum(id) from products
} { 23.0 }
do_execsql_test mod-int-agg {
SELECT 17 % sum(id) from users
} { 17 }
do_execsql_test mod-agg-int {
SELECT count(*) % 17 from users
} { 4 }
do_execsql_test mod-agg-float {
SELECT count(*) % 2.43 from users
} { 0.0 }