mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
25
IDE/Tests/Test1/src/Assembly.bf
Normal file
25
IDE/Tests/Test1/src/Assembly.bf
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Assembly
|
||||
{
|
||||
public static int IncVal(ref int val)
|
||||
{
|
||||
val++;
|
||||
return val;
|
||||
}
|
||||
|
||||
public static void Test1()
|
||||
{
|
||||
int a = 0;
|
||||
int d = IncVal(ref a) + IncVal(ref a) + IncVal(ref a);
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//AssemblyTester_Test
|
||||
Test1();
|
||||
}
|
||||
}
|
||||
}
|
26
IDE/Tests/Test1/src/Break.bf
Normal file
26
IDE/Tests/Test1/src/Break.bf
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System.Threading;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Break
|
||||
{
|
||||
public static void Infinite()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
int a = 0;
|
||||
a++;
|
||||
a++;
|
||||
a++;
|
||||
if (a == -1)
|
||||
Infinite();
|
||||
}
|
||||
}
|
||||
}
|
36
IDE/Tests/Test1/src/Breakpoints.bf
Normal file
36
IDE/Tests/Test1/src/Breakpoints.bf
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Breakpoints
|
||||
{
|
||||
public static void Recurse(int a)
|
||||
{
|
||||
int b = 234;
|
||||
//Recurse_C
|
||||
int c = 345;
|
||||
|
||||
if (a == 10)
|
||||
return;
|
||||
|
||||
Recurse(a + 1);
|
||||
int d = 100 + a;
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//BreakpointTester_Test
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
|
||||
while (a < 20)
|
||||
{
|
||||
//BreakpointTester_LoopA
|
||||
a++;
|
||||
}
|
||||
|
||||
//BreakpointTester_Recurse
|
||||
Recurse(0);
|
||||
}
|
||||
}
|
||||
}
|
27
IDE/Tests/Test1/src/Breakpoints02.bf
Normal file
27
IDE/Tests/Test1/src/Breakpoints02.bf
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Breakpoints02
|
||||
{
|
||||
static void MethodA()
|
||||
{
|
||||
int a = 0;
|
||||
for (int i < 3)
|
||||
{
|
||||
a++;
|
||||
//MethodA_1
|
||||
a++;
|
||||
//MethodA_2
|
||||
a++;
|
||||
a++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
MethodA();
|
||||
}
|
||||
}
|
||||
}
|
34
IDE/Tests/Test1/src/Enums.bf
Normal file
34
IDE/Tests/Test1/src/Enums.bf
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
enum EnumA
|
||||
{
|
||||
case A(int a);
|
||||
case B(float b);
|
||||
}
|
||||
|
||||
enum EnumB
|
||||
{
|
||||
case A;
|
||||
case B;
|
||||
case C;
|
||||
}
|
||||
|
||||
class EnumTester
|
||||
{
|
||||
public static void Test()
|
||||
{
|
||||
EnumA ea = .B(1.2f);
|
||||
|
||||
let z = (aa:123, bb:345);
|
||||
var q = (a:234, 567, c:999);
|
||||
|
||||
var qRef = ref q;
|
||||
|
||||
EnumB eb = .B;
|
||||
|
||||
//EnumTester_Test
|
||||
}
|
||||
}
|
||||
}
|
248
IDE/Tests/Test1/src/HotSwap.bf
Normal file
248
IDE/Tests/Test1/src/HotSwap.bf
Normal file
|
@ -0,0 +1,248 @@
|
|||
using System.Diagnostics;
|
||||
using System;
|
||||
|
||||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
interface IHot
|
||||
{
|
||||
int IHotA();
|
||||
/*IHot_IHotB
|
||||
int IHotB();
|
||||
*/
|
||||
}
|
||||
|
||||
class HotA : IHot
|
||||
{
|
||||
public virtual int MethodA()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
//*HotA_MethodB
|
||||
public virtual int MethodB()
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
/*@*/
|
||||
|
||||
/*HotA_MethodC
|
||||
public virtual int MethodC()
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
*/
|
||||
|
||||
// Note- this is purposely beneath MethodC
|
||||
/*HotA_MethodB_2
|
||||
public virtual int MethodB()
|
||||
{
|
||||
return 111;
|
||||
}
|
||||
*/
|
||||
|
||||
/*HotA_MethodD
|
||||
public virtual int MethodD()
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
*/
|
||||
|
||||
public virtual int MethodE()
|
||||
{
|
||||
return 14;
|
||||
}
|
||||
|
||||
public int IHotA()
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public int IHotB()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
class HotB : HotA
|
||||
{
|
||||
public override int MethodA()
|
||||
{
|
||||
//HotB_MethodA_Return
|
||||
return 20;
|
||||
}
|
||||
|
||||
/*HotB_MethodB_Start
|
||||
public override int MethodB()
|
||||
{
|
||||
return 21;
|
||||
}
|
||||
*/
|
||||
|
||||
/*HotB_MethodC_Start
|
||||
public override int MethodC()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
class HotTester
|
||||
{
|
||||
|
||||
public void Test2(HotA hot)
|
||||
{
|
||||
/*HotTester_Test2
|
||||
int val = hot.MethodC();
|
||||
*/
|
||||
}
|
||||
|
||||
public void Test3(HotA hot)
|
||||
{
|
||||
/*HotTester_Test3
|
||||
int val = hot.MethodE();
|
||||
*/
|
||||
}
|
||||
|
||||
public void Test1()
|
||||
{
|
||||
//*HotTester_Test1
|
||||
|
||||
HotA hot = scope HotB();
|
||||
|
||||
//HotStart
|
||||
int val = hot.MethodA();
|
||||
val = hot.MethodB();
|
||||
val = hot.MethodB();
|
||||
|
||||
Test2(hot);
|
||||
|
||||
//HotTester_Test1_EndTest
|
||||
val = 99;
|
||||
|
||||
Test3(hot);
|
||||
|
||||
/*@*/
|
||||
}
|
||||
|
||||
public void TestVirtualRemap2(HotA hot)
|
||||
{
|
||||
/*HotTester_TestVirtualRemap2_MethodCCall
|
||||
int val = hot.MethodC();
|
||||
*/
|
||||
}
|
||||
|
||||
public void TestVirtualRemap()
|
||||
{
|
||||
//HotStart_VirtualRemap
|
||||
HotA hot = scope HotB();
|
||||
|
||||
//*HotTester_TestVirtualRemap_MethodBCall
|
||||
int val = hot.MethodB();
|
||||
/*@*/
|
||||
|
||||
TestVirtualRemap2(hot);
|
||||
|
||||
//*HotTester_TestVirtualRemap_MethodBCall_2
|
||||
val = hot.MethodB();
|
||||
/*@*/
|
||||
}
|
||||
|
||||
static public int TestFuncs_Func()
|
||||
{
|
||||
//HotTester_TestFuncs_Func_Return
|
||||
return 123;
|
||||
}
|
||||
|
||||
/*HotTester_TestFuncs_Func2
|
||||
static public int TestFuncs_Func2()
|
||||
{
|
||||
//HotTester_TestFuncs_Func2_Return
|
||||
return 444;
|
||||
}
|
||||
*/
|
||||
|
||||
public void TestFuncs_Compare(HotA hot, delegate int() dlgA0, delegate int() dlgT0, function int() funcT0)
|
||||
{
|
||||
delegate int() dlgA1 = scope => hot.MethodA;
|
||||
delegate int() dlgT1 = scope => TestFuncs_Func;
|
||||
function int() funcT1 = => TestFuncs_Func;
|
||||
|
||||
Debug.Assert(Delegate.Equals(dlgA0, dlgA1));
|
||||
Debug.Assert(Delegate.Equals(dlgT0, dlgT1));
|
||||
Debug.Assert(funcT0 == funcT1);
|
||||
|
||||
//TestFuncs_Compare_Calls
|
||||
int val = dlgA0();
|
||||
val = dlgT0();
|
||||
val = funcT0();
|
||||
}
|
||||
|
||||
public void TestFuncs()
|
||||
{
|
||||
//HotStart_Funcs
|
||||
HotA hot = scope HotB();
|
||||
//Debug.WriteLine("Result: {0}", hot);
|
||||
|
||||
delegate int() dlgA0 = scope => hot.MethodA;
|
||||
delegate int() dlgT0 = scope => TestFuncs_Func;
|
||||
function int() funcT0 = => TestFuncs_Func;
|
||||
TestFuncs_Compare(hot, dlgA0, dlgT0, funcT0);
|
||||
}
|
||||
|
||||
public void TestFuncs2_Compare(function int() funcT0)
|
||||
{
|
||||
/*TestFuncs2_Compare_Body
|
||||
function int() funcT1 = => TestFuncs_Func2;
|
||||
Debug.Assert(funcT1 == funcT0);
|
||||
*/
|
||||
int val = funcT0();
|
||||
}
|
||||
|
||||
public void TestFuncs2()
|
||||
{
|
||||
/*TestFuncs2_Body
|
||||
function int() funcT0 = => TestFuncs_Func2;
|
||||
TestFuncs2_Compare(funcT0);
|
||||
*/
|
||||
}
|
||||
|
||||
public void TestIHotA(HotA hot)
|
||||
{
|
||||
/*HotTester_TestIHotA
|
||||
IHot ihot = hot;
|
||||
int val = ihot.IHotA();
|
||||
*/
|
||||
}
|
||||
|
||||
public void TestIHotB(HotA hot)
|
||||
{
|
||||
/*HotTester_TestIHotB
|
||||
IHot ihot = hot;
|
||||
int val = ihot.IHotB();
|
||||
*/
|
||||
}
|
||||
|
||||
public void TestInterfaces()
|
||||
{
|
||||
//HotStart_Interfaces
|
||||
HotA hot = scope HotB();
|
||||
TestIHotA(hot);
|
||||
TestIHotB(hot);
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
HotTester ht = scope .();
|
||||
ht.Test1();
|
||||
ht.Test1();
|
||||
|
||||
ht.TestVirtualRemap();
|
||||
ht.TestFuncs();
|
||||
ht.TestFuncs2();
|
||||
ht.TestInterfaces();
|
||||
}
|
||||
}
|
||||
}
|
143
IDE/Tests/Test1/src/HotSwap_BaseChange.bf
Normal file
143
IDE/Tests/Test1/src/HotSwap_BaseChange.bf
Normal file
|
@ -0,0 +1,143 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class HotSwap_BaseChange
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
public virtual int MethodA0()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
public virtual int MethodA1()
|
||||
{
|
||||
return 101;
|
||||
}
|
||||
}
|
||||
|
||||
class ClassB
|
||||
{
|
||||
public virtual int MethodB0()
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
/*ClassB_MethodB1
|
||||
public virtual int MethodB1()
|
||||
{
|
||||
return 201;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*ClassC_0
|
||||
class ClassC : ClassA
|
||||
{
|
||||
public virtual int MethodC0()
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*ClassC_1
|
||||
class ClassC : ClassB
|
||||
{
|
||||
public virtual int MethodC0()
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*ClassC_2
|
||||
class ClassC : ClassB
|
||||
{
|
||||
public virtual int MethodC0()
|
||||
{
|
||||
return 1300;
|
||||
}
|
||||
|
||||
public virtual int MethodC1()
|
||||
{
|
||||
return 1301;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*ClassC_3
|
||||
class ClassC : ClassA
|
||||
{
|
||||
// FAILS
|
||||
public this() : base(123)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int MethodC0()
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
static void DoTest0()
|
||||
{
|
||||
/*DoTest0_Body
|
||||
ClassC cc = scope .();
|
||||
int a0 = cc.MethodA0();
|
||||
int a1 = cc.MethodA1();
|
||||
int c0 = cc.MethodC0();
|
||||
*/
|
||||
}
|
||||
|
||||
static void DoTest1()
|
||||
{
|
||||
/*DoTest1_Body
|
||||
ClassC cc = scope .();
|
||||
int b0 = cc.MethodB0();
|
||||
int c0 = cc.MethodC0();
|
||||
b0 = cc.MethodB0();
|
||||
c0 = cc.MethodC0();
|
||||
DoTest2(cc);
|
||||
*/
|
||||
}
|
||||
|
||||
/*DoTest2_Decl
|
||||
static void DoTest2(ClassC cc)
|
||||
{
|
||||
/*DoTest2_Body
|
||||
int b0 = cc.MethodB0();
|
||||
int b1 = cc.MethodB1();
|
||||
int c0 = cc.MethodC0();
|
||||
int c1 = cc.MethodC1();
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
static void DoTest3()
|
||||
{
|
||||
/*DoTest3_Body
|
||||
ClassC cc = scope .();
|
||||
*/
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
// Reify these methods and types
|
||||
ClassA ca = scope .();
|
||||
ca.MethodA0();
|
||||
ca.MethodA1();
|
||||
ClassB cb = scope .();
|
||||
cb.MethodB0();
|
||||
|
||||
int a = 0;
|
||||
//Test_Start
|
||||
DoTest0();
|
||||
DoTest1();
|
||||
DoTest3();
|
||||
}
|
||||
}
|
||||
}
|
137
IDE/Tests/Test1/src/HotSwap_Data.bf
Normal file
137
IDE/Tests/Test1/src/HotSwap_Data.bf
Normal file
|
@ -0,0 +1,137 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class HotSwap_Data
|
||||
{
|
||||
struct StructA
|
||||
{
|
||||
public int mA = 100;
|
||||
/*StructA_mA2
|
||||
public int mA2 = 101;
|
||||
*/
|
||||
/*StructA_mA3
|
||||
public int mA3 = 102;
|
||||
*/
|
||||
}
|
||||
|
||||
struct StructB
|
||||
{
|
||||
public int mB;
|
||||
}
|
||||
|
||||
struct StructC : StructA
|
||||
{
|
||||
public StructB mSB;
|
||||
public int mC;
|
||||
}
|
||||
|
||||
interface IFaceA
|
||||
{
|
||||
void IMethodA();
|
||||
}
|
||||
|
||||
interface IFaceB
|
||||
{
|
||||
void IMethodB();
|
||||
}
|
||||
|
||||
class ClassA : IFaceA
|
||||
{
|
||||
public void IMethodA()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class ClassB : IFaceB
|
||||
{
|
||||
public void IMethodB()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class ClassC :
|
||||
//*ClassC_IFaceA
|
||||
IFaceA
|
||||
/*@*/
|
||||
/*ClassC_IFaceB_WithoutComma
|
||||
IFaceB
|
||||
*/
|
||||
/*ClassC_IFaceB_WithComma
|
||||
, IFaceB
|
||||
*/
|
||||
{
|
||||
public void IMethodA()
|
||||
{
|
||||
}
|
||||
|
||||
public void IMethodB()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static void Test01()
|
||||
{
|
||||
StructC sc = .();
|
||||
/*Test01_mA2
|
||||
int val = sc.mA2;
|
||||
*/
|
||||
}
|
||||
|
||||
//*Func
|
||||
[AlwaysInclude]
|
||||
static void Func()
|
||||
{
|
||||
StructA sa = .();
|
||||
}
|
||||
/*@*/
|
||||
|
||||
static void Test02()
|
||||
{
|
||||
}
|
||||
|
||||
static void Test03()
|
||||
{
|
||||
/*Test03_delegate
|
||||
delegate void() funcPtr = new => Func;
|
||||
Console.WriteLine("Delegate: {0}", funcPtr);
|
||||
*/
|
||||
}
|
||||
|
||||
static void Test04()
|
||||
{
|
||||
ClassA ca = scope .();
|
||||
IFaceA ia = ca;
|
||||
ia.IMethodA();
|
||||
ClassB cb = scope .();
|
||||
IFaceB ib = cb;
|
||||
ib.IMethodB();
|
||||
ClassC cc = scope .();
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
/*Test_funcPtr
|
||||
function void() funcPtr = => Func;
|
||||
*/
|
||||
|
||||
int a = 0;
|
||||
//Test_Test01
|
||||
Test01();
|
||||
Test01();
|
||||
|
||||
//Test_Test02
|
||||
Test02();
|
||||
|
||||
//Test_Test03
|
||||
Test03();
|
||||
Test03();
|
||||
|
||||
//Test_Test04
|
||||
Test04();
|
||||
}
|
||||
}
|
||||
}
|
36
IDE/Tests/Test1/src/HotSwap_GetUnused.bf
Normal file
36
IDE/Tests/Test1/src/HotSwap_GetUnused.bf
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class HotSwap_GetUnusued
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
public void MethodA()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int MethodB()
|
||||
{
|
||||
return 123;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoTest()
|
||||
{
|
||||
ClassA ca = scope .();
|
||||
ca.MethodA();
|
||||
/*DoTest_MethodB
|
||||
int val = ca.MethodB();
|
||||
*/
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
int a = 123;
|
||||
//Test
|
||||
DoTest();
|
||||
}
|
||||
}
|
||||
}
|
46
IDE/Tests/Test1/src/HotSwap_Interfaces2.bf
Normal file
46
IDE/Tests/Test1/src/HotSwap_Interfaces2.bf
Normal file
|
@ -0,0 +1,46 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class HotSwap_Interfaces2
|
||||
{
|
||||
interface IFaceA
|
||||
{
|
||||
int Method0();
|
||||
/*IFaceA_Method1
|
||||
int Method1();
|
||||
*/
|
||||
}
|
||||
|
||||
class ClassA : IFaceA
|
||||
{
|
||||
public int Method0()
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
/*ClassA_Method1
|
||||
public int Method1()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
static void Test1(IFaceA ia)
|
||||
{
|
||||
/*Test1_Method1
|
||||
int v1 = ia.Method1();
|
||||
*/
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
ClassA ca = scope .();
|
||||
IFaceA ia = ca;
|
||||
//Test_Start
|
||||
int v0 = ia.Method0();
|
||||
Test1(ia);
|
||||
}
|
||||
}
|
||||
}
|
37
IDE/Tests/Test1/src/HotSwap_Reflection.bf
Normal file
37
IDE/Tests/Test1/src/HotSwap_Reflection.bf
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class HotSwap_Reflection
|
||||
{
|
||||
[Reflect]
|
||||
class ClassA
|
||||
{
|
||||
int mA;//ClassA_mA
|
||||
|
||||
public static Type GetMyType()
|
||||
{
|
||||
return typeof(ClassA);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
let t0 = ClassA.GetMyType();
|
||||
for (let field in t0.GetFields())
|
||||
{
|
||||
}
|
||||
let t1 = ClassA.GetMyType();
|
||||
for (let field in t1.GetFields())
|
||||
{
|
||||
}
|
||||
let t2 = ClassA.GetMyType();
|
||||
for (let field in t2.GetFields())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
95
IDE/Tests/Test1/src/HotSwap_TLS.bf
Normal file
95
IDE/Tests/Test1/src/HotSwap_TLS.bf
Normal file
|
@ -0,0 +1,95 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class HotSwap_TLS
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
[ThreadStatic]
|
||||
public static int sTLS0;
|
||||
|
||||
/*ClassA_TLS1
|
||||
[ThreadStatic]
|
||||
public static int sTLS1;
|
||||
*/
|
||||
}
|
||||
|
||||
static Monitor sMonitor = new .() ~ delete _;
|
||||
static WaitEvent sEvent = new .() ~ delete _;
|
||||
static WaitEvent sDoneEvent = new .() ~ delete _;
|
||||
static int sThreadResult;
|
||||
|
||||
public static int Inc0()
|
||||
{
|
||||
return ++ClassA.sTLS0;
|
||||
}
|
||||
|
||||
public static int Inc1()
|
||||
{
|
||||
/*Inc1_TLS1
|
||||
return ++ClassA.sTLS1;
|
||||
*/
|
||||
#unwarn
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void Thread0()
|
||||
{
|
||||
sEvent.WaitFor();
|
||||
sThreadResult = Inc0();
|
||||
sDoneEvent.Set();
|
||||
|
||||
sEvent.WaitFor();
|
||||
sThreadResult = Inc0();
|
||||
sDoneEvent.Set();
|
||||
|
||||
sEvent.WaitFor();
|
||||
sThreadResult = Inc1();
|
||||
sDoneEvent.Set();
|
||||
|
||||
sEvent.WaitFor();
|
||||
sThreadResult = Inc1();
|
||||
sDoneEvent.Set();
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
let thread = scope Thread(new => Thread0);
|
||||
thread.Start(false);
|
||||
|
||||
int val = Inc0();
|
||||
val = Inc0();
|
||||
val = Inc0();
|
||||
Debug.Assert(val == 3);
|
||||
|
||||
sEvent.Set();
|
||||
sDoneEvent.WaitFor();
|
||||
Debug.Assert(sThreadResult == 1);
|
||||
|
||||
sEvent.Set();
|
||||
sDoneEvent.WaitFor();
|
||||
Debug.Assert(sThreadResult == 2);
|
||||
|
||||
val = Inc1();
|
||||
val = Inc1();
|
||||
val = Inc1();
|
||||
NOP!();//Debug.Assert(val == 3);
|
||||
|
||||
sEvent.Set();
|
||||
sDoneEvent.WaitFor();
|
||||
NOP!();//Debug.Assert(sThreadResult == 1);
|
||||
|
||||
sEvent.Set();
|
||||
sDoneEvent.WaitFor();
|
||||
NOP!();//Debug.Assert(sThreadResult == 2);
|
||||
|
||||
thread.Join();
|
||||
}
|
||||
}
|
||||
}
|
60
IDE/Tests/Test1/src/Inline.bf
Normal file
60
IDE/Tests/Test1/src/Inline.bf
Normal file
|
@ -0,0 +1,60 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class InlineTester
|
||||
{
|
||||
[Inline]
|
||||
public static int TimesTwo(int a)
|
||||
{
|
||||
return a * 2;
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public static int Add(int a, int b)
|
||||
{
|
||||
int retVal = TimesTwo(a);
|
||||
retVal += TimesTwo(b);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static int PlusOne(int a)
|
||||
{
|
||||
return a + 1;
|
||||
}
|
||||
|
||||
public static mixin MixB(var argC)
|
||||
{
|
||||
argC = PlusOne(argC);
|
||||
argC
|
||||
}
|
||||
|
||||
public static mixin MixA(var argA, var argB)
|
||||
{
|
||||
int z = MixB!(argA);
|
||||
argA + argB
|
||||
}
|
||||
|
||||
public static void TestInlines()
|
||||
{
|
||||
int a = 123;
|
||||
int b = 234;
|
||||
int d = Add(a, b);
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
int a = 10;
|
||||
int b = 2;
|
||||
|
||||
//InlineTester
|
||||
int c = MixA!(a, b);
|
||||
|
||||
TestInlines();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
31
IDE/Tests/Test1/src/Lambdas.bf
Normal file
31
IDE/Tests/Test1/src/Lambdas.bf
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class LambdaTester
|
||||
{
|
||||
public int mA = 123;
|
||||
public int mB = 234;
|
||||
|
||||
public void Test1()
|
||||
{
|
||||
int outerVar = 88;
|
||||
|
||||
delegate int(int argA0) dlg = scope (argA1) =>
|
||||
{
|
||||
int a = mA;
|
||||
int b = outerVar;
|
||||
return 222;
|
||||
};
|
||||
|
||||
//LambdaTest_Test1
|
||||
dlg(99);
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
LambdaTester lt = scope .();
|
||||
lt.Test1();
|
||||
}
|
||||
}
|
||||
}
|
23
IDE/Tests/Test1/src/MemoryBreakpoints.bf
Normal file
23
IDE/Tests/Test1/src/MemoryBreakpoints.bf
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class MemoryBreakpointTester
|
||||
{
|
||||
int mA;
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//MemoryBreakpointTester_Test
|
||||
MemoryBreakpointTester mbt = scope .();
|
||||
|
||||
int a = 0;
|
||||
mbt.mA++;
|
||||
a++;
|
||||
a++;
|
||||
mbt.mA++;
|
||||
a++;
|
||||
a++;
|
||||
}
|
||||
}
|
||||
}
|
62
IDE/Tests/Test1/src/Methods.bf
Normal file
62
IDE/Tests/Test1/src/Methods.bf
Normal file
|
@ -0,0 +1,62 @@
|
|||
namespace IDETest
|
||||
{
|
||||
class Methods
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
public int TEST_MethodA()
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
|
||||
public int TEST_MethodB()
|
||||
{
|
||||
return 201;
|
||||
}
|
||||
|
||||
/*ClassA_MethodC
|
||||
public int TEST_MethodC()
|
||||
{
|
||||
return 202;
|
||||
}
|
||||
*/
|
||||
|
||||
public static int TEST_StaticMethodA()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
public static int TEST_StaticMethodB()
|
||||
{
|
||||
return 101;
|
||||
}
|
||||
|
||||
/*ClassA_StaticMethodC
|
||||
public static int TEST_StaticMethodC()
|
||||
{
|
||||
return 102;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static void DoTest()
|
||||
{
|
||||
/*DoTest_Body
|
||||
ClassA ca = scope .();
|
||||
ca.TEST_MethodB();
|
||||
ca.TEST_MethodC();
|
||||
ClassA.TEST_StaticMethodB();
|
||||
ClassA.TEST_StaticMethodC();
|
||||
*/
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
ClassA ca = scope .();
|
||||
ca.TEST_MethodA();
|
||||
ClassA.TEST_StaticMethodA();
|
||||
DoTest();
|
||||
}
|
||||
}
|
||||
}
|
45
IDE/Tests/Test1/src/Mixins.bf
Normal file
45
IDE/Tests/Test1/src/Mixins.bf
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
|
||||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Mixins
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
public String mStr;
|
||||
}
|
||||
|
||||
public static mixin MixA(int a)
|
||||
{
|
||||
int b = a + 10;
|
||||
b + 100
|
||||
}
|
||||
|
||||
public static mixin MixB(int a)
|
||||
{
|
||||
int c = MixA!(a + 10000);
|
||||
int d = MixA!(a + 20000);
|
||||
int e = MixA!(a + 30000);
|
||||
}
|
||||
|
||||
public static mixin MixC(int a)
|
||||
{
|
||||
int b = 100;
|
||||
MixB!(b);
|
||||
MixB!(b + 1000);
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
ClassA ca = scope .();
|
||||
ca.mStr = new String("Boof");
|
||||
|
||||
DeleteAndNullify!(ca.mStr);
|
||||
int a = 123;
|
||||
MixC!(1);
|
||||
}
|
||||
}
|
||||
}
|
79
IDE/Tests/Test1/src/Multithread.bf
Normal file
79
IDE/Tests/Test1/src/Multithread.bf
Normal file
|
@ -0,0 +1,79 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System.Threading;
|
||||
using System;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Multithread
|
||||
{
|
||||
public bool mDone;
|
||||
public WaitEvent mStartedProc = new WaitEvent() ~ delete _;
|
||||
|
||||
//TODO: Doesn't work with anything other than 0
|
||||
[ThreadStatic]
|
||||
public static int sLocalVal = 0;
|
||||
|
||||
public void DoRecurse(int depth, ref int val)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
++val;
|
||||
if (val < 5)
|
||||
{
|
||||
DoRecurse(depth + 1, ref val);
|
||||
}
|
||||
}
|
||||
|
||||
public void ThreadFunc(Object obj)
|
||||
{
|
||||
int threadNum = (int)obj;
|
||||
sLocalVal++;
|
||||
|
||||
String threadName = scope .();
|
||||
Thread.CurrentThread.GetName(threadName);
|
||||
|
||||
mStartedProc.Set();
|
||||
|
||||
//ThreadFunc
|
||||
int val = 0;
|
||||
for (int i < 200)
|
||||
{
|
||||
val = 0; DoRecurse(0, ref val);
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//MultithreadTester_Test
|
||||
bool doTest = false;
|
||||
if (!doTest)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Multithread mt = scope Multithread();
|
||||
|
||||
Thread threadA = scope .(new => mt.ThreadFunc);
|
||||
threadA.SetName("ThreadA");
|
||||
threadA.Start(0, false);
|
||||
mt.mStartedProc.WaitFor();
|
||||
|
||||
Thread threadB = scope .(new => mt.ThreadFunc);
|
||||
threadB.SetName("ThreadB");
|
||||
threadB.Start(1, false);
|
||||
mt.mStartedProc.WaitFor();
|
||||
|
||||
Thread threadC = scope .(new => mt.ThreadFunc);
|
||||
threadC.SetName("ThreadC");
|
||||
threadC.Start(2, false);
|
||||
mt.mStartedProc.WaitFor();
|
||||
|
||||
threadA.Join();
|
||||
threadB.Join();
|
||||
threadC.Join();
|
||||
|
||||
int a = 99;
|
||||
}
|
||||
}
|
||||
}
|
71
IDE/Tests/Test1/src/Multithread02.bf
Normal file
71
IDE/Tests/Test1/src/Multithread02.bf
Normal file
|
@ -0,0 +1,71 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System.Threading;
|
||||
using System;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Multithread02
|
||||
{
|
||||
public static WaitEvent sEvent0 = new WaitEvent() ~ delete _;
|
||||
public static WaitEvent sEvent1 = new WaitEvent() ~ delete _;
|
||||
public static int sVal0;
|
||||
public static int sVal1;
|
||||
|
||||
class ClassA
|
||||
{
|
||||
public int mA;
|
||||
|
||||
[AlwaysInclude]
|
||||
public int GetValWithWait()
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
return mA;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Thread1()
|
||||
{
|
||||
Thread.CurrentThread.SetName("Test_Thread1");
|
||||
|
||||
ClassA ca = scope .();
|
||||
ca.mA = 100;
|
||||
Thread.Sleep(100);
|
||||
|
||||
//Thread1_0
|
||||
sEvent0.Set();
|
||||
Interlocked.Increment(ref sVal1);
|
||||
sEvent1.WaitFor();
|
||||
|
||||
//Thread1_1
|
||||
Interlocked.Increment(ref sVal1);
|
||||
}
|
||||
|
||||
public static void DoTest()
|
||||
{
|
||||
ClassA ca = scope .();
|
||||
ca.mA = 9;
|
||||
|
||||
Thread thread1 = scope .(new => Thread1);
|
||||
thread1.Start(false);
|
||||
Interlocked.Increment(ref sVal0);
|
||||
Thread.Sleep(500);
|
||||
Interlocked.Increment(ref sVal0);
|
||||
|
||||
sEvent0.WaitFor();
|
||||
sEvent1.Set();
|
||||
|
||||
thread1.Join();
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
bool doTest = false;
|
||||
if (doTest)
|
||||
{
|
||||
DoTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
35
IDE/Tests/Test1/src/Program.bf
Normal file
35
IDE/Tests/Test1/src/Program.bf
Normal file
|
@ -0,0 +1,35 @@
|
|||
namespace IDETest
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Assembly.Test();
|
||||
Break.Test();
|
||||
Breakpoints.Test();
|
||||
Breakpoints02.Test();
|
||||
EnumTester.Test();
|
||||
HotTester.Test();
|
||||
HotSwap_BaseChange.Test();
|
||||
HotSwap_Data.Test();
|
||||
HotSwap_GetUnusued.Test();
|
||||
HotSwap_Interfaces2.Test();
|
||||
HotSwap_Reflection.Test();
|
||||
HotSwap_TLS.Test();
|
||||
InlineTester.Test();
|
||||
LambdaTester.Test();
|
||||
Methods.Test();
|
||||
Mixins.Test();
|
||||
Multithread.Test();
|
||||
Multithread02.Test();
|
||||
MemoryBreakpointTester.Test();
|
||||
SplatTester.Test();
|
||||
Stepping_Scope.Test();
|
||||
Unions.Test();
|
||||
Virtuals.Test();
|
||||
|
||||
Bug001.Test();
|
||||
Bug002.Test();
|
||||
}
|
||||
}
|
||||
}
|
48
IDE/Tests/Test1/src/Splats.bf
Normal file
48
IDE/Tests/Test1/src/Splats.bf
Normal file
|
@ -0,0 +1,48 @@
|
|||
namespace IDETest
|
||||
{
|
||||
struct SplatA
|
||||
{
|
||||
public int mA;
|
||||
}
|
||||
|
||||
struct SplatB : SplatA
|
||||
{
|
||||
public float mB;
|
||||
}
|
||||
|
||||
struct SplatC : SplatB
|
||||
{
|
||||
public char8 mC;
|
||||
|
||||
public void DoTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public float GetB()
|
||||
{
|
||||
return mB;
|
||||
}
|
||||
}
|
||||
|
||||
class SplatTester
|
||||
{
|
||||
public static int GetC(SplatC sc)
|
||||
{
|
||||
return sc.mA;
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
SplatC sc = .();
|
||||
sc.mA = 123;
|
||||
sc.mB = 1.2f;
|
||||
sc.mC = 'Z';
|
||||
|
||||
//SplatTester_SplatC_Call
|
||||
sc.DoTest();
|
||||
sc.GetB();
|
||||
GetC(sc);
|
||||
}
|
||||
}
|
||||
}
|
55
IDE/Tests/Test1/src/Stepping_Scope.bf
Normal file
55
IDE/Tests/Test1/src/Stepping_Scope.bf
Normal file
|
@ -0,0 +1,55 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Stepping_Scope
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
public ~this()
|
||||
{
|
||||
int b = 99;
|
||||
}
|
||||
}
|
||||
|
||||
static void Test1(int inVal)
|
||||
{
|
||||
int a = 1;
|
||||
var ca = scope ClassA();
|
||||
|
||||
if (inVal == 0)
|
||||
{
|
||||
a = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
a = 3;
|
||||
//Stepping_Scope_Test1_Leave
|
||||
}
|
||||
|
||||
static void Test2(int inVal)
|
||||
{
|
||||
int a = 1;
|
||||
|
||||
if (inVal == 0)
|
||||
{
|
||||
var ca = scope:: ClassA();
|
||||
a = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
a = 3;
|
||||
//Stepping_Scope_Test1_Leave
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Stepping_Scope_Test_Start
|
||||
Test1(0);
|
||||
Test1(1);
|
||||
|
||||
Test2(0);
|
||||
Test2(1);
|
||||
}
|
||||
}
|
||||
}
|
58
IDE/Tests/Test1/src/Unions.bf
Normal file
58
IDE/Tests/Test1/src/Unions.bf
Normal file
|
@ -0,0 +1,58 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Unions
|
||||
{
|
||||
struct InnerA
|
||||
{
|
||||
public int32 mInt0;
|
||||
public int32 mInt1;
|
||||
}
|
||||
|
||||
struct InnerB
|
||||
{
|
||||
public InnerA mInnerA;
|
||||
}
|
||||
|
||||
[Union]
|
||||
struct UStruct
|
||||
{
|
||||
public InnerB mInnerB;
|
||||
}
|
||||
|
||||
[Union]
|
||||
struct UStruct2
|
||||
{
|
||||
public InnerB mInnerB;
|
||||
public int64 mFullInt;
|
||||
}
|
||||
|
||||
public static void UseUnion(UStruct us)
|
||||
{
|
||||
int a = us.mInnerB.mInnerA.mInt0;
|
||||
int b = us.mInnerB.mInnerA.mInt1;
|
||||
}
|
||||
|
||||
public static void UseUnion2(UStruct2 us)
|
||||
{
|
||||
int a2 = us.mInnerB.mInnerA.mInt0;
|
||||
int b2 = us.mInnerB.mInnerA.mInt1;
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
UStruct us;
|
||||
us.mInnerB.mInnerA.mInt0 = 12;
|
||||
us.mInnerB.mInnerA.mInt1 = 23;
|
||||
UseUnion(us);
|
||||
|
||||
UStruct2 us2;
|
||||
us2..mFullInt = 0x11223344'55667788;
|
||||
UseUnion2(us2);
|
||||
}
|
||||
}
|
||||
}
|
99
IDE/Tests/Test1/src/Virtuals.bf
Normal file
99
IDE/Tests/Test1/src/Virtuals.bf
Normal file
|
@ -0,0 +1,99 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class Virtuals
|
||||
{
|
||||
|
||||
class ClassA
|
||||
{
|
||||
public virtual int GetA(int a)
|
||||
{
|
||||
return a + 1000;
|
||||
}
|
||||
|
||||
public virtual int Korf
|
||||
{
|
||||
get
|
||||
{
|
||||
return 123;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface IFaceA
|
||||
{
|
||||
int GetA()
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
}
|
||||
|
||||
interface IFaceB
|
||||
{
|
||||
int GetB()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
}
|
||||
|
||||
interface IFaceC
|
||||
{
|
||||
int GetC()
|
||||
{
|
||||
return 33;
|
||||
}
|
||||
}
|
||||
|
||||
interface IFaceD
|
||||
{
|
||||
int GetD()
|
||||
{
|
||||
return 44;
|
||||
}
|
||||
}
|
||||
|
||||
//#define A
|
||||
|
||||
class ClassB : ClassA
|
||||
/*ClassA_IFaces
|
||||
, IFaceA, IFaceB, IFaceC, IFaceD
|
||||
*/
|
||||
{
|
||||
public override int GetA(int a)
|
||||
{
|
||||
PrintF("Skoof GetA\n");
|
||||
return a + 2000;
|
||||
}
|
||||
|
||||
public override int Korf
|
||||
{
|
||||
get
|
||||
{
|
||||
PrintF("Skoof Korf\n");
|
||||
return 234;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
ClassB cb = scope .();
|
||||
ClassA ca = cb;
|
||||
/*Test_IFaces
|
||||
IFaceA ia = cb;
|
||||
ia.GetA();
|
||||
IFaceB ib = cb;
|
||||
ib.GetB();
|
||||
IFaceC ic = cb;
|
||||
ic.GetC();
|
||||
IFaceD id = cb;
|
||||
id.GetD();
|
||||
*/
|
||||
|
||||
//Test_Start
|
||||
int c = ca.GetA(99);
|
||||
int d = ca.Korf;
|
||||
}
|
||||
}
|
||||
}
|
32
IDE/Tests/Test1/src/bugs/Bug001.bf
Normal file
32
IDE/Tests/Test1/src/bugs/Bug001.bf
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
|
||||
class Bug001
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
public String mStrA;
|
||||
public String mStrB;
|
||||
public bool mCheck;
|
||||
|
||||
public void DoTest()
|
||||
{
|
||||
int a = 123;
|
||||
int b = 234;
|
||||
if (mCheck)
|
||||
return;
|
||||
|
||||
//Bug001_DoTest
|
||||
while (mCheck)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
ClassA ca = scope .();
|
||||
ca.DoTest();
|
||||
}
|
||||
}
|
23
IDE/Tests/Test1/src/bugs/Bug002.bf
Normal file
23
IDE/Tests/Test1/src/bugs/Bug002.bf
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
|
||||
class Bug002
|
||||
{
|
||||
public static void Parse(String[] strs)
|
||||
{
|
||||
for (let val in strs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int val2 = 999;
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
var strs = scope String[] {"aaa", "bbb", "ccc"};
|
||||
//Bug002_DoTest
|
||||
Parse(strs);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue