зеркало из https://github.com/mozilla/gecko-dev.git
Bug 599791 - part 7 - Tests. r=jorendorff
This commit is contained in:
Родитель
ad94db4487
Коммит
c676b3afdf
|
@ -2268,6 +2268,8 @@ function run_single_closure_tests(library, abi, suffix)
|
|||
|
||||
function closure_fn(i)
|
||||
{
|
||||
if (i == 42)
|
||||
throw "7.5 million years for that?";
|
||||
return "a" in this ? i + this.a : i + b;
|
||||
}
|
||||
|
||||
|
@ -2290,9 +2292,37 @@ function run_single_closure_tests(library, abi, suffix)
|
|||
do_check_eq(closure2(-17), -17 + thisobj.a);
|
||||
do_check_eq(test_closure(-52, closure2), -52 + thisobj.a);
|
||||
|
||||
// Specify an error sentinel, and have the JS code throw (see bug 599791).
|
||||
let closure3 = fn_t(closure_fn, null, 54);
|
||||
do_check_eq(closure3(42), 54);
|
||||
do_check_eq(test_closure(42, closure3), 54);
|
||||
|
||||
// Check what happens when the return type is bigger than a word.
|
||||
var fn_64_t = ctypes.FunctionType(ctypes.default_abi, ctypes.uint64_t, [ctypes.bool]).ptr;
|
||||
var bignum1 = ctypes.UInt64.join(0xDEADBEEF, 0xBADF00D);
|
||||
var bignum2 = ctypes.UInt64.join(0xDEFEC8ED, 0xD15EA5E);
|
||||
function closure_fn_64(fail)
|
||||
{
|
||||
if (fail)
|
||||
throw "Just following orders, sir!";
|
||||
return bignum1;
|
||||
};
|
||||
var closure64 = fn_64_t(closure_fn_64, null, bignum2);
|
||||
do_check_eq(ctypes.UInt64.compare(closure64(false), bignum1), 0);
|
||||
do_check_eq(ctypes.UInt64.compare(closure64(true), bignum2), 0);
|
||||
|
||||
// Test a callback that returns void (see bug 682504).
|
||||
var fn_v_t = ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, []).ptr;
|
||||
fn_v_t(function() {})(); // Don't crash
|
||||
|
||||
// Make sure that a void callback can't return an error sentinel.
|
||||
var sentinelThrew = false;
|
||||
try {
|
||||
fn_v_t(function() {}, null, -1);
|
||||
} catch(e) {
|
||||
sentinelThrew = true;
|
||||
}
|
||||
do_check_true(sentinelThrew);
|
||||
}
|
||||
|
||||
function run_variadic_tests(library) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче