public void Int32TruncateSaturatedSignedFloat32_Compiled()
    {
        var exports = ConversionTestBase <float, int> .CreateInstance(
            new LocalGet(0),
            new Int32TruncateSaturateFloat32Signed(),
            new End());

        // Test cases from https://github.com/WebAssembly/spec/blob/7526564b56c30250b66504fe795e9c1e88a938af/test/core/conversions.wast
        Assert.AreEqual(0, exports.Test(0.0f));
        Assert.AreEqual(0, exports.Test(-0.0f));
        Assert.AreEqual(0, exports.Test(float.Epsilon));
        Assert.AreEqual(0, exports.Test(-float.Epsilon));
        Assert.AreEqual(1, exports.Test(1.0f));
        Assert.AreEqual(1, exports.Test(BitConverter.Int32BitsToSingle(0x3f8ccccd)));
        Assert.AreEqual(1, exports.Test(1.5f));
        Assert.AreEqual(-1, exports.Test(-1.0f));
        Assert.AreEqual(-1, exports.Test(BitConverter.Int32BitsToSingle(unchecked ((int)0xbf8ccccd))));
        Assert.AreEqual(-1, exports.Test(-1.5f));
        Assert.AreEqual(-1, exports.Test(-1.9f));
        Assert.AreEqual(-2, exports.Test(-2.0f));
        Assert.AreEqual(2147483520, exports.Test(2147483520.0f));
        Assert.AreEqual(-2147483648, exports.Test(-2147483648.0f));
        Assert.AreEqual(0x7fffffff, exports.Test(2147483648.0f));
        Assert.AreEqual(unchecked ((int)0x80000000), exports.Test(-2147483904.0f));
        Assert.AreEqual(0x7fffffff, exports.Test(float.PositiveInfinity));
        Assert.AreEqual(unchecked ((int)0x80000000), exports.Test(float.NegativeInfinity));
        Assert.AreEqual(0, exports.Test(float.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(float.NaN, 0x200000)));
        Assert.AreEqual(0, exports.Test(-float.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(-float.NaN, 0x200000)));
    }
    public void Int64TruncateSaturatedUnsignedFloat32_Compiled()
    {
        var exports = ConversionTestBase <float, long> .CreateInstance(
            new LocalGet(0),
            new Int64TruncateSaturateFloat32Unsigned(),
            new End());

        // Test cases from https://github.com/WebAssembly/spec/blob/7526564b56c30250b66504fe795e9c1e88a938af/test/core/conversions.wast
        Assert.AreEqual(0, exports.Test(0.0f));
        Assert.AreEqual(0, exports.Test(-0.0f));
        Assert.AreEqual(0, exports.Test(float.Epsilon));
        Assert.AreEqual(0, exports.Test(-float.Epsilon));
        Assert.AreEqual(1, exports.Test(1.0f));
        Assert.AreEqual(1, exports.Test(BitConverter.Int32BitsToSingle(0x3f8ccccd)));
        Assert.AreEqual(1, exports.Test(1.5f));
        Assert.AreEqual(4294967296, exports.Test(4294967296f));
        Assert.AreEqual(-1099511627776, exports.Test(18446742974197923840.0f));
        Assert.AreEqual(0, exports.Test(BitConverter.Int32BitsToSingle(unchecked ((int)0xbf666666))));
        Assert.AreEqual(0, exports.Test(BitConverter.Int32BitsToSingle(unchecked ((int)0xbf7fffff))));
        Assert.AreEqual(unchecked ((long)0xffffffffffffffff), exports.Test(18446744073709551616.0f));
        Assert.AreEqual(0x0000000000000000, exports.Test(-1.0f));
        Assert.AreEqual(unchecked ((long)0xffffffffffffffff), exports.Test(float.PositiveInfinity));
        Assert.AreEqual(0x0000000000000000, exports.Test(float.NegativeInfinity));
        Assert.AreEqual(0, exports.Test(float.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(float.NaN, 0x200000)));
        Assert.AreEqual(0, exports.Test(-float.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(-float.NaN, 0x200000)));
    }
    public void Int64TruncateSaturatedUnsignedFloat64_Compiled()
    {
        var exports = ConversionTestBase <double, long> .CreateInstance(
            new LocalGet(0),
            new Int64TruncateSaturateFloat64Unsigned(),
            new End());

        // Test cases from https://github.com/WebAssembly/spec/blob/7526564b56c30250b66504fe795e9c1e88a938af/test/core/conversions.wast
        Assert.AreEqual(0, exports.Test(0.0));
        Assert.AreEqual(0, exports.Test(-0.0));
        Assert.AreEqual(0, exports.Test(double.Epsilon));
        Assert.AreEqual(0, exports.Test(-double.Epsilon));
        Assert.AreEqual(1, exports.Test(1.0));
        Assert.AreEqual(1, exports.Test(BitConverter.Int64BitsToDouble(0x3ff199999999999a)));
        Assert.AreEqual(1, exports.Test(1.5));
        Assert.AreEqual(0xffffffff, exports.Test(4294967295));
        Assert.AreEqual(0x100000000, exports.Test(4294967296));
        Assert.AreEqual(-2048, exports.Test(18446744073709549568.0));
        Assert.AreEqual(0, exports.Test(BitConverter.Int64BitsToDouble(unchecked ((long)0xbfeccccccccccccd))));
        Assert.AreEqual(0, exports.Test(BitConverter.Int64BitsToDouble(unchecked ((long)0xbfefffffffffffff))));
        Assert.AreEqual(100000000, exports.Test(1e8));
        Assert.AreEqual(10000000000000000, exports.Test(1e16));
        Assert.AreEqual(-9223372036854775808, exports.Test(9223372036854775808));
        Assert.AreEqual(unchecked ((long)0xffffffffffffffff), exports.Test(18446744073709551616.0));
        Assert.AreEqual(0x0000000000000000, exports.Test(-1.0));
        Assert.AreEqual(unchecked ((long)0xffffffffffffffff), exports.Test(double.PositiveInfinity));
        Assert.AreEqual(0x0000000000000000, exports.Test(double.NegativeInfinity));
        Assert.AreEqual(0, exports.Test(double.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(double.NaN, 0x4000000000000)));
        Assert.AreEqual(0, exports.Test(-double.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(-double.NaN, 0x4000000000000)));
    }
Ejemplo n.º 4
0
    public void Int64TruncateSaturatedSignedFloat32_Compiled()
    {
        var exports = ConversionTestBase <float, long> .CreateInstance(
            new LocalGet(0),
            new Int64TruncateSaturateFloat32Signed(),
            new End());

        // Test cases from https://github.com/WebAssembly/spec/blob/7526564b56c30250b66504fe795e9c1e88a938af/test/core/conversions.wast
        Assert.AreEqual(0, exports.Test(0.0f));
        Assert.AreEqual(0, exports.Test(-0.0f));
        Assert.AreEqual(0, exports.Test(float.Epsilon));
        Assert.AreEqual(0, exports.Test(-float.Epsilon));
        Assert.AreEqual(1, exports.Test(1.0f));
        Assert.AreEqual(1, exports.Test(BitConverter.Int32BitsToSingle(0x3f8ccccd)));
        Assert.AreEqual(1, exports.Test(1.5f));
        Assert.AreEqual(-1, exports.Test(-1.0f));
        Assert.AreEqual(-1, exports.Test(BitConverter.Int32BitsToSingle(unchecked ((int)0xbf8ccccd))));
        Assert.AreEqual(-1, exports.Test(-1.5f));
        Assert.AreEqual(-1, exports.Test(-1.9f));
        Assert.AreEqual(-2, exports.Test(-2.0f));
        Assert.AreEqual(4294967296, exports.Test(4294967296f));
        Assert.AreEqual(-4294967296, exports.Test(-4294967296f));
        Assert.AreEqual(9223371487098961920, exports.Test(9223371487098961920.0f));
        Assert.AreEqual(-9223372036854775808, exports.Test(-9223372036854775808.0f));
        Assert.AreEqual(0x7fffffffffffffff, exports.Test(9223372036854775808.0f));
        Assert.AreEqual(unchecked ((long)0x8000000000000000), exports.Test(-9223373136366403584.0f));
        Assert.AreEqual(0x7fffffffffffffff, exports.Test(float.PositiveInfinity));
        Assert.AreEqual(unchecked ((long)0x8000000000000000), exports.Test(float.NegativeInfinity));
        Assert.AreEqual(0, exports.Test(float.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(float.NaN, 0x200000)));
        Assert.AreEqual(0, exports.Test(-float.NaN));
        Assert.AreEqual(0, exports.Test(AddPayload(-float.NaN, 0x200000)));
    }
        public void Int32TruncateSaturatedSignedFloat64_Compiled()
        {
            var exports = ConversionTestBase <double, int> .CreateInstance(
                new LocalGet(0),
                new Int32TruncateSaturateFloat64Signed(),
                new End());

            // Test cases from https://github.com/WebAssembly/spec/blob/7526564b56c30250b66504fe795e9c1e88a938af/test/core/conversions.wast
            Assert.AreEqual(0, exports.Test(0.0));
            Assert.AreEqual(0, exports.Test(-0.0));
            Assert.AreEqual(0, exports.Test(double.Epsilon));
            Assert.AreEqual(0, exports.Test(-double.Epsilon));
            Assert.AreEqual(1, exports.Test(1.0));
            Assert.AreEqual(1, exports.Test(BitConverter.Int64BitsToDouble(0x3ff199999999999a)));
            Assert.AreEqual(1, exports.Test(1.5));
            Assert.AreEqual(-1, exports.Test(-1.0));
            Assert.AreEqual(-1, exports.Test(BitConverter.Int64BitsToDouble(unchecked ((long)0xbff199999999999a))));
            Assert.AreEqual(-1, exports.Test(-1.5));
            Assert.AreEqual(-1, exports.Test(-1.9));
            Assert.AreEqual(-2, exports.Test(-2.0));
            Assert.AreEqual(2147483647, exports.Test(2147483647.0));
            Assert.AreEqual(-2147483648, exports.Test(-2147483648.0));
            Assert.AreEqual(0x7fffffff, exports.Test(2147483648.0));
            Assert.AreEqual(unchecked ((int)0x80000000), exports.Test(-2147483649.0));
            Assert.AreEqual(0x7fffffff, exports.Test(double.PositiveInfinity));
            Assert.AreEqual(unchecked ((int)0x80000000), exports.Test(double.NegativeInfinity));
            Assert.AreEqual(0, exports.Test(double.NaN));
            Assert.AreEqual(0, exports.Test(AddPayload(double.NaN, 0x4000000000000)));
            Assert.AreEqual(0, exports.Test(-double.NaN));
            Assert.AreEqual(0, exports.Test(AddPayload(-double.NaN, 0x4000000000000)));
        }
    public void Float64ConvertUnsignedInt32_Compiled()
    {
        var exports = ConversionTestBase <int, double> .CreateInstance(
            new LocalGet(0),
            new Float64ConvertInt32Unsigned(),
            new End());

        foreach (var value in Samples.UInt32)
        {
            Assert.AreEqual(value, exports.Test((int)value));
        }
    }
        public void Float32ConvertSignedInt32_Compiled()
        {
            var exports = ConversionTestBase <int, float> .CreateInstance(
                new GetLocal(0),
                new Float32ConvertSignedInt32(),
                new End());

            foreach (var value in Samples.Int32)
            {
                Assert.AreEqual(value, exports.Test(value));
            }
        }
        public void Float32ConvertUnsignedInt64_Compiled()
        {
            var exports = ConversionTestBase <long, float> .CreateInstance(
                new GetLocal(0),
                new Float32ConvertUnsignedInt64(),
                new End());

            foreach (var value in Samples.UInt64)
            {
                Assert.AreEqual(value, exports.Test((long)value));
            }
        }
Ejemplo n.º 9
0
        public void Float32DemoteFloat64_Compiled()
        {
            var exports = ConversionTestBase <double, float> .CreateInstance(
                new LocalGet(0),
                new Float32DemoteFloat64(),
                new End());

            foreach (var value in Samples.Double)
            {
                Assert.AreEqual((float)value, exports.Test(value));
            }
        }
Ejemplo n.º 10
0
    public void Float64ConvertSignedInt64_Compiled()
    {
        var exports = ConversionTestBase <long, double> .CreateInstance(
            new LocalGet(0),
            new Float64ConvertInt64Signed(),
            new End());

        foreach (var value in Samples.Int64)
        {
            Assert.AreEqual(value, exports.Test(value));
        }
    }
        public void Float64PromoteFloat32_Compiled()
        {
            var exports = ConversionTestBase <float, double> .CreateInstance(
                new GetLocal(0),
                new Float64PromoteFloat32(),
                new End());

            foreach (var value in Samples.Single)
            {
                Assert.AreEqual(value, exports.Test(value));
            }
        }
Ejemplo n.º 12
0
    public void Float64ReinterpretInt64_Compiled()
    {
        var exports = ConversionTestBase <long, double> .CreateInstance(
            new LocalGet(0),
            new Float64ReinterpretInt64(),
            new End());

        foreach (var value in Samples.Int64)
        {
            Assert.AreEqual(new Overlap64 {
                Int64 = value
            }.Float64, exports.Test(value));
        }
    }
Ejemplo n.º 13
0
        public void Int64ReinterpretFloat64_Compiled()
        {
            var exports = ConversionTestBase <double, long> .CreateInstance(
                new GetLocal(0),
                new Int64ReinterpretFloat64(),
                new End());

            foreach (var value in Samples.Double)
            {
                Assert.AreEqual(new Overlap64 {
                    Float64 = value
                }.Int64, exports.Test(value));
            }
        }
        public void Float32ReinterpretInt32_Compiled()
        {
            var exports = ConversionTestBase <int, float> .CreateInstance(
                new GetLocal(0),
                new Float32ReinterpretInt32(),
                new End());

            foreach (var value in Samples.Int32)
            {
                Assert.AreEqual(new Overlap32 {
                    Int32 = value
                }.Float32, exports.Test(value));
            }
        }
        public void Int32ReinterpretFloat32_Compiled()
        {
            var exports = ConversionTestBase <float, int> .CreateInstance(
                new LocalGet(0),
                new Int32ReinterpretFloat32(),
                new End());

            foreach (var value in Samples.Single)
            {
                Assert.AreEqual(new Overlap32 {
                    Float32 = value
                }.Int32, exports.Test(value));
            }
        }
Ejemplo n.º 16
0
        public void Int64ExtendSignedInt32_Compiled()
        {
            var exports = ConversionTestBase <int, long> .CreateInstance(
                new LocalGet(0),
                new Int64ExtendInt32Signed(),
                new End());

            //Test cases from https://github.com/WebAssembly/spec/blob/c4774b47d326e4114f96232f1389a555639d7348/test/core/conversions.wast
            Assert.AreEqual(0, exports.Test(0));
            Assert.AreEqual(10000, exports.Test(10000));
            Assert.AreEqual(-10000, exports.Test(-10000));
            Assert.AreEqual(-1, exports.Test(-1));
            Assert.AreEqual(0x000000007fffffff, exports.Test(0x7fffffff));
            Assert.AreEqual(unchecked ((long)0xffffffff80000000), exports.Test(unchecked ((int)0x80000000)));
        }
        public void Int64TruncateSignedFloat32_Compiled()
        {
            var exports = ConversionTestBase <float, long> .CreateInstance(
                new GetLocal(0),
                new Int64TruncateSignedFloat32(),
                new End());

            foreach (var value in new[] { 0, 1.5f, -1.5f, 123445678901234f })
            {
                Assert.AreEqual((long)value, exports.Test(value));
            }

            const float exceptional = 1234456789012345678901234567890f;

            Assert.ThrowsException <System.OverflowException>(() => exports.Test(exceptional));
        }
    public void Int32Extend8Signed_Compiled()
    {
        var exports = ConversionTestBase <int, int> .CreateInstance(
            new LocalGet(0),
            new Int32Extend8Signed(),
            new End());

        //Test cases from https://github.com/WebAssembly/spec/blob/7526564b56c30250b66504fe795e9c1e88a938af/test/core/i32.wast
        Assert.AreEqual(0, exports.Test(0));
        Assert.AreEqual(127, exports.Test(0x7f));
        Assert.AreEqual(-128, exports.Test(0x80));
        Assert.AreEqual(-1, exports.Test(0xff));
        Assert.AreEqual(0, exports.Test(0x01234500));
        Assert.AreEqual(-0x80, exports.Test(unchecked ((int)0xfedcba80)));
        Assert.AreEqual(-1, exports.Test(-1));
    }
        public void Int32TruncateUnsignedFloat32_Compiled()
        {
            var exports = ConversionTestBase <float, int> .CreateInstance(
                new GetLocal(0),
                new Int32TruncateUnsignedFloat32(),
                new End());

            foreach (var value in new[] { 0, 1.5f, -1.5f })
            {
                Assert.AreEqual((int)value, exports.Test(value));
            }

            const float exceptional = 123445678901234f;

            ExceptionAssert.Expect <System.OverflowException>(() => exports.Test(exceptional));
        }
Ejemplo n.º 20
0
    public void Int64Extend16Signed_Compiled()
    {
        var exports = ConversionTestBase <long, long> .CreateInstance(
            new LocalGet(0),
            new Int64Extend16Signed(),
            new End());

        //Test cases from https://github.com/WebAssembly/spec/blob/7526564b56c30250b66504fe795e9c1e88a938af/test/core/i64.wast
        Assert.AreEqual(0, exports.Test(0));
        Assert.AreEqual(32767, exports.Test(0x7fff));
        Assert.AreEqual(-32768, exports.Test(0x8000));
        Assert.AreEqual(-1, exports.Test(0xffff));
        Assert.AreEqual(0, exports.Test(0x0123456789abc0000));
        Assert.AreEqual(-0x8000, exports.Test(unchecked ((long)0xfedcba9876548000)));
        Assert.AreEqual(-1, exports.Test(-1));
    }
Ejemplo n.º 21
0
        public void Int32TruncateUnsignedFloat64_Compiled()
        {
            var exports = ConversionTestBase <double, int> .CreateInstance(
                new LocalGet(0),
                new Int32TruncateFloat64Unsigned(),
                new End());

            foreach (var value in new[] { 0, 1.5, -1.5 })
            {
                Assert.AreEqual((int)value, exports.Test(value));
            }

            const double exceptional = 123445678901234.0;

            Assert.ThrowsException <System.OverflowException>(() => exports.Test(exceptional));
        }
Ejemplo n.º 22
0
        public void Int64TruncateUnsignedFloat64_Compiled()
        {
            var exports = ConversionTestBase <double, long> .CreateInstance(
                new GetLocal(0),
                new Int64TruncateUnsignedFloat64(),
                new End());

            foreach (var value in new[] { 0, 1.5, -1.5, 123445678901234.0 })
            {
                Assert.AreEqual((long)value, exports.Test(value));
            }

            const double exceptional = 1234456789012345678901234567890.0;

            ExceptionAssert.Expect <System.OverflowException>(() => exports.Test(exceptional));
        }
Ejemplo n.º 23
0
        public void Int32WrapInt64_Compiled()
        {
            var exports = ConversionTestBase <long, int> .CreateInstance(
                new LocalGet(0),
                new Int32WrapInt64(),
                new End());

            //Test cases from https://github.com/WebAssembly/spec/blob/c4774b47d326e4114f96232f1389a555639d7348/test/core/conversions.wast
            Assert.AreEqual(-1, exports.Test(-1));
            Assert.AreEqual(-100000, exports.Test(-100000));
            Assert.AreEqual(unchecked ((int)0x80000000), exports.Test(0x80000000));
            Assert.AreEqual(0x7fffffff, exports.Test(unchecked ((long)0xffffffff7fffffff)));
            Assert.AreEqual(0x00000000, exports.Test(unchecked ((long)0xffffffff00000000)));
            Assert.AreEqual(unchecked ((int)0xffffffff), exports.Test(unchecked ((long)0xfffffffeffffffff)));
            Assert.AreEqual(0x00000001, exports.Test(unchecked ((long)0xffffffff00000001)));
            Assert.AreEqual(0, exports.Test(0));
            Assert.AreEqual(unchecked ((int)0x9ABCDEF0), exports.Test(0x123456789ABCDEF0));
            Assert.AreEqual(unchecked ((int)0xffffffff), exports.Test(0x00000000ffffffff));
            Assert.AreEqual(unchecked ((int)0x0000000100000000), exports.Test(0x00000000));
            Assert.AreEqual(unchecked ((int)0x0000000100000001), exports.Test(0x00000001));
        }