tests/test_quick.ps1
|
# Quick test to verify pre-compiled DLLs are loaded Import-Module PaperinikDB -Force Write-Host "Creating connection..." $conn = New-DuckDBConnection Write-Host "Creating scalar function..." $conn.CreateFunction('double_it', { param([int]$x) $x * 2 }, @([int]), [int]) Write-Host "Testing scalar function..." $result = $conn.sql("SELECT double_it(21) as value") Write-Host "double_it(21) = $($result.value)" Write-Host "Creating table function..." $conn.CreateTableFunction( 'generate_numbers', { param([int]$count) 1..$count | ForEach-Object { @{ n = $_; doubled = $_ * 2 } } }, @{ n = [int]; doubled = [int] }, @([int]) ) Write-Host "Testing table function..." $result = $conn.sql("SELECT * FROM generate_numbers(3)") $result | Format-Table Write-Host "Creating table function..." $conn.CreateTableFunction( 'generate_powers', { param([int]$count) 1..$count | ForEach-Object { @{ n = $_; pow2 = [math]::Pow(2, $_) } } }, @{ n = [int]; pow2 = [int] }, @([int]) ) Write-Host "Testing table function..." $result = $conn.sql("SELECT * FROM generate_powers(4)") $result | Format-Table $conn.Close() Write-Host "All tests passed!" |