CSPspEmu.Core.Tests.CpuEmitterTest.VfpuConstantsTest C# (CSharp) Method

VfpuConstantsTest() private method

private VfpuConstantsTest ( ) : void
return void
        public void VfpuConstantsTest()
        {
            CpuThreadState.Vfpr.ClearAll(float.NaN);

            var Names = VfpuConstants.Constants.Select(Info => Info.Name).ToArray();
            string Assembly = "";

            Action<Action<string, int, int, int, int>> Iterate = (Action) =>
            {
                for (int n = 0; n < Names.Length; n++)
                {
                    var ConstantName = Names[n];
                    int Matrix = (n >> 4) & 7;
                    int Column = (n >> 2) & 3;
                    int Row = (n >> 0) & 3;

                    Action(ConstantName, n, Matrix, Column, Row);
                }
            };

            Iterate((ConstantName, n, Matrix, Column, Row) =>
            {
                Assembly += String.Format(
                    "vcst.s S{0}{1}{2}, {3}\n",
                    Matrix, Column, Row, ConstantName
                );
            });

            Console.WriteLine("{0}", Assembly);

            ExecuteAssembly(Assembly);

            CpuThreadState.DumpVfpuRegisters(Console.Error);

            Iterate((ConstantName, n, Matrix, Column, Row) =>
            {
                Console.WriteLine(
                    "{0}, {1}",
                    VfpuUtils.GetRegisterName(Matrix, Column, Row) + " : " + ConstantName + " : " + VfpuConstants.GetConstantValueByName(ConstantName).Value,
                    VfpuUtils.GetRegisterName(Matrix, Column, Row) + " : " + ConstantName + " : " + CpuThreadState.Vfpr[Matrix, Column, Row]
                );
                Assert.AreEqual(
                    VfpuUtils.GetRegisterName(Matrix, Column, Row) + " : " + ConstantName + " : " + VfpuConstants.GetConstantValueByName(ConstantName).Value,
                    VfpuUtils.GetRegisterName(Matrix, Column, Row) + " : " + ConstantName + " : " + CpuThreadState.Vfpr[Matrix, Column, Row]
                );
            });
        }