This commit is contained in:
Alexander Zhirov 2023-02-27 01:22:09 +03:00
parent 1d0a2964cf
commit 151d77ee54
11 changed files with 340 additions and 0 deletions

View file

@ -0,0 +1,29 @@
import std.stdio;
class A
{
int x = 42;
}
unittest
{
{
auto a1 = new A;
assert(a1.x == 42);
auto a2 = a1;
a2.x = 100;
assert(a1.x == 100);
}
{
auto a1 = new A;
auto a2 = new A;
a1.x = 100;
a2.x = 200;
// Заставим a1 и a2 обменяться привязками
auto t = a1;
a1 = a2;
a2 = t;
assert(a1.x == 200);
assert(a2.x == 100);
}
}