mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
Beefy::String changes, lambda hotswap fixes
Changed some string internals related to StringViewsma Added an "incompatible capture" error for lambdas when the captures change
This commit is contained in:
parent
767a3fafd9
commit
2f01cc14dd
25 changed files with 544 additions and 180 deletions
|
@ -27,7 +27,7 @@ TargetDirectory = "$(WorkspaceDir)/dist"
|
|||
TargetName = "BeefIDE_d"
|
||||
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib"
|
||||
CLibType = "Dynamic"
|
||||
DebugCommandArguments = "-proddir=C:\\Beef\\IDE\\Tests\\Test1 -platform=Win32 -test=scripts\\Break.txt -testNoExit"
|
||||
DebugCommandArguments = "-proddir=C:\\Beef\\IDE\\Tests\\Test1 -test=scripts\\HotSwap_Lambdas01.txt -testNoExit"
|
||||
DebugWorkingDirectory = "c:\\Beef\\IDE\\Tests\\EmptyTest"
|
||||
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
||||
|
||||
|
|
28
IDE/Tests/Test1/scripts/HotSwap_Lambdas01.txt
Normal file
28
IDE/Tests/Test1/scripts/HotSwap_Lambdas01.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
# This tests modifying anonymous lambdas, including changing captured data (both legally and illegally)
|
||||
|
||||
ShowFile("src/HotSwap_Lambdas01.bf")
|
||||
GotoText("//Test_Start")
|
||||
ToggleBreakpoint()
|
||||
RunWithCompiling()
|
||||
|
||||
StepOver()
|
||||
StepOver()
|
||||
StepOver()
|
||||
StepOver()
|
||||
AssertEvalEquals("val0", "200")
|
||||
AssertEvalEquals("val1", "423")
|
||||
AssertEvalEquals("val2", "757")
|
||||
|
||||
ToggleCommentAt("Dlg0_0")
|
||||
ToggleCommentAt("Dlg1_0")
|
||||
ToggleCommentAt("Dlg2_0")
|
||||
Compile()
|
||||
SetExpectError("incompatible captures")
|
||||
StepOver()
|
||||
ExpectError()
|
||||
StepOut()
|
||||
StepOver()
|
||||
StepOver()
|
||||
AssertEvalEquals("val0", "200")
|
||||
AssertEvalEquals("val1", "300")
|
||||
AssertEvalEquals("val2", "523")
|
62
IDE/Tests/Test1/src/HotSwap_Lambdas01.bf
Normal file
62
IDE/Tests/Test1/src/HotSwap_Lambdas01.bf
Normal file
|
@ -0,0 +1,62 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
namespace IDETest
|
||||
{
|
||||
class HotSwap_Lambdas01
|
||||
{
|
||||
class ClassA
|
||||
{
|
||||
public delegate int() mDlg0 ~ delete _;
|
||||
public delegate int() mDlg1 ~ delete _;
|
||||
public delegate int() mDlg2 ~ delete _;
|
||||
|
||||
int mA = 123;
|
||||
|
||||
public this()
|
||||
{
|
||||
int val = 234;
|
||||
|
||||
mDlg0 = new () =>
|
||||
{
|
||||
int ret = 200;
|
||||
/*Dlg0_0
|
||||
ret += mA;
|
||||
*/
|
||||
return ret;
|
||||
};
|
||||
|
||||
mDlg1 = new () =>
|
||||
{
|
||||
int ret = 300;
|
||||
//*Dlg1_0
|
||||
ret += mA;
|
||||
/*@*/
|
||||
return ret;
|
||||
};
|
||||
|
||||
mDlg2 = new () =>
|
||||
{
|
||||
int ret = 400;
|
||||
//*Dlg2_0
|
||||
ret += val;
|
||||
/*@*/
|
||||
ret += mA;
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
//Test_Start
|
||||
ClassA ca = scope .();
|
||||
int val0 = ca.mDlg0();
|
||||
int val1 = ca.mDlg1();
|
||||
int val2 = ca.mDlg2();
|
||||
|
||||
val0 = ca.mDlg0();
|
||||
val1 = ca.mDlg1();
|
||||
val2 = ca.mDlg2();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ namespace IDETest
|
|||
HotSwap_Data.Test();
|
||||
HotSwap_GetUnusued.Test();
|
||||
HotSwap_Interfaces2.Test();
|
||||
HotSwap_Lambdas01.Test();
|
||||
HotSwap_LocateSym01.Test();
|
||||
HotSwap_Reflection.Test();
|
||||
HotSwap_TLS.Test();
|
||||
|
|
|
@ -10,7 +10,6 @@ IntermediateType = "ObjectAndIRCode"
|
|||
ConfigSelections = {mintest2 = {Enabled = false}}
|
||||
|
||||
[Configs.Debug.Win64]
|
||||
BfOptimizationLevel = "O0"
|
||||
IntermediateType = "ObjectAndIRCode"
|
||||
COptimizationLevel = "Og"
|
||||
|
||||
|
|
|
@ -87,85 +87,37 @@ struct TestStruct
|
|||
public int mB;
|
||||
}
|
||||
|
||||
class Bloozer
|
||||
{
|
||||
int mA;
|
||||
}
|
||||
|
||||
class Blurg
|
||||
{
|
||||
[Export, CLink, StdCall]
|
||||
public static void Poof()
|
||||
{
|
||||
PrintF("Poofs!\n");
|
||||
}
|
||||
|
||||
[Export, CLink, StdCall]
|
||||
public static void Poof2()
|
||||
{
|
||||
PrintF("Poofs2!\n");
|
||||
}
|
||||
|
||||
static void Test0()
|
||||
{
|
||||
Snorf sn = scope .();
|
||||
int a = 124;
|
||||
}
|
||||
|
||||
|
||||
public void DoRecurse(int depth, ref int val)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
++val;
|
||||
if (val < 5)
|
||||
{
|
||||
DoRecurse(depth + 1, ref val);
|
||||
}
|
||||
}
|
||||
|
||||
public static void VoidCall()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static int GetInt()
|
||||
{
|
||||
float f = 10.0f;
|
||||
//f = f % 3.0f;
|
||||
|
||||
return 123;
|
||||
}
|
||||
|
||||
delegate void() mFuncA;
|
||||
delegate void() mFuncB;
|
||||
|
||||
public static void Hey()
|
||||
{
|
||||
float f = 1.2f;
|
||||
//f = f % 2.3f;
|
||||
int a = 123;
|
||||
Blurg blurg = scope .();
|
||||
blurg.mFuncA = new () =>
|
||||
{
|
||||
PrintF("YoA!\n");
|
||||
PrintF("A %d!\n", a);
|
||||
PrintF("Blurg: %p\n", blurg);
|
||||
};
|
||||
|
||||
TestStruct ts = .();
|
||||
//int val = ts..mA;
|
||||
ts.mA = 123;
|
||||
blurg.mFuncB = new () =>
|
||||
{
|
||||
PrintF("YoB!\n");
|
||||
};
|
||||
|
||||
GetInt();
|
||||
GetInt();
|
||||
|
||||
VoidCall();
|
||||
int val0 = GetInt();
|
||||
|
||||
Blurg bl = scope .();
|
||||
int val = 0;
|
||||
bl.DoRecurse(0, ref val);
|
||||
|
||||
Test0();
|
||||
Test0();
|
||||
Test0();
|
||||
Test0();
|
||||
|
||||
Result<void*> voidPtrResult = default;
|
||||
|
||||
//void* val = voidPtrResult;
|
||||
|
||||
|
||||
//Result<TestStruct> ts = .Ok(.());
|
||||
|
||||
//let val = ts.Get();
|
||||
//Snorf.Bloog bl = .();
|
||||
|
||||
//Poof();
|
||||
while (true)
|
||||
{
|
||||
blurg.mFuncA();
|
||||
blurg.mFuncB();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3051,7 +3051,7 @@ namespace IDE
|
|||
|
||||
if (mRunningTestScript)
|
||||
{
|
||||
if ((mScriptManager.mExpectingError != null) && (text.Contains(mScriptManager.mExpectingError)))
|
||||
if (mScriptManager.IsErrorExpected(text))
|
||||
{
|
||||
DeleteAndNullify!(mScriptManager.mExpectingError);
|
||||
OutputLine("Received expected error: {0}", text);
|
||||
|
@ -10479,7 +10479,7 @@ namespace IDE
|
|||
}
|
||||
else if (cmd == "error")
|
||||
{
|
||||
if ((mRunningTestScript) && (!IsCrashDump))
|
||||
if ((mRunningTestScript) && (!IsCrashDump) && (!mScriptManager.IsErrorExpected(param)))
|
||||
mScriptManager.Fail(param);
|
||||
|
||||
bool isFirstMsg = true;
|
||||
|
@ -10553,7 +10553,6 @@ namespace IDE
|
|||
if (isFirstMsg)
|
||||
{
|
||||
OutputLineSmart(scope String("ERROR: ", errorMsg));
|
||||
Fail(errorMsg);
|
||||
isFirstMsg = false;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -177,6 +177,11 @@ namespace IDE
|
|||
//gApp.mRunningTestScript = false;
|
||||
}
|
||||
|
||||
public bool IsErrorExpected(StringView err)
|
||||
{
|
||||
return (mExpectingError != null) && (err.Contains(mExpectingError));
|
||||
}
|
||||
|
||||
public void Fail(StringView fmt, params Object[] args)
|
||||
{
|
||||
Fail(scope String()..AppendF(fmt, params args));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue