Files
c3c/test/test_suite/assert/assert_with_void.c3
Christoffer Lerno 2439405e70 - $foreach "()" replaced by trailing ":" $foreach ($x, $y : $foo) -> $foreach $x, $y : $foo:
- `$for` "()" replaced by trailing ":" `$for (var $x = 0; $x < FOO; $x++)` -> `$for var $x = 0; $x < FOO; $x++:`
- `$switch` "()" replaced by trailing ":" `$switch ($Type)` -> `$switch $Type:`
- Empty `$switch` requires trailing ":" `$switch` -> `$switch:`
2025-03-04 16:13:47 +01:00

42 lines
1.0 KiB
Plaintext

module testing;
import std::io;
fn void main()
{
String[] s1;
String[] s2;
assert(false, "%s / %s", deep_print(s1), deep_print(s2)); // #error: This expression is of type
}
macro deep_print(a)
{
var $Type = $typeof(a);
$switch $Type.kindof:
$case ARRAY:
$case SLICE:
io::print("[");
foreach (i, x : a)
{
if (i > 0) io::print(", ");
deep_print(x);
}
io::print("]");
$case STRUCT:
io::print("{");
$foreach $i, $m : $typeof(a).membersof:
if ($i > 0) io::print(", ");
deep_print($m.get(a));
$endforeach
io::print("}");
$default:
$switch $Type.nameof:
$case "String":
$case "DString":
$case "WString":
$case "ZString":
io::printf(`"%s"`, a);
$default:
io::printf("%s", a);
$endswitch
$endswitch
}