コード例 #1
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void LessThanTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d < v, false, "#1");
        double v2 = 5;

        Assert(d < v2, false, "#1a");

        d = 4.6;
        Assert(d < 4.59, false, "#2");
        var b2 = 4.6;

        Assert(d < b2, false, "#2a");

        d = new MyType(30);
        MyType v3 = new MyType(30);

        Assert(d < v3, false, "#3");
        dynamic d3 = new MyType(-7);

        Assert(d3 < new MyType(6), true, "#3a");

        d3 = new MyTypeImplicitOnly(-7);
        Assert(d3 < 11, true, "#3b");

        d = 2m;
        decimal v4 = 4m;

        Assert(d < v4, true, "#4");
        Assert(d < 2m, false, "#4a");
    }
コード例 #2
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void ExclusiveOrTest()
    {
        dynamic d = true;

        var v = false;

        Assert(d ^ v, true, "#1");
        Assert(d ^ true, false, "#1a");

        d = 42;
        var v2 = 62;

        Assert(d ^ v2, 20, "#2");
        Assert(d ^ 0, 42, "#2a");

        d = new MyType(42);
        MyType v3 = new MyType(30);

        Assert(d ^ v3, new MyType(52), "#3");
        dynamic d3 = new MyType(-7);

        Assert <MyType> (d3 ^ new MyType(6), new MyType(-1), "#3a");

        d3 = new MyTypeImplicitOnly(-7);
        Assert(d3 ^ 11, -14, "#3b");
    }
コード例 #3
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void GreaterThanEqualTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d >= v, true, "#1");
        double v2 = 5;

        Assert(d >= v2, true, "#1a");

        d = 4.6;
        Assert(d >= 4.59, true, "#2");
        var b2 = 4.6;

        Assert(d >= b2, true, "#2a");

        d = new MyType(30);
        MyType v3 = new MyType(30);

        Assert(d >= v3, true, "#3");
        dynamic d3 = new MyType(-7);

        Assert(d3 >= new MyType(6), false, "#3a");

        d3 = new MyTypeImplicitOnly(-7);
        Assert(d3 >= 11, false, "#3b");

        d = 2m;
        decimal v4 = 4m;

        Assert(d >= v4, false, "#4");
        Assert(d >= 2m, true, "#4a");
    }
コード例 #4
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void LessThanOrEqualTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d <= v, false, "#1");
        double v2 = 5;

        Assert(d <= v2, true, "#1a");

        d = 4.6;
        Assert(d <= 4.59, false, "#2");
        var b2 = 4.6;

        Assert(d <= b2, true, "#2a");

        d = new MyType(30);
        MyType v3 = new MyType(30);

        Assert(d <= v3, true, "#3");
        dynamic d3 = new MyType(-7);

        Assert(d3 <= new MyType(6), true, "#3a");

        d3 = new MyTypeImplicitOnly(-7);
        Assert(d3 <= 11, true, "#3b");

        d = 2m;
        decimal v4 = 4m;

        Assert(d <= v4, true, "#4");
        Assert(d <= 2m, true, "#4a");
    }
コード例 #5
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void OrTest()
    {
        dynamic d = true;

        var v = false;

        Assert(d | v, true, "#1");
        Assert(d | false, true, "#1a");

        d = 42;
        var v2 = 62;

        Assert(d | v2, 62, "#2");
        Assert(d | 0, 42, "#2a");

        d = new MyType(42);
        MyType v3 = new MyType(30);

        Assert(d | v3, new MyType(62), "#3");
        dynamic d3 = new MyType(-7);

        Assert <MyType> (d3 | new MyType(6), new MyType(-1), "#3a");

        d3 = new MyTypeImplicitOnly(-7);
        Assert(d3 | 11, -5, "#3b");
    }
コード例 #6
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
#pragma warning disable 169

    void AddTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d + v, 7, "#1");
        double v2 = 0.5;

        Assert(d + v2, 5.5, "#1a");

        d = new MyType(5);
        MyType v3 = new MyType(30);

        Assert(d + v3, new MyType(35), "#3");
        dynamic d3 = new MyType(-7);

        Assert <MyType> (d3 + new MyType(6), new MyType(-1), "#3a");

        d3 = new MyTypeImplicitOnly(6);
        Assert(d3 + new MyTypeImplicitOnly(11), 17, "#3b");

        d = new MyTypeImplicitOnly(5);
        decimal v4 = 4m;

        Assert(d + v4, 9m, "#4");
    }
コード例 #7
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void AndTest()
    {
        dynamic d = true;

        var v = false;

        Assert(d & v, false, "#1");
        Assert(d & true, true, "#1a");

        d = 42;
        var v2 = 62;

        Assert(d & v2, 42, "#2");
        Assert(d & 0, 0, "#2a");

        d = new MyType(10);
        MyType v3 = new MyType(30);

        Assert(d & v3, new MyType(10), "#3");
        dynamic d3 = new MyType(-7);

        Assert <MyType> (d3 & new MyType(6), new MyType(0), "#3a");

        d3 = new MyTypeImplicitOnly(6);
        Assert(d3 & 11, 2, "#3b");
    }
コード例 #8
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void AddNullableTest()
    {
        dynamic d = 5;

        int?v2 = null;

        Assert <int?> (d + v2, null, "#1");
        Assert <int?> (d + null, null, "#1a");
        Assert <int?> (null + d, null, "#1b");

        v2 = -2;
        Assert(d + v2, 3, "#2");
        dynamic d2 = (int?)-2;

        Assert(d2 + 1, -1, "#2a");

        d = new MyType(5);
        MyType?v3 = new MyType(30);

        Assert(d + v3, new MyType(35), "#3");
        dynamic d3 = new MyType? (new MyType(-7));

        Assert(d3 + new MyType(6), new MyType(-1), "#3a");
        Assert <MyType?> (d3 + null, null, "#3b");

        d = new MyTypeImplicitOnly(5);
        decimal?v4 = 4m;

        Assert(d + v4, 9m, "#4");
        v4 = null;
        Assert <decimal?> (d + v4, null, "#4a");
    }
コード例 #9
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void MultiplyNullableTest()
    {
        dynamic d = 5;

        int?v2 = null;

        Assert <int?> (d * v2, null, "#1");
        Assert <int?> (d * null, null, "#1a");
        Assert <int?> (null * d, null, "#1b");

        v2 = -2;
        Assert(d * v2, -10, "#2");
        dynamic d2 = (int?)-2;

        Assert(d2 * 1, -2, "#2a");

        d = new MyType(5);
        MyType?v3 = new MyType(30);

        Assert(d * v3, new MyType(150), "#3");
        dynamic d3 = new MyType? (new MyType(-7));

        Assert(d3 * new MyType(6), new MyType(-42), "#3a");
        Assert <MyType?> (d3 * null, null, "#3b");

        d = new MyTypeImplicitOnly(5);
        decimal?v4 = 4m;

        Assert(d * v4, 20m, "#4");
        v4 = null;
        Assert <decimal?> (d * v4, null, "#4a");
    }
コード例 #10
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void ModuloNullableTest()
    {
        dynamic d = 5;

        double?v2 = null;

        Assert <double?> (d % v2, null, "#1");
        Assert <double?> (d % null, null, "#1a");
        Assert <double?> (null % d, null, "#1b");

        v2 = -2;
        Assert(d % v2, 1, "#2");
        dynamic d2 = (int?)-2;

        Assert(d2 % 1, 0, "#2a");

        d = new MyType(-2);
        MyType?v3 = new MyType(30);

        Assert(d % v3, new MyType(-2), "#3");
        dynamic d3 = new MyType? (new MyType(-7));

        Assert(d3 % new MyType(6), new MyType(-1), "#3a");
        Assert <MyType?> (d3 + null, null, "#3b");

        d = new MyTypeImplicitOnly(5);
        decimal?v4 = 4m;

        Assert(d % v4, 1m, "#4");
        v4 = null;
        Assert <decimal?> (d % v4, null, "#4a");
    }
コード例 #11
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void DivideNullableTest()
    {
        dynamic d = 5;

        double?v2 = null;

        Assert <double?> (d / v2, null, "#1");
        Assert <double?> (d / null, null, "#1a");
        Assert <double?> (null / d, null, "#1b");

        v2 = -2;
        Assert(d / v2, -2.5, "#2");
        dynamic d2 = (int?)-2;

        Assert(d2 / 1, -2, "#2a");

        d = new MyType(5);
        MyType?v3 = new MyType(30);

        Assert(d / v3, new MyType(0), "#3");
        dynamic d3 = new MyType? (new MyType(-7));

        Assert(d3 / new MyType(6), new MyType(-1), "#3a");
        Assert <MyType?> (d3 + null, null, "#3b");

        d = new MyTypeImplicitOnly(5);
        decimal?v4 = 4m;

        Assert(d / v4, 1.25m, "#4");
        v4 = null;
        Assert <decimal?> (d / v4, null, "#4a");
    }
コード例 #12
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void EqualTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d == v, false, "#1");
        double v2 = 5;

        Assert(d == v2, true, "#1a");

        d = true;
        Assert(d == false, false, "#2");
        bool b2 = true;

        Assert(d == b2, true, "#2a");

        d = new MyType(30);
        MyType v3 = new MyType(30);

        Assert(d == v3, true, "#3");
        dynamic d3 = new MyTypeImplicitOnly(-7);

        Assert(d3 == 11, false, "#3b");

        d = 2m;
        decimal v4 = 4m;

        Assert(d == v4, false, "#4");
        Assert(d == 2m, true, "#4a");

        d = null;
        Assert(d == null, true, "#5");
    }
コード例 #13
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void SubtractNullableTest()
    {
        dynamic d = 5;

        int?v2 = null;

        Assert <int?> (d - v2, null, "#1");
        Assert <int?> (d - null, null, "#1a");
        Assert <int?> (null - d, null, "#1b");

        v2 = -2;
        Assert(d - v2, 7, "#2");
        dynamic d2 = (int?)-2;

        Assert(d2 - 1, -3, "#2a");

        d = new MyType(5);
        MyType?v3 = new MyType(30);

        Assert(d - v3, new MyType(-25), "#3");
        dynamic d3 = new MyType? (new MyType(-7));

        Assert(d3 - new MyType(6), new MyType(-13), "#3a");
        Assert <MyType?> (d3 - null, null, "#3b");

        d = new MyTypeImplicitOnly(5);
        decimal?v4 = 4m;

        Assert(d - v4, 1m, "#4");
        v4 = null;
        Assert <decimal?> (d - v4, null, "#4a");
    }
コード例 #14
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void UnaryPlus()
    {
        dynamic d = -8;

        Assert(-8, +d, "#1");
        Assert(-8, +(+d), "#1a");

        d = new MyType(14);
        Assert(new MyType(334455), +d, "#2");

        d = new MyTypeImplicitOnly(4);
        Assert(4, +d, "#3");

        d = (uint)7;
        Assert <uint> (7, +d, "#4");
    }
コード例 #15
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void Negate()
    {
        dynamic d = -8;

        Assert(8, -d, "#1");
        Assert(-8, -(-d), "#1a");

        d = new MyType(-14);
        Assert(new MyType(14), -d, "#2");

        d = new MyTypeImplicitOnly(4);
        Assert(-4, -d, "#3");

        d = (uint)7;
        Assert(-7, -d, "#4");

        d = double.NegativeInfinity;
        Assert(double.PositiveInfinity, -d, "#5");
    }
コード例 #16
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void ConvertExplicitTest()
    {
        dynamic d = 300;

        Assert(44, (byte)d, "#1");
        Assert <byte?> (44, (byte?)d, "#1a");

        d = 3m;
        Assert(3, d, "#2");

        d = new MyTypeImplicitOnly(5);
        Assert(5, (int)d, "#3");

        d = new MyTypeExplicit(-2);
        Assert(-2, (int)d, "#4");

        d = null;
        Assert(null, (object)d, "#5");
    }
コード例 #17
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void ConvertImplicitTest()
    {
        dynamic d  = 3;
        decimal v1 = d;

        Assert(3m, v1, "#1");

        d = new MyTypeImplicitOnly(5);
        int v2 = d;

        Assert(5, v2, "#2");

        d = (byte)4;
        int v3 = d;

        Assert(4, v3, "#3");

        int[] v4 = new int[] { d };
        Assert(4, v4[0], "#4");

        d = true;
        var v5 = new [] { d, 1 };

        Assert(true, v5[0], "#5");
        Assert(1, v5[1], "#5a");

        d = "aa";
        bool b = false;
        var  r = b ? d : "ss";

        Assert("ss", r, "#6");

        var v = new [] { d, 1 };

        Assert("aa", v [0], "#7");

        dynamic [,] a = new dynamic [, ] {
            { 1, 2 }, { 'b', 'x' }
        };
        Assert(2, a [0, 1], "#8");
        Assert('x', a [1, 1], "#8a");
    }
コード例 #18
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void NegateNullable()
    {
        dynamic d = (int?)-8;

        Assert(8, -d, "#1");
        Assert(-8, -(-d), "#1a");

        MyType?n1 = new MyType(4);

        d = n1;
        Assert(new MyType(-4), -d, "#2");

        MyTypeImplicitOnly?n2 = new MyTypeImplicitOnly(4);

        d = n2;
        Assert(-4, -d, "#3");

        d = (sbyte?)7;
        Assert(-7, -d, "#4");
    }
コード例 #19
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void RightShiftTest()
    {
        dynamic d = (ulong)0x7F000;

        int v = 2;

        Assert <ulong> (d >> v, 0x1FC00, "#1");
        Assert <ulong> (d >> 1, 0x3F800, "#1a");
        short s = 2;

        Assert <ulong> (d >> s, 0x1FC00, "#1b");

        d = 0x7F000;
        MyTypeImplicitOnly v3 = new MyTypeImplicitOnly(3);

        Assert(d >> v3, 0xFE00, "#3");
        dynamic d3 = new MyType(-7);

        Assert(d3 >> new MyTypeImplicitOnly(11), -1, "#3a");
    }
コード例 #20
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void UnaryPlusNullable()
    {
        dynamic d = (int?)-8;

        Assert(-8, +d, "#1");
        Assert(-8, +(+d), "#1a");

        MyType?n1 = new MyType(4);

        d = n1;
        Assert(new MyType(334455), +d, "#2");

        MyTypeImplicitOnly?n2 = new MyTypeImplicitOnly(4);

        d = n2;
        Assert(4, +d, "#3");

        d = (sbyte?)7;
        Assert(7, +d, "#4");
    }
コード例 #21
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void ModuloTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d % v, 1, "#1");

        d = new MyType(5);
        MyType v3 = new MyType(30);

        Assert(d % v3, new MyType(5), "#3");
        dynamic d3 = new MyType(-7);

        Assert <MyType> (d3 % new MyType(6), new MyType(-1), "#3a");

        d = new MyTypeImplicitOnly(5);
        decimal v4 = 4m;

        Assert(d % v4, 1m, "#4");
    }
コード例 #22
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void DivideTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d / v, 2, "#1");

        d = new MyType(5);
        MyType v3 = new MyType(30);

        Assert(d / v3, new MyType(0), "#3");
        dynamic d3 = new MyType(-7);

        Assert <MyType> (d3 + new MyType(6), new MyType(-1), "#3a");

        d = new MyTypeImplicitOnly(6);
        decimal v4 = 4m;

        Assert(d / v4, 1.5m, "#4");
    }
コード例 #23
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void LeftShiftTest()
    {
        dynamic d = (ulong)0x7F000;

        int v = 2;

        Assert <ulong> (d << v, 0x1FC000, "#1");
        Assert <ulong> (d << 1, 0xFE000, "#1a");
        short s = 2;

        Assert <ulong> (d << s, 0x1FC000, "#1b");

        d = 0x7F000;
        MyTypeImplicitOnly v3 = new MyTypeImplicitOnly(3);

        Assert(d << v3, 0x3F8000, "#3");
        dynamic d3 = new MyType(-7);

        Assert(d3 << new MyTypeImplicitOnly(6), -448, "#3a");
        Assert(d3 << 11, -14336, "#3b");
    }
コード例 #24
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void SubtractTest()
    {
        dynamic d = 5;

        int v = 2;

        Assert(d - v, 3, "#1");
        double v2 = 0.5;

        Assert(d - v2, 4.5, "#1a");

        d = new MyType(5);
        MyType v3 = new MyType(30);

        Assert(d - v3, new MyType(-25), "#3");
        dynamic d3 = new MyType(-7);

        Assert(d3 - new MyType(6), new MyType(-13), "#3a");

        d = new MyTypeImplicitOnly(5);
        decimal v4 = 4m;

        Assert(d - v4, 1m, "#4");
    }
コード例 #25
0
ファイル: dtest-006.cs プロジェクト: samcf111/unityMono5.5.0
    void LessThanNullableTest()
    {
        dynamic d = 5;

        int?v2 = null;

        Assert(d < v2, false, "#1");
        Assert(d < null, false, "#1a");
        Assert(null < d, false, "#1b");

        v2 = -2;
        Assert(d < v2, false, "#2");
        dynamic d2 = (int?)-2;

        Assert(d2 < 1, true, "#2a");
        d2 = (uint?)44;
        Assert(d2 < 44, false, "#2b");

        d = new MyType(30);
        MyType?v3 = new MyType(30);

        Assert(d < v3, false, "#3");
        dynamic d3 = new MyType? (new MyType(-7));

        Assert(d3 < new MyType(6), true, "#3a");

        d3 = new MyTypeImplicitOnly(-7);
        Assert(d3 < null, false, "#3b");

        d = 4.1m;
        decimal?v4 = 4m;

        Assert(d < v4, false, "#4");
        v4 = null;
        Assert(d < v4, false, "#4a");
    }