Skip to content

Commit 0ccc5e7

Browse files
committed
Skip tests for undefined methods
1 parent 24b6b89 commit 0ccc5e7

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

test/test_statement.rb

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -293,24 +293,23 @@ def test_fullscan_steps
293293
@db.execute 'INSERT INTO test_table (name) VALUES (?)', "name_#{i}"
294294
end
295295
@db.execute 'DROP INDEX IF EXISTS idx_test_table_id;'
296-
297296
stmt = @db.prepare("SELECT * FROM test_table WHERE name LIKE 'name%'")
298297
stmt.execute.to_a
298+
299299
assert_equal 9, stmt.fullscan_steps
300-
ensure
301-
stmt.close if stmt
300+
301+
stmt.close
302302
end
303303

304304
def test_sorts
305305
@db.execute 'CREATE TABLE test1(a)'
306306
@db.execute 'INSERT INTO test1 VALUES (1)'
307-
308307
stmt = @db.prepare('select * from test1 order by a')
309308
stmt.execute.to_a
310309

311310
assert_equal 1, stmt.sorts
312-
ensure
313-
stmt.close if stmt
311+
312+
stmt.close
314313
end
315314

316315
def test_autoindexes
@@ -320,93 +319,103 @@ def test_autoindexes
320319
@db.execute 'INSERT INTO t1 (a, b) VALUES (?, ?)', [i, i.to_s]
321320
@db.execute 'INSERT INTO t2 (c, d) VALUES (?, ?)', [i, i.to_s]
322321
end
323-
324322
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c;")
325323
stmt.execute.to_a
324+
326325
assert_equal 9, stmt.autoindexes
327-
ensure
328-
stmt.close if stmt
326+
327+
stmt.close
329328
end
330329

331330
def test_vm_steps
332331
@db.execute 'CREATE TABLE test1(a)'
333332
@db.execute 'INSERT INTO test1 VALUES (1)'
334-
335333
stmt = @db.prepare('select * from test1 order by a')
336334
stmt.execute.to_a
337335

338336
assert_equal 17, stmt.vm_steps
339-
ensure
340-
stmt.close if stmt
337+
338+
stmt.close
341339
end
342340

343341
def test_reprepares
342+
stmt = @db.prepare("SELECT * FROM test_table WHERE name LIKE ?")
343+
344+
skip("reprepares not defined") unless stmt.respond_to?(:reprepares)
345+
344346
@db.execute 'CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT);'
345347
10.times do |i|
346348
@db.execute 'INSERT INTO test_table (name) VALUES (?)', "name_#{i}"
347349
end
348-
349-
stmt = @db.prepare("SELECT * FROM test_table WHERE name LIKE ?")
350350
stmt.execute('name%').to_a
351351

352352
assert_equal 1, stmt.reprepares
353-
ensure
354-
stmt.close if stmt
353+
354+
stmt.close
355355
end
356356

357357
def test_runs
358+
stmt = @db.prepare('select * from test1')
359+
360+
skip("runs not defined") unless stmt.respond_to?(:runs)
361+
358362
@db.execute 'CREATE TABLE test1(a)'
359363
@db.execute 'INSERT INTO test1 VALUES (1)'
360-
361-
stmt = @db.prepare('select * from test1')
362364
stmt.execute.to_a
363365

364366
assert_equal 1, stmt.runs
365-
ensure
366-
stmt.close if stmt
367+
368+
stmt.close
367369
end
368370

369371
def test_filter_misses
372+
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c;")
373+
374+
skip("filter_misses not defined") unless stmt.respond_to?(:filter_misses)
375+
370376
@db.execute "CREATE TABLE t1(a,b);"
371377
@db.execute "CREATE TABLE t2(c,d);"
372378
10.times do |i|
373379
@db.execute 'INSERT INTO t1 (a, b) VALUES (?, ?)', [i, i.to_s]
374380
@db.execute 'INSERT INTO t2 (c, d) VALUES (?, ?)', [i, i.to_s]
375381
end
376-
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c;")
377382
stmt.execute.to_a
378383

379384
assert_equal 10, stmt.filter_misses
380-
ensure
381-
stmt.close if stmt
385+
386+
stmt.close
382387
end
383388

384389
def test_filter_hits
390+
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c AND b = '1' AND d = '1';")
391+
392+
skip("filter_hits not defined") unless stmt.respond_to?(:filter_hits)
393+
385394
@db.execute "CREATE TABLE t1(a,b);"
386395
@db.execute "CREATE TABLE t2(c,d);"
387396
10.times do |i|
388397
@db.execute 'INSERT INTO t1 (a, b) VALUES (?, ?)', [i, i.to_s]
389398
@db.execute 'INSERT INTO t2 (c, d) VALUES (?, ?)', [i+1, i.to_s]
390399
end
391-
392-
stmt = @db.prepare("SELECT * FROM t1, t2 WHERE a=c AND b = '1' AND d = '1';")
393400
stmt.execute.to_a
394401

395402
assert_equal 1, stmt.filter_hits
396-
ensure
397-
stmt.close if stmt
403+
404+
stmt.close
398405
end
399406

400407
def test_memused
408+
stmt = @db.prepare('select * from test1')
409+
410+
skip("memused not defined") unless stmt.respond_to?(:memused)
411+
401412
@db.execute 'CREATE TABLE test1(a)'
402413
@db.execute 'INSERT INTO test1 VALUES (1)'
403-
404-
stmt = @db.prepare('select * from test1')
405414
stmt.execute.to_a
406415

407416
assert_operator stmt.memused, :>, 0
408-
ensure
409-
stmt.close if stmt
417+
418+
stmt.close
410419
end
411420
end
412421
end

0 commit comments

Comments
 (0)