[gjs/wip/ptomato/mozjs31prep] test: Root misc functions in tests
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/ptomato/mozjs31prep] test: Root misc functions in tests
- Date: Fri, 4 Nov 2016 00:34:33 +0000 (UTC)
commit 5f1f755af161752aff7e4e4cb9cb30b9b7d35a3a
Author: Philip Chimento <philip endlessm com>
Date: Thu Nov 3 17:31:39 2016 -0700
test: Root misc functions in tests
This converts any code from the tests to use exact GC rooting that would
otherwise have caused a compile error in mozjs31.
https://bugzilla.gnome.org/show_bug.cgi?id=742249
test/gjs-test-call-args.cpp | 8 ++++++--
test/gjs-tests.cpp | 12 +++++-------
2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp
index 544c3bc..66326be 100644
--- a/test/gjs-test-call-args.cpp
+++ b/test/gjs-test-call-args.cpp
@@ -263,7 +263,9 @@ run_code(GjsUnitTestFixture *fx,
options.setFileAndLine("unit test", 1);
JS::RootedObject global(fx->cx, gjs_get_import_global(fx->cx));
- bool ok = JS::Evaluate(fx->cx, global, options, script, strlen(script), NULL);
+ JS::RootedValue ignored(fx->cx);
+ bool ok = JS::Evaluate(fx->cx, global, options, script, strlen(script),
+ ignored.address());
JS_ReportPendingException(fx->cx);
g_assert_null(fx->message);
@@ -280,7 +282,9 @@ run_code_expect_exception(GjsUnitTestFixture *fx,
options.setFileAndLine("unit test", 1);
JS::RootedObject global(fx->cx, gjs_get_import_global(fx->cx));
- bool ok = JS::Evaluate(fx->cx, global, options, script, strlen(script), NULL);
+ JS::RootedValue ignored(fx->cx);
+ bool ok = JS::Evaluate(fx->cx, global, options, script, strlen(script),
+ ignored.address());
g_assert_false(ok);
g_assert_true(JS_IsExceptionPending(fx->cx));
JS_ReportPendingException(fx->cx);
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index 712ba0d..17251b3 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -78,7 +78,7 @@ static void
gjstest_test_func_gjs_jsapi_util_error_throw(GjsUnitTestFixture *fx,
gconstpointer unused)
{
- JS::Value exc, value;
+ JS::RootedValue exc(fx->cx), value(fx->cx);
char *s = NULL;
/* Test that we can throw */
@@ -87,13 +87,11 @@ gjstest_test_func_gjs_jsapi_util_error_throw(GjsUnitTestFixture *fx,
g_assert(JS_IsExceptionPending(fx->cx));
- exc = JS::UndefinedValue();
- JS_GetPendingException(fx->cx, &exc);
+ JS_GetPendingException(fx->cx, exc.address());
g_assert(!exc.isUndefined());
- value = JS::UndefinedValue();
- JS_GetProperty(fx->cx, &exc.toObject(), "message",
- &value);
+ JS::RootedObject exc_obj(fx->cx, &exc.toObject());
+ JS_GetProperty(fx->cx, exc_obj, "message", value.address());
g_assert(value.isString());
@@ -119,7 +117,7 @@ gjstest_test_func_gjs_jsapi_util_error_throw(GjsUnitTestFixture *fx,
g_assert(JS_IsExceptionPending(fx->cx));
exc = JS::UndefinedValue();
- JS_GetPendingException(fx->cx, &exc);
+ JS_GetPendingException(fx->cx, exc.address());
g_assert(!exc.isUndefined());
g_assert(&exc.toObject() == &previous.toObject());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]