diff options
author | Simon McVittie <smcv@debian.org> | 2020-08-23 18:42:23 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2020-08-23 18:42:23 +0100 |
commit | b74fb008c7425898d21dff93c8e1a60f582099c3 (patch) | |
tree | 4a9ef1abc91b419c0f11861edb4257d92b453d1b | |
parent | 36554365611da91d338dbe26e034a0c302167e78 (diff) | |
download | gjs-wip/smcv/test-more-flags.tar.gz |
testGIMarshalling: Expand test coverage for flagswip/smcv/test-more-flags
This requires a GObject-Introspection release with
gobject-introspection!235 included.
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r-- | installed-tests/js/testGIMarshalling.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js index 6001e316..dc39df38 100644 --- a/installed-tests/js/testGIMarshalling.js +++ b/installed-tests/js/testGIMarshalling.js @@ -442,6 +442,14 @@ describe('C array with length', function () { ]); }); + describe('of flags', function () { + testInParameter('array_flags', [ + GIMarshallingTests.Flags.VALUE1, + GIMarshallingTests.Flags.VALUE2, + GIMarshallingTests.Flags.VALUE3, + ]); + }); + it('marshals an array with a 64-bit length parameter', function () { expect(() => GIMarshallingTests.array_in_guint64_len([-1, 0, 1, 2])).not.toThrow(); }); @@ -742,6 +750,11 @@ describe('GValue', function () { .not.toThrow(); }).pend("GJS doesn't support native enum types"); + xit('flags can be passed into a function and packed', function () { + expect(() => GIMarshallingTests.gvalue_in_flags(GIMarshallingTests.Flags.VALUE3)) + .not.toThrow(); + }).pend("we don't know to pack flags in a GValue as flags and not gint"); + it('marshals as an int64 out parameter', function () { expect(GIMarshallingTests.gvalue_int64_out()).toEqual(Limits.int64.max); }); @@ -1131,6 +1144,14 @@ let VFuncTester = GObject.registerClass(class VFuncTester extends GIMarshallingT return GIMarshallingTests.Enum.VALUE3; } + vfunc_vfunc_return_flags() { + return GIMarshallingTests.Flags.VALUE2; + } + + vfunc_vfunc_out_flags() { + return GIMarshallingTests.Flags.VALUE3; + } + vfunc_vfunc_return_object_transfer_none() { if (!this._returnObject) this._returnObject = new GIMarshallingTests.Object({int: 53}); @@ -1273,6 +1294,14 @@ describe('Virtual function', function () { expect(tester.vfunc_out_enum()).toEqual(GIMarshallingTests.Enum.VALUE3); }); + it('marshals a flags return value', function () { + expect(tester.vfunc_return_flags()).toEqual(GIMarshallingTests.Flags.VALUE2); + }); + + it('marshals a flags out parameter', function () { + expect(tester.vfunc_out_flags()).toEqual(GIMarshallingTests.Flags.VALUE3); + }); + // These tests check what the refcount is of the returned objects; see // comments in gimarshallingtests.c. // Objects that are exposed in JS always have at least one reference (the @@ -1330,6 +1359,12 @@ const WrongVFuncTester = GObject.registerClass(class WrongVFuncTester extends GI vfunc_vfunc_out_enum() { } + vfunc_vfunc_return_flags() { + } + + vfunc_vfunc_out_flags() { + } + vfunc_vfunc_return_object_transfer_none() { } @@ -1419,6 +1454,26 @@ describe('Wrong virtual functions', function () { GLib.test_assert_expected_messages_internal('Gjs', 'testGIMarshalling.js', 0, 'testVFuncReturnWrongValue'); }); + + it('marshals a flags return value', function () { + GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_CRITICAL, + 'JS ERROR: Error: Expected type flags for Return*undefined*'); + + expect(tester.vfunc_return_flags()).toEqual(0); + + GLib.test_assert_expected_messages_internal('Gjs', 'testGIMarshalling.js', 0, + 'testVFuncReturnWrongValue'); + }); + + it('marshals a flags out parameter', function () { + GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_CRITICAL, + 'JS ERROR: Error: Expected type flags for Argument*undefined*'); + + expect(tester.vfunc_out_flags()).toEqual(0); + + GLib.test_assert_expected_messages_internal('Gjs', 'testGIMarshalling.js', 0, + 'testVFuncReturnWrongValue'); + }); }); describe('Inherited GObject', function () { |