Skip to content

Commit

Permalink
added suitable testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
sorin-gabriel committed Oct 11, 2021
1 parent 1018cab commit e6d32b9
Showing 1 changed file with 61 additions and 18 deletions.
79 changes: 61 additions & 18 deletions test/compilable/b19294.d
@@ -1,26 +1,69 @@
import std.stdio;
import std.complex;
alias MT = MyStruct!int;

void main()
struct MyStruct(T)
{
alias T = Complex!float;
T x;

T iV = complex(1.0f, 1.0f);
T[] arr = [iV, 2 * iV, 3 * iV, 4 * iV, 5 * iV, 6 * iV];
Complex!float[] result = new T[arr.length];
this(T y)
{
x = y;
}

MyStruct!T opBinary(string op)(MyStruct!T y) const
{
alias C = typeof(return);
auto w = C(this.x);
return w.opOpAssign!(op)(y);
}

MyStruct!T opBinaryRight(string op)(MyStruct!T y) const
{
return opBinary!(op)(y);
}

ref MyStruct opOpAssign(string op, T)(const MyStruct!T z)
{
mixin ("x "~op~"= z.x;");
return this;
}

MyStruct!T opBinary(string op)(T y) const
{
alias C = typeof(return);
auto w = C(this.x);
return w.opOpAssign!(op)(y);
}

MyStruct!T opBinaryRight(string op)(T y) const
{
return opBinary!(op)(y);
}

ref MyStruct opOpAssign(string op, T)(const T z)
{
mixin ("x "~op~"= z;");
return this;
}
}

void test()
{
MT s = MyStruct!int(1);
MT[] arr = [s, 2 * s, 3 * s, 4 * s, 5 * s, 6 * s];
MT[] result = new MT[arr.length];

result[] = arr[] + iV;
result[] = iV + arr[];
result[] = arr[] + s;
result[] = s + arr[];

result[] = arr[] - iV;
result[] = iV - arr[];
result[] = arr[] - s;
result[] = s - arr[];

result[] = arr[] * iV;
result[] = iV * arr[];
result[] = arr[] * s;
result[] = s * arr[];

result[] = arr[] / iV;
result[] = iV / arr[];
result[] = arr[] / s;
result[] = s / arr[];

result[] = arr[] ^^ iV;
result[] = iV ^^ arr[];
}
result[] = arr[] ^^ s;
result[] = s ^^ arr[];
}

0 comments on commit e6d32b9

Please sign in to comment.