mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fixed regression with optional argument macros and lambdas.
This commit is contained in:
23
test/unit/regression/lambda_in_macro.c3
Normal file
23
test/unit/regression/lambda_in_macro.c3
Normal file
@@ -0,0 +1,23 @@
|
||||
module lambda;
|
||||
|
||||
macro @test(int $xd = ...)
|
||||
{
|
||||
return fn int() {
|
||||
static int tx = 0;
|
||||
$if $defined($xd):
|
||||
return $xd + tx++;
|
||||
$else
|
||||
return 0;
|
||||
$endif
|
||||
};
|
||||
}
|
||||
|
||||
fn void test_lambda_in_macro() @test
|
||||
{
|
||||
assert(@test(2)() == 2);
|
||||
assert(@test(2)() == 3);
|
||||
assert(@test(2)() == 4);
|
||||
assert(@test(2)() == 5);
|
||||
assert(@test(4)() == 4);
|
||||
assert(@test()() == 0);
|
||||
}
|
||||
Reference in New Issue
Block a user