Пример #1
0
#
# You must not remove this notice, or any other, from this software.
#
#
#####################################################################################

from common import *
import sys

def f1(arg0, arg1, arg2, arg3): return "same## %s %s %s %s" % (arg0, arg1, arg2, arg3)
def f2(arg0, arg1, arg2=6, arg3=7): return "same## %s %s %s %s" % (arg0, arg1, arg2, arg3)
def f3(arg0, arg1, arg2, *arg3): return "same## %s %s %s %s" % (arg0, arg1, arg2, arg3)

if is_cli: 
    from iptest.process_util import run_csc 
    run_csc("/nologo /target:library /out:sbs_library.dll sbs_library.cs")
    import clr
    clr.AddReference("sbs_library")
    from SbsTest import C
    o = C()
    g1 = o.M1
    g2 = o.M2
    g3 = o.M3
    
    #for peverify runs
    from System.IO import Path, File, Directory
    if File.Exists(Path.GetTempPath() + r"\sbs_library.dll"):
        try:
            File.Delete(Path.GetTempPath() + r"\sbs_library.dll")
        except:
            pass
Пример #2
0
def test_gh1435():
    code = """
using System;

 /// <summary>
/// Some description1.
/// </summary>
public class gh1435
{
    /// <summary>
    /// Some description2.
    /// </summary>
    public static String strFoo= "foo";

    /// <summary>
    /// Some description3.
    /// </summary>
    public gh1435()
    {

    }

    /// <summary>
    /// Some description4.
    /// </summary>
    public int someMethod1()
    {
        return 8;
    }

    /// <summary>
    /// Some description5.
    /// </summary>
    public int someMethod2(string strSome)
    {
        return 8;
    }

    /// <summary>
    /// Some description6.
    /// </summary>
    public int someMethod3(out string strSome)
    {
        strSome = "Some string.";
        return 8;
    }

    /// <summary>
    /// Another description1
    /// </summary>
    public int someMethod4(out string strSome, ref int foo) 
    {
        strSome = "Another string";
        foo = 10;
        return 5;
    }
}
"""

    tmp = testpath.temporary_dir

    test_cs, test_dll, test_xml = path_combine(tmp, 'gh1435.cs'), path_combine(
        tmp, 'gh1435.dll'), path_combine(tmp, 'gh1435.xml')

    write_to_file(test_cs, code)

    AreEqual(
        run_csc("/nologo /doc:" + test_xml + " /target:library /out:" +
                test_dll + " " + test_cs), 0)

    from cStringIO import StringIO

    class _Capturing(list):
        def __enter__(self):
            self._stdout = sys.stdout
            sys.stdout = self._stringio = StringIO()
            return self

        def __exit__(self, *args):
            self.extend(self._stringio.getvalue())
            sys.stdout = self._stdout

    expected = """Help on method_descriptor:

someMethod4(...)
    someMethod4(self: clsBar, foo: int) -> (int, str, int)

    Another description1""".replace('\r', '')

    clr.AddReferenceToFileAndPath(test_dll)
    import gh1435
    with _Capturing() as output:
        help(gh1435.someMethod4)
    Assert('\n'.join(output), expected)