Files
c3c/test/unit/regression/vector_conversion.c3
Christoffer Lerno 25bccf4883 New faults and syntax (#2034)
- Remove `[?]` syntax.
- Change `int!` to `int?` syntax.
- New `fault` declarations.
- Enum associated values can reference the calling enum.
2025-03-10 00:11:35 +01:00

31 lines
590 B
Plaintext

module test @test;
fn void vector_array_inferred()
{
int[<2>] x = { 4, 7 };
int[2] y = x;
int[*] y1 = y;
int[*] y2 = x;
int[<*>] z = x;
int[<*>] w = y;
double[<2>] ww = x;
assert((int[<2>])y == { 4, 7});
assert((int[<2>])y1 == { 4, 7 });
assert((int[<2>])y2 == { 4, 7 });
assert(z == { 4, 7 });
assert(w == { 4, 7 });
}
fn void vector_convert_slice()
{
int[<2>] x = { 1, 2 };
int[2] y = { 4, 4 };
x *= y[:2];
assert(x == { 4, 8 });
}
fn void vector_convert_bool()
{
bool[<2>] a = { true, false };
assert({ -1, 0 } == (int[<2>])a);
assert({ 1.0, 0 } == (float[<2>])a);
}