Net-DBus
view release on metacpan or search on metacpan
t/56-scalar-param-typing.t view on Meta::CPAN
skip "sign truncation broken", 1;
is($object->get_last_message_param, -3, "double as byte");
}
# -ve Range overflow
$myobject->ScalarByte(dbus_byte(-10000));
is($object->get_last_message_signature, "y", "-ve int as byte overflow");
SKIP: {
skip "sign truncation broken", 1;
is($object->get_last_message_param, -10000, "-ve int as byte overflow");
}
##### Boolean
# String, O and false
$myobject->ScalarBoolean(dbus_boolean("0"));
is($object->get_last_message_signature, "b", "string as boolean, 0 and false");
is($object->get_last_message_param, '', "string as boolean, 0 and false");
# String, O but true
$myobject->ScalarBoolean(dbus_boolean("0true"));
is($object->get_last_message_signature, "b", "string as boolean, 0 but true");
is($object->get_last_message_param, '1', "string as boolean, 0 but true");
# String, 1 and true
$myobject->ScalarBoolean(dbus_boolean("1true"));
is($object->get_last_message_signature, "b", "string as boolean, 1 and true");
is($object->get_last_message_param, '1', "string as boolean, 1 and true");
# Int true
$myobject->ScalarBoolean(dbus_boolean(1));
is($object->get_last_message_signature, "b", "int as boolean, true");
is($object->get_last_message_param, '1', "int as boolean, true");
# Int false
$myobject->ScalarBoolean(dbus_boolean(0));
is($object->get_last_message_signature, "b", "int as boolean, false");
is($object->get_last_message_param, '', "int as boolean, false");
# Undefined and false
$myobject->ScalarBoolean(dbus_boolean(undef));
is($object->get_last_message_signature, "b", "undefined as boolean, false");
is($object->get_last_message_param, '', "undefined as boolean, false");
}
TEST_INTROSPECT_TYPING: {
my ($bus, $object, $robject, $myobject, $otherobject) = &setup;
my $ins = Net::DBus::Binding::Introspector->new();
$ins->add_method("ScalarString", ["string"], [], "org.example.MyObject", {}, []);
$ins->add_method("ScalarInt16", ["int16"], [], "org.example.MyObject", {}, []);
$ins->add_method("ScalarUInt16", ["uint16"], [], "org.example.MyObject", {}, []);
$ins->add_method("ScalarInt32", ["int32"], [], "org.example.MyObject", {}, []);
$ins->add_method("ScalarUInt32", ["uint32"], [], "org.example.MyObject", {}, []);
$ins->add_method("ScalarDouble", ["double"], [], "org.example.MyObject", {}, []);
$ins->add_method("ScalarByte", ["byte"], [], "org.example.MyObject", {}, []);
$ins->add_method("ScalarBoolean", ["bool"], [], "org.example.MyObject", {}, []);
$object->seed_action("org.freedesktop.DBus.Introspectable", "Introspect",
reply => { return => [ $ins->format($object) ] });
##### String tests
$myobject->ScalarString("Foo");
is($object->get_last_message_signature, "s", "string as string");
is($object->get_last_message_param, "Foo", "string as string");
$myobject->ScalarString(2);
is($object->get_last_message->get_signature, "s", "int as string");
is($object->get_last_message_param, "2", "int as string");
$myobject->ScalarString(5.234);
is($object->get_last_message->get_signature, "s", "double as string");
is($object->get_last_message_param, "5.234", "double as string");
#### INT 16 tests
# Positive integers
$myobject->ScalarInt16("2");
is($object->get_last_message_signature, "n", "string as int16");
is($object->get_last_message_param, 2, "string as int16");
$myobject->ScalarInt16(2);
is($object->get_last_message_signature, "n", "int as int16");
is($object->get_last_message_param, 2, "int as int16");
$myobject->ScalarInt16(2.0);
is($object->get_last_message_signature, "n", "double as int16");
is($object->get_last_message_param, 2, "double as int16");
# Negative integers
$myobject->ScalarInt16("-2");
is($object->get_last_message_signature, "n", "-ve string as int16");
SKIP: {
skip "sign truncation not checked", 1;
is($object->get_last_message_param, "-2", "-ve string as int16");
}
$myobject->ScalarInt16(-2);
is($object->get_last_message_signature, "n", "-ve int as int16");
SKIP: {
skip "sign truncation not checked", 1;
is($object->get_last_message_param, "-2", "-ve int as int16");
}
$myobject->ScalarInt16(-2.0);
is($object->get_last_message_signature, "n", "-ve double as int16");
SKIP: {
skip "sign truncation not checked", 1;
is($object->get_last_message_param, "-2.0", "-ve double as int16");
}
# Rounding of doubles
$myobject->ScalarInt16(2.1);
is($object->get_last_message_signature, "n", "round down double as int16");
is($object->get_last_message_param, 2, "round down double as int16");
$myobject->ScalarInt16(2.9);
( run in 2.848 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )