Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add proper test case for [201128cc88] that covers most branches of the modified method. Also, tweak common test infrastructure. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a290d2c1a52949b12cd2cdfbe916c9b9 |
User & Date: | mistachkin 2011-07-07 04:18:55.806 |
References
2011-07-07
| ||
04:30 | • Ticket [201128cc88] SQLite3.GetParamValueBytes optimization status still Closed with 2 other changes artifact: b6073f8c6c user: mistachkin | |
04:19 | • Ticket [201128cc88]: 1 change artifact: cec4f7a5fb user: mistachkin | |
Context
2011-07-07
| ||
05:12 | To avoid future confusion, the fix for [8c1650482e] should match the fix for [201128cc88]. check-in: f1f7b20cea user: mistachkin tags: trunk | |
04:18 | Add proper test case for [201128cc88] that covers most branches of the modified method. Also, tweak common test infrastructure. check-in: a290d2c1a5 user: mistachkin tags: trunk | |
02:40 | Further optimization/fix for ticket [201128cc88]. check-in: f09f0e8ea1 user: mistachkin tags: trunk | |
Changes
Changes to Tests/common.eagle.
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # NOTE: Return the full path of the loaded file. # return $fileName } return "" } proc setupDb {fileName {mode ""} {delete ""} {extra ""} {varName db}} { set fileName [file join [getTemporaryPath] $fileName] if {[string length $delete] == 0 || $delete} then { catch {file delete $fileName} } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | # NOTE: Return the full path of the loaded file. # return $fileName } return "" } proc compileCSharpWith { text resultsVarName errorsVarName fileNames args } { # # NOTE: Create the base command to evaluate and add the property settings # that are almost always needed by our unit tests (i.e. the System # and System.Data assembly references). # set command [list compileCSharp $text results errors \ ReferencedAssemblies.Add System.dll ReferencedAssemblies.Add \ System.Data.dll] # # NOTE: Add all the provided file names as assembly references. # foreach fileName $fileNames { lappend command ReferencedAssemblies.Add [getAssemblyFileName $fileName] } # # NOTE: Add the extra arguments, if any, to the command to evaluate. # eval lappend command $args # # NOTE: Alias the compiler local results and errors variables to the # variable names provided by our caller. # upvar 1 $resultsVarName results upvar 1 $errorsVarName errors # # NOTE: Evaluate the constructed [compileCSharp] command and return the # result. # eval $command } proc setupDb {fileName {mode ""} {delete ""} {extra ""} {varName db}} { set fileName [file join [getTemporaryPath] $fileName] if {[string length $delete] == 0 || $delete} then { catch {file delete $fileName} } |
︙ | ︙ |
Added Tests/tkt-201128cc88.eagle.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ############################################################################### # # tkt-201128cc88.eagle -- # # Written by Joe Mistachkin. # Released to the public domain, use at your own risk! # ############################################################################### package require EagleLibrary package require EagleTest runTestPrologue ############################################################################### source [file join $path common.eagle] loadAssembly System.Data.SQLite.dll ############################################################################### runTest {test tkt-201128cc88-1.1 {custom function with byte[] arg} -setup { copyAssembly SQLite.Interop.dll copyAssembly System.Data.SQLite.dll set fileName tkt-201128cc88-1.1.db } -body { set id [object invoke Interpreter.GetActive NextId] unset -nocomplain results errors set code [compileCSharpWith [subst { using System; using System.Data.SQLite; namespace _Dynamic${id} { \[SQLiteFunction(Name = "Base64", FuncType = FunctionType.Scalar)\] public class Test${id} : SQLiteFunction { public override object Invoke(object\[\] args) { if (args == null) return null; if (args.Length != 1) return new ArgumentException(String.Format( "need exactly one argument, got {0}", args.Length)); object arg = args\[0\]; if (arg == null) return String.Empty; Type type = arg.GetType(); if (type == typeof(DBNull)) return String.Empty; if (type != typeof(byte\[\])) return new ArgumentException(String.Format( "argument must be byte array, got {0}", type)); return Convert.ToBase64String((byte\[\]) arg); } public static void Main() { SQLiteFunction.RegisterFunction(typeof(Test${id})); } } } }] results errors System.Data.SQLite.dll] # # NOTE: Compile the C# code (above) to register the custom SQLite function # and then open the database for this test case and attempt to execute # the function. Normally, we would open the database in the test setup # phase; however, that will not work correctly because newly registered # functions are only picked up and used by databases opened after they # have been registered. # list $code $results \ [expr {[info exists errors] ? $errors : ""}] \ [expr {$code eq "Ok" ? [catch { object invoke _Dynamic${id}.Test${id} Main } result] : [set result ""]}] $result [setupDb $fileName] \ [sql execute -execute scalar $db "SELECT Base64(CAST(NULL AS BLOB));"] \ [sql execute -execute scalar $db "SELECT Base64(CAST('' AS BLOB));"] \ [sql execute -execute scalar $db "SELECT Base64(CAST('foo' AS BLOB));"] } -cleanup { cleanupDb $fileName unset -nocomplain result code results errors id db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA System.Data.SQLite} -match regexp \ -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}\ SQLiteConnection#\d+ \{\} \{\} Zm9v$}} ############################################################################### runTestEpilogue |
Changes to Tests/tkt-e1b2e0f769.eagle.
︙ | ︙ | |||
15 16 17 18 19 20 21 | ############################################################################### source [file join $path common.eagle] loadAssembly System.Data.SQLite.dll ############################################################################### | | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ############################################################################### source [file join $path common.eagle] loadAssembly System.Data.SQLite.dll ############################################################################### runTest {test tkt-e1b2e0f769-1.1 {data reader cleanup} -setup { copyAssembly SQLite.Interop.dll copyAssembly System.Data.SQLite.dll setupDb [set fileName tkt-e1b2e0f769-1.1.db] } -body { sql execute $db "CREATE TABLE t1(x INTEGER);" sql execute $db "CREATE TABLE t2(x INTEGER);" foreach x [list 1 2 3] { sql execute $db "INSERT INTO t1 (x) VALUES($x);" } set result1 [list] set dataSource [file join [getTemporaryPath] tkt-e1b2e0f769-1.1.db] foreach table [list t1 t2] { set id [object invoke Interpreter.GetActive NextId] set sql "SELECT x FROM $table ORDER BY x;" unset -nocomplain results errors set code [compileCSharpWith [subst { using System.Collections.Generic; using System.Data.SQLite; namespace _Dynamic${id} { public class Test${id} { |
︙ | ︙ | |||
100 101 102 103 104 105 106 | connection.Open(); return Tkt_e1b2e0f769(connection).Count; } } } } | < < | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | connection.Open(); return Tkt_e1b2e0f769(connection).Count; } } } } }] results errors System.Data.SQLite.dll] lappend result1 $code $results \ [expr {[info exists errors] ? $errors : ""}] \ [expr {$code eq "Ok" ? [catch { object invoke _Dynamic${id}.Test${id} Main } result2] : [set result2 ""]}] $result2 } |
︙ | ︙ |