mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
New tests
This commit is contained in:
parent
b3cc0b5be4
commit
fc063a65c1
3 changed files with 57 additions and 0 deletions
|
@ -21,5 +21,12 @@ namespace Tests
|
|||
Test.Assert(Math.Min((int64)-1, (int64)0) == -1);
|
||||
Test.Assert(Math.Max((int64)-1, (int64)0) == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestLiterals()
|
||||
{
|
||||
Test.Assert(0b0111010110111100110100010101 == 123456789);
|
||||
Test.Assert(0o726746425 == 123456789);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,5 +36,42 @@ namespace Tests
|
|||
int result = Add3(() => a++);
|
||||
Test.Assert(result == 63);
|
||||
}
|
||||
|
||||
[Test]
|
||||
static void LambdaWithDtor()
|
||||
{
|
||||
int a = 10;
|
||||
int b = 20;
|
||||
|
||||
//
|
||||
{
|
||||
delegate void() dlg = scope [&] () =>
|
||||
{
|
||||
a++;
|
||||
}
|
||||
~
|
||||
{
|
||||
b++;
|
||||
};
|
||||
dlg();
|
||||
}
|
||||
|
||||
Test.Assert(a == 11);
|
||||
Test.Assert(b == 21);
|
||||
|
||||
delegate void() dlg = new [&] () =>
|
||||
{
|
||||
a += 100;
|
||||
}
|
||||
~
|
||||
{
|
||||
b += 200;
|
||||
};
|
||||
dlg();
|
||||
Test.Assert(a == 111);
|
||||
Test.Assert(b == 21);
|
||||
delete dlg;
|
||||
Test.Assert(b == 221);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,16 @@ namespace Tests
|
|||
{
|
||||
mA += addTo;
|
||||
}
|
||||
|
||||
public mixin MixB(var addTo)
|
||||
{
|
||||
void AddIt()
|
||||
{
|
||||
mA += addTo;
|
||||
}
|
||||
|
||||
AddIt();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -20,6 +30,8 @@ namespace Tests
|
|||
MixClass mc = scope MixClass();
|
||||
mc.MixA!(10);
|
||||
Test.Assert(mc.mA == 110);
|
||||
mc.MixB!(10);
|
||||
Test.Assert(mc.mA == 120);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -43,5 +55,6 @@ namespace Tests
|
|||
Test.Assert(str0 == null);
|
||||
Test.Assert(str1 == "AB");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue