mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
297 lines
3.2 KiB
Beef
297 lines
3.2 KiB
Beef
#pragma warning disable 168
|
|
|
|
using System;
|
|
|
|
namespace IDETest
|
|
{
|
|
class LocalVars
|
|
{
|
|
public void If1()
|
|
{
|
|
int a;
|
|
int b = 123;
|
|
if (b == 234)
|
|
{
|
|
a = 234;
|
|
return;
|
|
}
|
|
b = a; //FAIL
|
|
}
|
|
|
|
public void If2(out int a) //FAIL
|
|
{
|
|
int b = 123;
|
|
if (b == 234)
|
|
return;
|
|
a = 234;
|
|
b = a;
|
|
}
|
|
|
|
public void For1(out int a)
|
|
{
|
|
for (int b < 2)
|
|
a = 9;
|
|
}
|
|
|
|
public void For2(out int a) //FAIL
|
|
{
|
|
int b = 123;
|
|
for (int c < b)
|
|
a = 9;
|
|
}
|
|
|
|
public void Do1(out int a) //FAIL
|
|
{
|
|
int b = 123;
|
|
do
|
|
{
|
|
if (b == 234)
|
|
break;
|
|
a = 9;
|
|
}
|
|
b = a;
|
|
}
|
|
|
|
public void Switch1()
|
|
{
|
|
int val;
|
|
|
|
Result<int> iResult = .Ok(123);
|
|
switch (iResult)
|
|
{
|
|
case .Ok(out val):
|
|
case .Err:
|
|
}
|
|
|
|
int a = val; //FAIL
|
|
}
|
|
|
|
public void Switch2()
|
|
{
|
|
int val;
|
|
|
|
Result<int> iResult = .Ok(123);
|
|
switch (iResult)
|
|
{
|
|
case .Ok(out val):
|
|
case .Err: val = 1;
|
|
}
|
|
|
|
int a = val;
|
|
}
|
|
|
|
public void Switch3()
|
|
{
|
|
int val;
|
|
|
|
Result<int> iResult = .Ok(123);
|
|
switch (iResult)
|
|
{
|
|
case .Ok(out val):
|
|
case .Err: return;
|
|
}
|
|
|
|
int a = val;
|
|
}
|
|
|
|
public void Switch4()
|
|
{
|
|
int a = 1;
|
|
int b;
|
|
|
|
switch (a)
|
|
{
|
|
case 1:
|
|
b = 1;
|
|
case 2:
|
|
case 3:
|
|
fallthrough;
|
|
case 4:
|
|
b = 2;
|
|
default:
|
|
b = 3;
|
|
}
|
|
|
|
int c = b; //FAIL
|
|
}
|
|
|
|
public void Switch5()
|
|
{
|
|
int a = 1;
|
|
int b;
|
|
|
|
switch (a)
|
|
{
|
|
case 1:
|
|
b = 1;
|
|
case 2:
|
|
fallthrough;
|
|
case 3:
|
|
fallthrough;
|
|
case 4:
|
|
b = 2;
|
|
default:
|
|
b = 3;
|
|
}
|
|
|
|
int c = b;
|
|
}
|
|
|
|
public void Switch6()
|
|
{
|
|
int val;
|
|
|
|
Result<int> iResult = .Ok(123);
|
|
switch (iResult)
|
|
{
|
|
case .Ok(out val):
|
|
case .Err: break;
|
|
}
|
|
|
|
int a = val; //FAIL
|
|
}
|
|
|
|
public void While1()
|
|
{
|
|
int a = 1;
|
|
int b;
|
|
|
|
while (true)
|
|
{
|
|
if (a == 2)
|
|
break;
|
|
b = 2;
|
|
}
|
|
|
|
int c = b; //FAIL
|
|
}
|
|
|
|
public void While2()
|
|
{
|
|
int a = 1;
|
|
int b;
|
|
|
|
while (true)
|
|
{
|
|
if (a == 2)
|
|
return;
|
|
b = 2;
|
|
break;
|
|
}
|
|
|
|
int c = b;
|
|
}
|
|
|
|
public void While3()
|
|
{
|
|
int a = 1;
|
|
int b;
|
|
|
|
while (a == 1)
|
|
{
|
|
if (a == 2)
|
|
return;
|
|
b = 2;
|
|
break;
|
|
}
|
|
|
|
int c = b; //FAIL
|
|
}
|
|
|
|
public void While4()
|
|
{
|
|
for (int i < 2)
|
|
{
|
|
int a = 1;
|
|
int b;
|
|
|
|
while (true)
|
|
{
|
|
if (a == 2)
|
|
return;
|
|
b = 2;
|
|
break;
|
|
}
|
|
|
|
int c = b;
|
|
}
|
|
}
|
|
|
|
public void While5()
|
|
{
|
|
for (int i < 2)
|
|
{
|
|
int a = 1;
|
|
int b;
|
|
|
|
while (a == 1)
|
|
{
|
|
if (a == 2)
|
|
return;
|
|
b = 2;
|
|
break;
|
|
}
|
|
|
|
int c = b; //FAIL
|
|
}
|
|
}
|
|
|
|
public bool GetVal(out int a)
|
|
{
|
|
a = 1;
|
|
return true;
|
|
}
|
|
|
|
public void Local1()
|
|
{
|
|
if ((GetVal(var a)) && (GetVal(var b)))
|
|
{
|
|
int c = a;
|
|
int d = b;
|
|
}
|
|
|
|
int e = a;
|
|
int f = b; //FAIL
|
|
}
|
|
|
|
public void Local2()
|
|
{
|
|
int a;
|
|
int b;
|
|
if ((GetVal(out a)) && (GetVal(out b)))
|
|
{
|
|
int c = a;
|
|
int d = b;
|
|
}
|
|
|
|
int e = a;
|
|
int f = b; //FAIL
|
|
}
|
|
|
|
public void Local3()
|
|
{
|
|
if ((GetVal(var a)) || (GetVal(var b))) //FAIL
|
|
{
|
|
int c = a;
|
|
int d = b;
|
|
}
|
|
|
|
int e = a;
|
|
int f = b; //FAIL
|
|
}
|
|
|
|
public void Local4()
|
|
{
|
|
int a;
|
|
int b;
|
|
if ((GetVal(out a)) || (GetVal(out b)))
|
|
{
|
|
int c = a;
|
|
int d = b; //FAIL
|
|
}
|
|
|
|
int e = a;
|
|
int f = b; //FAIL
|
|
}
|
|
}
|
|
}
|