mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-20 08:58:00 +02:00
Initial checkin
This commit is contained in:
parent
c74712dad9
commit
078564ac9e
3242 changed files with 1616395 additions and 0 deletions
47
IDEHelper/Tests/src/Mixins.bf
Normal file
47
IDEHelper/Tests/src/Mixins.bf
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
class Mixins
|
||||
{
|
||||
class MixClass
|
||||
{
|
||||
public int mA = 100;
|
||||
|
||||
public mixin MixA(var addTo)
|
||||
{
|
||||
mA += addTo;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
MixClass mc = scope MixClass();
|
||||
mc.MixA!(10);
|
||||
Test.Assert(mc.mA == 110);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestLocalMixin()
|
||||
{
|
||||
mixin AppendAndNullify(String str)
|
||||
{
|
||||
int a = 1;
|
||||
a++;
|
||||
str.Append("B");
|
||||
str = null;
|
||||
}
|
||||
|
||||
int a = 2;
|
||||
a++;
|
||||
|
||||
String str0 = scope String("A");
|
||||
String str1 = str0;
|
||||
|
||||
AppendAndNullify!(str0);
|
||||
Test.Assert(str0 == null);
|
||||
Test.Assert(str1 == "AB");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue