1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 23:56:05 +02:00
Beef/IDEHelper/Tests/src/Mixins.bf

48 lines
635 B
Beef
Raw Normal View History

2019-08-23 11:56:54 -07:00
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");
}
}
}