summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2010-09-14 15:58:00 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2011-01-12 20:15:02 -0500
commit259ede142fd4dcf7171555aa50e87d2e652d6220 (patch)
treef1e9287c3f53869fbaa06e0cd66a90e020ea1434 /test
parent4bd95b58636386aeefb6b504ec4ec1ab07018513 (diff)
downloadgjs-259ede142fd4dcf7171555aa50e87d2e652d6220.tar.gz
Handle wide ranging enum values better
Enums were being converted to and from jsval using JSVAL_TO_INT and INT_TO_JSVAL. The latter is just wrong - INT_TO_JSVAL produces junk results if called on an integer outside the range of -0x40000000 - 0x3fffffff. Just fixing that still leaves a problem - if we get 0x80000000 as a flags value, and we treat it as (int)0x80000000 then we pass it to another function that is using 'guint' for flags instead of the enum type, we'll throw because the value is out of range. So, this change goes a further and (by depending on gobject-introspection changes in 629704) correctly maps all signed and unsigned 32 bit constants onto the correct numeric value. A new utility function gjs_value_to_int64() is added to convert from jsval to gint64, since we are using int64 as an intermediate type for holding enum values. https://bugzilla.gnome.org/show_bug.cgi?id=629705
Diffstat (limited to 'test')
-rw-r--r--test/js/testEverythingBasic.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/js/testEverythingBasic.js b/test/js/testEverythingBasic.js
index 79dcb348..5f3d39ee 100644
--- a/test/js/testEverythingBasic.js
+++ b/test/js/testEverythingBasic.js
@@ -340,8 +340,17 @@ function testNestedGHashOut() {
/* Enums */
function testEnumParam() {
- let e = Everything.test_enum_param(Everything.TestEnum.VALUE1);
+ let e;
+
+ e = Everything.test_enum_param(Everything.TestEnum.VALUE1);
+ assertEquals('Enum parameter', 'value1', e);
+ e = Everything.test_enum_param(Everything.TestEnum.VALUE3);
+ assertEquals('Enum parameter', 'value3', e);
+
+ e = Everything.test_unsigned_enum_param(Everything.TestEnumUnsigned.VALUE1);
assertEquals('Enum parameter', 'value1', e);
+ e = Everything.test_unsigned_enum_param(Everything.TestEnumUnsigned.VALUE2);
+ assertEquals('Enum parameter', 'value2', e);
}
function testSignal() {