mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
- Remove `[?]` syntax. - Change `int!` to `int?` syntax. - New `fault` declarations. - Enum associated values can reference the calling enum.
18 lines
425 B
Plaintext
18 lines
425 B
Plaintext
import std::math;
|
|
|
|
fn void vector_method_reduce() @test
|
|
{
|
|
float[<3>] x = { 1, 2.0, 4.0 };
|
|
int[<*>] y = { -23, 1, 4 };
|
|
assert(y.sum() == -18);
|
|
assert(y.product() == -92);
|
|
assert(y.max() == 4);
|
|
assert(y.and() == 0);
|
|
assert(y.xor() == -20);
|
|
assert(y.min() == -23);
|
|
assert(y.or() == -19);
|
|
assert(x.sum(1.2) - 8.2 < 0.000001);
|
|
assert(x.product(1.2) - 9.6 < 0.000001);
|
|
assert(x.min() == 1.0);
|
|
assert(x.max() == 4.0);
|
|
} |