Starting from tests/binpac/enum/compare-enum.pac2, in the following code, the comparision of an integer (not converted!) to an enum label seems to return equal in any case.
# @TEST-EXEC: printf '\101\102' | pac-driver-test %INPUT >output
# @TEST-EXEC: btest-diff output
#
# @TEST-KNOWN-FAILURE: there's a problem with comparing enum labels.
module Mini;
type ObjectType = enum {
DataType = 0x41,
EndOfData = 0x43
};
if ( ObjectType::DataType == ObjectType::DataType ) {
print "equal";
}
if ( ObjectType::DataType != ObjectType::EndOfData ) {
print "not equal";
}
export type test = unit {
# a : uint8 &convert=ObjectType($$);
# b : uint8 &convert=ObjectType($$);
a : uint8;
b : uint8;
on %done {
if ( self.a == ObjectType::DataType )
print "equal";
if ( self.b != ObjectType::DataType )
print "not equal";
}
};
This prints
equal
not equal
equal
and the final "not equal" is missing.
As far as I understand it, either should the comparision work the right way or the compiler say that it is not supported.
I forgot to add that the comparision works correctly if I cast the enum label to an int before, like
if ( self.a == cast<uint8>(ObjectType::DataType) )
By the way, the unmodified test case seems to run correctly, despite it's marked as known failure?
Starting from
tests/binpac/enum/compare-enum.pac2
, in the following code, the comparision of an integer (not converted!) to an enum label seems to return equal in any case.This prints
and the final "not equal" is missing.
As far as I understand it, either should the comparision work the right way or the compiler say that it is not supported.
I forgot to add that the comparision works correctly if I cast the enum label to an int before, like
By the way, the unmodified test case seems to run correctly, despite it's marked as known failure?