commit
f782723f14
1207
bootstrap/main.cpp
1207
bootstrap/main.cpp
File diff suppressed because it is too large
Load Diff
130
tests/if/main.nat
Normal file
130
tests/if/main.nat
Normal file
@ -0,0 +1,130 @@
|
||||
fn if0(arg: s32) s32
|
||||
{
|
||||
>a: s32 = 1;
|
||||
if (arg == 1)
|
||||
{
|
||||
a = arg + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = arg - 3;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
fn if1(arg: s32) s32
|
||||
{
|
||||
>c: s32 = 3;
|
||||
>b: s32 = 2;
|
||||
|
||||
if (arg == 1)
|
||||
{
|
||||
b = 3;
|
||||
c = 4;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
fn if2(arg: s32) s32
|
||||
{
|
||||
if (arg == 1)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
fn if3(arg: s32) s32
|
||||
{
|
||||
>a: s32 = arg + 1;
|
||||
>b: s32 = 0;
|
||||
if (arg == 1)
|
||||
{
|
||||
b = a;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = a + 1;
|
||||
}
|
||||
|
||||
return a + b;
|
||||
}
|
||||
|
||||
fn if4(arg: s32) s32
|
||||
{
|
||||
>a: s32 = arg + 1;
|
||||
>b: s32 = arg + 2;
|
||||
if (arg == 1)
|
||||
{
|
||||
b = b + a;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = b + 1;
|
||||
}
|
||||
|
||||
return a + b;
|
||||
}
|
||||
|
||||
fn if5(arg: s32) s32
|
||||
{
|
||||
>a: s32 = 1;
|
||||
if (arg == 1)
|
||||
{
|
||||
if (arg == 2)
|
||||
{
|
||||
a = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = 3;
|
||||
}
|
||||
}
|
||||
else if (arg == 3)
|
||||
{
|
||||
a = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = 5;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
fn if6(arg: s32) s32
|
||||
{
|
||||
>a: s32 = 0;
|
||||
>b: s32 = 0;
|
||||
if (arg)
|
||||
{
|
||||
a = 1;
|
||||
}
|
||||
if (arg == 0)
|
||||
{
|
||||
b = 2;
|
||||
}
|
||||
|
||||
return arg + a + b;
|
||||
}
|
||||
|
||||
fn if7(arg: s32) s32
|
||||
{
|
||||
>a: s32 = arg == 2;
|
||||
if (arg == 1)
|
||||
{
|
||||
a = arg == 3;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
fn[cc(.c)] main[export] () s32
|
||||
{
|
||||
return if0(3) + if1(1) - 4 + if2(1) - 3 + if3(1) - 4 + if4(0) - 5 + if5(4) - 5 + if6(0) - 2 + if7(0);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user