Bug 1230685 - Replace function declarations with add_task statements in test_storage_value_array.js and test_unicode.js. r=mak

--HG--
extra : commitid : GaYkxxYU4Yj
This commit is contained in:
Jeffrey Tran 2016-02-10 15:30:34 +01:00
Родитель 1a2bff1271
Коммит f139fb05d8
2 изменённых файлов: 48 добавлений и 98 удалений

Просмотреть файл

@ -4,8 +4,7 @@
// This file tests the functions of mozIStorageValueArray
function setup()
{
add_task(function* setup() {
getOpenedDatabase().createTable("test", "id INTEGER PRIMARY KEY, name TEXT," +
"number REAL, nuller NULL, blobber BLOB");
@ -23,10 +22,11 @@ function setup()
stmt.reset();
stmt.finalize();
}
function test_getIsNull_for_null()
{
do_register_cleanup(cleanup);
});
add_task(function* test_getIsNull_for_null() {
var stmt = createStatement("SELECT nuller, blobber FROM test WHERE id = ?1");
stmt.bindByIndex(0, 1);
do_check_true(stmt.executeStep());
@ -35,10 +35,9 @@ function test_getIsNull_for_null()
do_check_true(stmt.getIsNull(1)); // data is null if size is 0
stmt.reset();
stmt.finalize();
}
});
function test_getIsNull_for_non_null()
{
add_task(function* test_getIsNull_for_non_null() {
var stmt = createStatement("SELECT name, blobber FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -47,10 +46,9 @@ function test_getIsNull_for_non_null()
do_check_false(stmt.getIsNull(1));
stmt.reset();
stmt.finalize();
}
});
function test_value_type_null()
{
add_task(function* test_value_type_null() {
var stmt = createStatement("SELECT nuller FROM test WHERE id = ?1");
stmt.bindByIndex(0, 1);
do_check_true(stmt.executeStep());
@ -59,10 +57,9 @@ function test_value_type_null()
stmt.getTypeOfIndex(0));
stmt.reset();
stmt.finalize();
}
});
function test_value_type_integer()
{
add_task(function* test_value_type_integer() {
var stmt = createStatement("SELECT id FROM test WHERE id = ?1");
stmt.bindByIndex(0, 1);
do_check_true(stmt.executeStep());
@ -71,10 +68,9 @@ function test_value_type_integer()
stmt.getTypeOfIndex(0));
stmt.reset();
stmt.finalize();
}
});
function test_value_type_float()
{
add_task(function* test_value_type_float() {
var stmt = createStatement("SELECT number FROM test WHERE id = ?1");
stmt.bindByIndex(0, 1);
do_check_true(stmt.executeStep());
@ -83,10 +79,9 @@ function test_value_type_float()
stmt.getTypeOfIndex(0));
stmt.reset();
stmt.finalize();
}
});
function test_value_type_text()
{
add_task(function* test_value_type_text() {
var stmt = createStatement("SELECT name FROM test WHERE id = ?1");
stmt.bindByIndex(0, 1);
do_check_true(stmt.executeStep());
@ -95,10 +90,9 @@ function test_value_type_text()
stmt.getTypeOfIndex(0));
stmt.reset();
stmt.finalize();
}
});
function test_value_type_blob()
{
add_task(function* test_value_type_blob() {
var stmt = createStatement("SELECT blobber FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -107,10 +101,9 @@ function test_value_type_blob()
stmt.getTypeOfIndex(0));
stmt.reset();
stmt.finalize();
}
});
function test_numEntries_one()
{
add_task(function* test_numEntries_one() {
var stmt = createStatement("SELECT blobber FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -118,10 +111,9 @@ function test_numEntries_one()
do_check_eq(1, stmt.numEntries);
stmt.reset();
stmt.finalize();
}
});
function test_numEntries_all()
{
add_task(function* test_numEntries_all() {
var stmt = createStatement("SELECT * FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -129,10 +121,9 @@ function test_numEntries_all()
do_check_eq(5, stmt.numEntries);
stmt.reset();
stmt.finalize();
}
});
function test_getInt()
{
add_task(function* test_getInt() {
var stmt = createStatement("SELECT id FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -141,10 +132,9 @@ function test_getInt()
do_check_eq(2, stmt.getInt64(0));
stmt.reset();
stmt.finalize();
}
});
function test_getDouble()
{
add_task(function* test_getDouble() {
var stmt = createStatement("SELECT number FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -152,10 +142,9 @@ function test_getDouble()
do_check_eq(1.23, stmt.getDouble(0));
stmt.reset();
stmt.finalize();
}
});
function test_getUTF8String()
{
add_task(function* test_getUTF8String() {
var stmt = createStatement("SELECT name FROM test WHERE id = ?1");
stmt.bindByIndex(0, 1);
do_check_true(stmt.executeStep());
@ -163,10 +152,9 @@ function test_getUTF8String()
do_check_eq("foo", stmt.getUTF8String(0));
stmt.reset();
stmt.finalize();
}
});
function test_getString()
{
add_task(function* test_getString() {
var stmt = createStatement("SELECT name FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -174,10 +162,9 @@ function test_getString()
do_check_eq("", stmt.getString(0));
stmt.reset();
stmt.finalize();
}
});
function test_getBlob()
{
add_task(function* test_getBlob() {
var stmt = createStatement("SELECT blobber FROM test WHERE id = ?1");
stmt.bindByIndex(0, 2);
do_check_true(stmt.executeStep());
@ -190,22 +177,6 @@ function test_getBlob()
do_check_eq(2, arr.value[1]);
stmt.reset();
stmt.finalize();
}
});
var tests = [test_getIsNull_for_null, test_getIsNull_for_non_null,
test_value_type_null, test_value_type_integer,
test_value_type_float, test_value_type_text, test_value_type_blob,
test_numEntries_one, test_numEntries_all, test_getInt,
test_getDouble, test_getUTF8String, test_getString, test_getBlob];
function run_test()
{
setup();
for (var i = 0; i < tests.length; i++) {
tests[i]();
}
cleanup();
}

Просмотреть файл

@ -7,8 +7,7 @@
const LATIN1_AE = "\xc6"; // "Æ"
const LATIN1_ae = "\xe6"; // "æ"
function setup()
{
add_task(function* setup() {
getOpenedDatabase().createTable("test", "id INTEGER PRIMARY KEY, name TEXT");
var stmt = createStatement("INSERT INTO test (name, id) VALUES (?1, ?2)");
@ -25,20 +24,20 @@ function setup()
stmt.bindByIndex(1, 4);
stmt.execute();
stmt.finalize();
}
function test_upper_ascii()
{
do_register_cleanup(cleanup);
});
add_task(function* test_upper_ascii() {
var stmt = createStatement("SELECT name, id FROM test WHERE name = upper('a')");
do_check_true(stmt.executeStep());
do_check_eq("A", stmt.getString(0));
do_check_eq(2, stmt.getInt32(1));
stmt.reset();
stmt.finalize();
}
});
function test_upper_non_ascii()
{
add_task(function* test_upper_non_ascii() {
var stmt = createStatement("SELECT name, id FROM test WHERE name = upper(?1)");
stmt.bindByIndex(0, LATIN1_ae);
do_check_true(stmt.executeStep());
@ -46,20 +45,18 @@ function test_upper_non_ascii()
do_check_eq(1, stmt.getInt32(1));
stmt.reset();
stmt.finalize();
}
});
function test_lower_ascii()
{
add_task(function* test_lower_ascii() {
var stmt = createStatement("SELECT name, id FROM test WHERE name = lower('B')");
do_check_true(stmt.executeStep());
do_check_eq("b", stmt.getString(0));
do_check_eq(3, stmt.getInt32(1));
stmt.reset();
stmt.finalize();
}
});
function test_lower_non_ascii()
{
add_task(function* test_lower_non_ascii() {
var stmt = createStatement("SELECT name, id FROM test WHERE name = lower(?1)");
stmt.bindByIndex(0, LATIN1_AE);
do_check_true(stmt.executeStep());
@ -67,38 +64,20 @@ function test_lower_non_ascii()
do_check_eq(4, stmt.getInt32(1));
stmt.reset();
stmt.finalize();
}
});
function test_like_search_different()
{
add_task(function* test_like_search_different() {
var stmt = createStatement("SELECT COUNT(*) FROM test WHERE name LIKE ?1");
stmt.bindByIndex(0, LATIN1_AE);
do_check_true(stmt.executeStep());
do_check_eq(2, stmt.getInt32(0));
stmt.finalize();
}
});
function test_like_search_same()
{
add_task(function* test_like_search_same() {
var stmt = createStatement("SELECT COUNT(*) FROM test WHERE name LIKE ?1");
stmt.bindByIndex(0, LATIN1_ae);
do_check_true(stmt.executeStep());
do_check_eq(2, stmt.getInt32(0));
stmt.finalize();
}
var tests = [test_upper_ascii, test_upper_non_ascii, test_lower_ascii,
test_lower_non_ascii, test_like_search_different,
test_like_search_same];
function run_test()
{
setup();
for (var i = 0; i < tests.length; i++) {
tests[i]();
}
cleanup();
}
});