[gjs/april-maintenance: 3/11] jsapi-util-args: Use args.requireAtLeast()
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/april-maintenance: 3/11] jsapi-util-args: Use args.requireAtLeast()
- Date: Fri, 1 May 2020 04:47:37 +0000 (UTC)
commit a17c09cef4c37cf21286d04eafcb95cac871e40e
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Apr 5 22:53:46 2020 -0700
jsapi-util-args: Use args.requireAtLeast()
This method used to be broken in SpiderMonkey, but it's been fixed for a
long time now.
gjs/jsapi-util-args.h | 7 +++----
test/gjs-test-call-args.cpp | 7 ++++---
2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gjs/jsapi-util-args.h b/gjs/jsapi-util-args.h
index 33bcfef6..d04e346f 100644
--- a/gjs/jsapi-util-args.h
+++ b/gjs/jsapi-util-args.h
@@ -376,10 +376,9 @@ GJS_JSAPI_RETURN_CONVENTION static bool gjs_parse_call_args(
g_assert(((void) "Wrong number of parameters passed to gjs_parse_call_args()",
sizeof...(Args) / 2 == n_total));
- /* COMPAT: In future, use args.requireAtLeast()
- * https://bugzilla.mozilla.org/show_bug.cgi?id=1334338 */
- if (args.length() < n_required ||
- (args.length() > n_total && !ignore_trailing_args)) {
+ if (!args.requireAtLeast(cx, function_name, n_required))
+ return false;
+ if (!ignore_trailing_args && args.length() > n_total) {
if (n_required == n_total) {
gjs_throw(cx, "Error invoking %s: Expected %d arguments, got %d",
function_name, n_required, args.length());
diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp
index beb1716f..787d80ab 100644
--- a/test/gjs-test-call-args.cpp
+++ b/test/gjs-test-call-args.cpp
@@ -353,10 +353,11 @@ gjs_test_add_tests_for_parse_call_args(void)
"optionalIntArgsNoAssert(1, 2, 3)"
"//*Expected minimum 1 arguments (and 1 optional), got 3");
ADD_CALL_ARGS_TEST_XFAIL("too-few-args-fails",
- "intArgNoAssert()//*Expected 1 arguments, got 0");
+ "intArgNoAssert()//*requires at least 1 argument, "
+ "but only 0 were passed");
ADD_CALL_ARGS_TEST_XFAIL("too-few-args-fails-with-optional",
- "optionalIntArgsNoAssert()"
- "//*Expected minimum 1 arguments (and 1 optional), got 0");
+ "optionalIntArgsNoAssert()//*requires at least 1 "
+ "argument, but only 0 were passed");
ADD_CALL_ARGS_TEST("args-ignores-trailing", "argsIgnoreTrailing(1, 2, 3)");
ADD_CALL_ARGS_TEST("one-of-each-type-works",
"oneOfEachType(true, 'foo', 'foo', 1, 1, 1, 1, {})");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]