mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 20:47:44 +00:00
7e20285e70
The -*- file variable lines -*- establish per-file settings that Emacs will pick up. This patch makes the following changes to those lines (and touches nothing else): - Never set the buffer's mode. Years ago, Emacs did not have a good JavaScript mode, so it made sense to use Java or C++ mode in .js files. However, Emacs has had js-mode for years now; it's perfectly serviceable, and is available and enabled by default in all major Emacs packagings. Selecting a mode in the -*- file variable line -*- is almost always the wrong thing to do anyway. It overrides Emacs's default choice, which is (now) reasonable; and even worse, it overrides settings the user might have made in their '.emacs' file for that file extension. It's only useful when there's something specific about that particular file that makes a particular mode appropriate. - Correctly propagate settings that establish the correct indentation level for this file: c-basic-offset and js2-basic-offset should be js-indent-level. Whatever value they're given should be preserved; different parts of our tree use different indentation styles. - We don't use tabs in Mozilla JS code. Always set indent-tabs-mode: nil. Remove tab-width: settings, at least in files that don't contain tab characters. - Remove js2-mode settings that belong in the user's .emacs file, like js2-skip-preprocessor-directives.
125 lines
3.0 KiB
JavaScript
125 lines
3.0 KiB
JavaScript
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
/* vim: set sw=2 ts=2 sts=2 et : */
|
|
/**
|
|
* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
*/
|
|
|
|
/**
|
|
* This file tests that the JS language helpers in various ways.
|
|
*/
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//// Test Functions
|
|
|
|
function test_params_enumerate()
|
|
{
|
|
let stmt = createStatement(
|
|
"SELECT * FROM test WHERE id IN (:a, :b, :c)"
|
|
);
|
|
|
|
// Make sure they are right.
|
|
let expected = ["a", "b", "c"];
|
|
let index = 0;
|
|
for (let name in stmt.params)
|
|
do_check_eq(name, expected[index++]);
|
|
}
|
|
|
|
function test_params_prototype()
|
|
{
|
|
let stmt = createStatement(
|
|
"SELECT * FROM sqlite_master"
|
|
);
|
|
|
|
// Set a property on the prototype and make sure it exist (will not be a
|
|
// bindable parameter, however).
|
|
Object.getPrototypeOf(stmt.params).test = 2;
|
|
do_check_eq(stmt.params.test, 2);
|
|
stmt.finalize();
|
|
}
|
|
|
|
function test_row_prototype()
|
|
{
|
|
let stmt = createStatement(
|
|
"SELECT * FROM sqlite_master"
|
|
);
|
|
|
|
do_check_true(stmt.executeStep());
|
|
|
|
// Set a property on the prototype and make sure it exists (will not be in the
|
|
// results, however).
|
|
Object.getPrototypeOf(stmt.row).test = 2;
|
|
do_check_eq(stmt.row.test, 2);
|
|
|
|
// Clean up after ourselves.
|
|
delete Object.getPrototypeOf(stmt.row).test;
|
|
stmt.finalize();
|
|
}
|
|
|
|
function test_params_gets_sync()
|
|
{
|
|
// Added for bug 562866.
|
|
/*
|
|
let stmt = createStatement(
|
|
"SELECT * FROM test WHERE id IN (:a, :b, :c)"
|
|
);
|
|
|
|
// Make sure we do not assert in getting the value.
|
|
let originalCount = Object.getOwnPropertyNames(stmt.params).length;
|
|
let expected = ["a", "b", "c"];
|
|
for each (let name in expected) {
|
|
stmt.params[name];
|
|
}
|
|
|
|
// Now make sure we didn't magically get any additional properties.
|
|
let finalCount = Object.getOwnPropertyNames(stmt.params).length;
|
|
do_check_eq(originalCount + expected.length, finalCount);
|
|
*/
|
|
}
|
|
|
|
function test_params_gets_async()
|
|
{
|
|
// Added for bug 562866.
|
|
/*
|
|
let stmt = createAsyncStatement(
|
|
"SELECT * FROM test WHERE id IN (:a, :b, :c)"
|
|
);
|
|
|
|
// Make sure we do not assert in getting the value.
|
|
let originalCount = Object.getOwnPropertyNames(stmt.params).length;
|
|
let expected = ["a", "b", "c"];
|
|
for each (let name in expected) {
|
|
stmt.params[name];
|
|
}
|
|
|
|
// Now make sure we didn't magically get any additional properties.
|
|
let finalCount = Object.getOwnPropertyNames(stmt.params).length;
|
|
do_check_eq(originalCount + expected.length, finalCount);
|
|
*/
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//// Test Runner
|
|
|
|
let tests = [
|
|
test_params_enumerate,
|
|
test_params_prototype,
|
|
test_row_prototype,
|
|
test_params_gets_sync,
|
|
test_params_gets_async,
|
|
];
|
|
function run_test()
|
|
{
|
|
cleanup();
|
|
|
|
// Create our database.
|
|
getOpenedDatabase().executeSimpleSQL(
|
|
"CREATE TABLE test (" +
|
|
"id INTEGER PRIMARY KEY " +
|
|
")"
|
|
);
|
|
|
|
// Run the tests.
|
|
tests.forEach(function(test) test());
|
|
}
|