[gjs: 5/12] tests: Add regression test for null returned GError
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 5/12] tests: Add regression test for null returned GError
- Date: Fri, 5 Mar 2021 05:05:09 +0000 (UTC)
commit 025636451169fbeaafc80d71e0c95b8222a11cfe
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Feb 14 13:43:12 2021 -0800
tests: Add regression test for null returned GError
In previous versions of GJS, returning (not throwing) a null GError from
an introspected function would cause GJS to try to free it. Even though
the bug has been fixed, add a regression test to make sure that it doesn't
occur again in the future.
See: #351
installed-tests/js/testExceptions.js | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/installed-tests/js/testExceptions.js b/installed-tests/js/testExceptions.js
index 0262e43c..662b5297 100644
--- a/installed-tests/js/testExceptions.js
+++ b/installed-tests/js/testExceptions.js
@@ -205,3 +205,17 @@ describe('thrown GError', function () {
expect(err.code).toEqual(Gio.IOErrorEnum.NOT_FOUND);
});
});
+
+describe('Returned GError', function () {
+ it('can be nullable', function () {
+ // expect a critical about passing in an invalid error domain, but this
+ // should not crash or log a critical about freeing a null GError
+ GLib.test_expect_message('GLib', GLib.LogLevelFlags.LEVEL_CRITICAL,
+ "g_error_new_literal: assertion 'domain != 0' failed");
+
+ expect(GLib.Error.new_literal(0, 0, 'message')).toBeNull();
+
+ GLib.test_assert_expected_messages_internal('GLib', 'testExceptions.js',
+ 0, 'testGErrorMessages');
+ });
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]