mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Lost changes
This commit is contained in:
parent
e6c4a95ccd
commit
8e9d7ed4c4
56 changed files with 1579 additions and 794 deletions
|
@ -80,6 +80,21 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
[IFaceA("C", InitVal=345)]
|
||||
struct StructA
|
||||
{
|
||||
public int mA = 123;
|
||||
|
||||
[OnCompile(.TypeInit), Comptime]
|
||||
public static void Generate()
|
||||
{
|
||||
Compiler.EmitTypeBody(typeof(Self), """
|
||||
public int32 mB = 234;
|
||||
public int32 GetValB() => mB;
|
||||
""");
|
||||
}
|
||||
}
|
||||
|
||||
enum MethodAErr
|
||||
{
|
||||
ErrorA,
|
||||
|
@ -168,6 +183,13 @@ namespace Tests
|
|||
Test.Assert(ca.mC == 345);
|
||||
Test.Assert(ca.GetValC() == 345);
|
||||
|
||||
StructA sa = .();
|
||||
Test.Assert(sa.mA == 123);
|
||||
Test.Assert(sa.mB == 234);
|
||||
Test.Assert(sa.GetValB() == 234);
|
||||
Test.Assert(sa.mC == 345);
|
||||
Test.Assert(sa.GetValC() == 345);
|
||||
|
||||
Compiler.Mixin("int val = 99;");
|
||||
Test.Assert(val == 99);
|
||||
|
||||
|
|
|
@ -160,6 +160,32 @@ namespace Tests
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
class ClassF
|
||||
{
|
||||
public static int sVal = 3;
|
||||
|
||||
public int mF0 = 1 ~
|
||||
{
|
||||
sVal += 40;
|
||||
};
|
||||
}
|
||||
|
||||
extension ClassF
|
||||
{
|
||||
public int mF1 = 2 ~
|
||||
{
|
||||
sVal += 500;
|
||||
};
|
||||
}
|
||||
|
||||
class ClassG : ClassF
|
||||
{
|
||||
public int mG0 = 3 ~
|
||||
{
|
||||
sVal += 6000;
|
||||
};
|
||||
}
|
||||
|
||||
extension TClassA<T> where T : IGetExVal
|
||||
{
|
||||
|
@ -226,6 +252,26 @@ namespace Tests
|
|||
ClassE ce = scope .();
|
||||
Test.Assert(ce.mD == 1);
|
||||
Test.Assert(ce.mE == 1);
|
||||
|
||||
///
|
||||
{
|
||||
ClassF cf = scope .();
|
||||
}
|
||||
Test.Assert(ClassF.sVal == 543);
|
||||
///
|
||||
{
|
||||
ClassF.sVal = 3;
|
||||
ClassG cg = scope .();
|
||||
}
|
||||
Test.Assert(ClassF.sVal == 6543);
|
||||
ClassF.sVal = 3;
|
||||
Object obj = new ClassF();
|
||||
delete obj;
|
||||
Test.Assert(ClassF.sVal == 543);
|
||||
ClassF.sVal = 3;
|
||||
obj = new ClassG();
|
||||
delete obj;
|
||||
Test.Assert(ClassF.sVal == 6543);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -95,6 +95,16 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
class IFaceA<T0, T1> where T0 : Dictionary<T1, int> where T1 : IHashable
|
||||
{
|
||||
Dictionary<T1, int> mDict;
|
||||
}
|
||||
|
||||
public static void MethodA<T0, T1>() where T0 : Dictionary<T1, int> where T1 : IHashable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
|
|
|
@ -239,6 +239,32 @@ namespace Tests
|
|||
switch (methodIdx)
|
||||
{
|
||||
case 0:
|
||||
Test.Assert(methodInfo.Name == "__BfCtor");
|
||||
Test.Assert(methodInfo.IsConstructor);
|
||||
case 1:
|
||||
Test.Assert(methodInfo.Name == "__BfStaticCtor");
|
||||
Test.Assert(methodInfo.IsConstructor);
|
||||
case 2:
|
||||
Test.Assert(methodInfo.Name == "GetA");
|
||||
var result = methodInfo.Invoke(ca, 123).Get();
|
||||
Test.Assert(result.Get<int>() == 1123);
|
||||
result.Dispose();
|
||||
result = methodInfo.Invoke(ca2, 123).Get();
|
||||
Test.Assert(result.Get<int>() == 2123);
|
||||
result.Dispose();
|
||||
result = methodInfo.Invoke(.Create(ca2), .Create(123)).Get();
|
||||
Test.Assert(result.Get<int>() == 2123);
|
||||
result.Dispose();
|
||||
case 3:
|
||||
Test.Assert(methodInfo.Name == "MemberMethodA");
|
||||
var result = methodInfo.Invoke(ca, 100, (int32)20, 3.0f).Get();
|
||||
Test.Assert(result.Get<float>() == 123);
|
||||
result.Dispose();
|
||||
|
||||
result = methodInfo.Invoke(.Create(ca), .Create(100), .Create((int32)20), .Create(3.0f)).Get();
|
||||
Test.Assert(result.Get<float>() == 123);
|
||||
result.Dispose();
|
||||
case 4:
|
||||
StructA sa = .() { mA = 1, mB = 2 };
|
||||
|
||||
Test.Assert(methodInfo.Name == "StaticMethodA");
|
||||
|
@ -291,7 +317,7 @@ namespace Tests
|
|||
let attrC = methodInfo.GetCustomAttribute<AttrCAttribute>().Get();
|
||||
Test.Assert(attrC.mA == 71);
|
||||
Test.Assert(attrC.mB == 72);
|
||||
case 1:
|
||||
case 5:
|
||||
Test.Assert(methodInfo.Name == "StaticMethodB");
|
||||
|
||||
var fieldA = typeInfo.GetField("mA").Value;
|
||||
|
@ -337,33 +363,6 @@ namespace Tests
|
|||
res.Dispose();
|
||||
fieldSAV.Dispose();
|
||||
fieldSStrV.Dispose();
|
||||
|
||||
case 2:
|
||||
Test.Assert(methodInfo.Name == "MemberMethodA");
|
||||
var result = methodInfo.Invoke(ca, 100, (int32)20, 3.0f).Get();
|
||||
Test.Assert(result.Get<float>() == 123);
|
||||
result.Dispose();
|
||||
|
||||
result = methodInfo.Invoke(.Create(ca), .Create(100), .Create((int32)20), .Create(3.0f)).Get();
|
||||
Test.Assert(result.Get<float>() == 123);
|
||||
result.Dispose();
|
||||
case 3:
|
||||
Test.Assert(methodInfo.Name == "GetA");
|
||||
var result = methodInfo.Invoke(ca, 123).Get();
|
||||
Test.Assert(result.Get<int>() == 1123);
|
||||
result.Dispose();
|
||||
result = methodInfo.Invoke(ca2, 123).Get();
|
||||
Test.Assert(result.Get<int>() == 2123);
|
||||
result.Dispose();
|
||||
result = methodInfo.Invoke(.Create(ca2), .Create(123)).Get();
|
||||
Test.Assert(result.Get<int>() == 2123);
|
||||
result.Dispose();
|
||||
case 4:
|
||||
Test.Assert(methodInfo.Name == "__BfStaticCtor");
|
||||
Test.Assert(methodInfo.IsConstructor);
|
||||
case 5:
|
||||
Test.Assert(methodInfo.Name == "__BfCtor");
|
||||
Test.Assert(methodInfo.IsConstructor);
|
||||
case 6:
|
||||
Test.FatalError(); // Shouldn't have any more
|
||||
}
|
||||
|
@ -445,6 +444,8 @@ namespace Tests
|
|||
switch (methodIdx)
|
||||
{
|
||||
case 0:
|
||||
Test.Assert(methodInfo.Name == "__BfCtor");
|
||||
case 1:
|
||||
Test.Assert(methodInfo.Name == "GetA");
|
||||
|
||||
var result = methodInfo.Invoke(sa, 34).Get();
|
||||
|
@ -464,7 +465,7 @@ namespace Tests
|
|||
result = methodInfo.Invoke(.Create(&sa), .Create(34));
|
||||
Test.Assert(result.Get<int32>() == 1234);
|
||||
result.Dispose();
|
||||
case 1:
|
||||
case 2:
|
||||
Test.Assert(methodInfo.Name == "GetB");
|
||||
|
||||
var result = methodInfo.Invoke(sa, 34).Get();
|
||||
|
@ -489,16 +490,15 @@ namespace Tests
|
|||
Test.Assert(sa.mB == 91);
|
||||
result.Dispose();
|
||||
|
||||
case 2:
|
||||
Test.Assert(methodInfo.Name == "MethodA0");
|
||||
case 3:
|
||||
Test.Assert(methodInfo.Name == "MethodA1");
|
||||
Test.Assert(methodInfo.Name == "MethodA0");
|
||||
case 4:
|
||||
Test.Assert(methodInfo.Name == "__BfCtor");
|
||||
Test.Assert(methodInfo.Name == "MethodA1");
|
||||
case 5:
|
||||
Test.Assert(methodInfo.Name == "__Equals");
|
||||
case 6:
|
||||
Test.Assert(methodInfo.Name == "__StrictEquals");
|
||||
|
||||
default:
|
||||
Test.FatalError(); // Shouldn't have any more
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue