mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
35 lines
522 B
Plaintext
35 lines
522 B
Plaintext
fn void vector_inc_dec() @test
|
|
{
|
|
int[<3>] x;
|
|
int[<3>] y;
|
|
int z = ++x[0];
|
|
int zz = y[0]++;
|
|
x[1]++;
|
|
++y[2];
|
|
int[<3>] g = x--;
|
|
assert(x == { 0, 0, -1 });
|
|
assert(y == { 1, 0, 1 });
|
|
assert(z == 1 && zz == 0);
|
|
assert(g == { 1, 1, 0 });
|
|
}
|
|
|
|
fn void int_inc_dec() @test
|
|
{
|
|
int x;
|
|
assert(x++ == 0);
|
|
assert(x == 1);
|
|
assert(++x == 2);
|
|
assert(x-- == 2);
|
|
assert(--x == 0);
|
|
}
|
|
|
|
fn void float_inc_dec() @test
|
|
{
|
|
double x;
|
|
assert(x++ == 0);
|
|
assert(x == 1.0);
|
|
assert(++x == 2.0);
|
|
assert(x-- == 2.0);
|
|
assert(--x == 0);
|
|
}
|