예제 #1
0
파일: Test.cs 프로젝트: uranium62/ilwasm
        public static void AssertEq(object expected, string exportedFunctionName, params object[] values)
        {
            var assembly     = Assembly.GetCallingAssembly();
            var exports      = ExportTable.GetExports(assembly);
            var export       = exports[exportedFunctionName];
            var result       = export.Invoke(null, values);
            var expectedText = Convert.ToString(expected);
            var actualText   = Convert.ToString(result);

            var passed = (expectedText == actualText);

            if (!passed)
            {
                Environment.ExitCode = 1;
            }

            if (QuietMode && passed)
            {
                return;
            }

            PrintHeader(assembly);
            Console.WriteLine(
                "(invoke \"{1}\" {2}){0}" +
                "-> {3} '{4}' == '{5}'",
                Environment.NewLine,
                exportedFunctionName,
                string.Join(" ", values),
                passed
                    ? "pass"
                    : "fail",
                expectedText,
                actualText
                );
        }
예제 #2
0
        public static void Invoke(string exportedFunctionName, params object[] values)
        {
            var    assembly = Assembly.GetCallingAssembly();
            var    exports  = ExportTable.GetExports(assembly);
            var    export   = exports[exportedFunctionName];
            object result;

            try {
                result = export.Invoke(null, values);
            } catch (Exception exc) {
                throw new Exception(string.Format("Invoke('{0}', ...) failed ", exportedFunctionName), exc);
            }

            if (QuietMode && (export.ReturnType.FullName == "System.Void"))
            {
                return;
            }

            PrintHeader(assembly);
            if (export.ReturnType.Name != "Void")
            {
                Console.WriteLine(
                    "(invoke \"{1}\" {2}){0}" +
                    "-> {3}",
                    Environment.NewLine,
                    exportedFunctionName,
                    string.Join(" ", values),
                    result
                    );
            }
            else
            {
                Console.WriteLine(
                    "(invoke \"{0}\" {1})",
                    exportedFunctionName,
                    string.Join(" ", values)
                    );
            }
        }
예제 #3
0
파일: Test.cs 프로젝트: uranium62/ilwasm
        public static void Invoke(string exportedFunctionName, params object[] values)
        {
            var assembly = Assembly.GetCallingAssembly();
            var exports  = ExportTable.GetExports(assembly);
            var export   = exports[exportedFunctionName];
            var result   = export.Invoke(null, values);

            if (QuietMode && (export.ReturnType.FullName == "System.Void"))
            {
                return;
            }

            PrintHeader(assembly);
            Console.WriteLine(
                "(invoke \"{1}\" {2}){0}" +
                "-> {3}",
                Environment.NewLine,
                exportedFunctionName,
                string.Join(" ", values),
                result
                );
        }