mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
types::has_equals fails with assert for bitstructs #2377
This commit is contained in:
36
test/test_suite/bitstruct/bitstruct_const_compare.c3
Normal file
36
test/test_suite/bitstruct/bitstruct_const_compare.c3
Normal file
@@ -0,0 +1,36 @@
|
||||
module test;
|
||||
|
||||
bitstruct Foo : int
|
||||
{
|
||||
bool foo;
|
||||
}
|
||||
|
||||
bitstruct Foo2 : int
|
||||
{
|
||||
bool a : 1;
|
||||
int b : 7..9;
|
||||
}
|
||||
|
||||
fn void main()
|
||||
{
|
||||
var $foo = (Foo) { true };
|
||||
var $bar = (Foo) { };
|
||||
bool $baz = $foo == $bar;
|
||||
$assert($baz == false);
|
||||
$baz = $foo == $foo;
|
||||
$assert($baz == true);
|
||||
$assert(true == types::has_equals(Foo));
|
||||
Foo2 $a1 = { true, 2 };
|
||||
Foo2 $a2 = {};
|
||||
Foo2 $a3 = { true, 3 };
|
||||
Foo2 $a4 = { false, 0 };
|
||||
$assert(!($a1 == $a2));
|
||||
$assert($a1 != $a2);
|
||||
$assert($a2 == $a2);
|
||||
$assert(!($a2 != $a2));
|
||||
$assert($a1 != $a3);
|
||||
$assert(!($a1 == $a3));
|
||||
$assert($a4 == $a2);
|
||||
$assert(!($a4 != $a2));
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user