public void TestConstructorClassHomonym() { var swiftCode = "public class FooClassCtor {\n" + " public var x:Int\n" + " public init(a:Int) { x = a\n }\n" + " public init(b:Int) { x = b + b\n }\n" + "}\n"; var call = new CSFunctionCall("FooClassCtor.FooClassCtor_a", false, CSConstant.Val(14)); var call1 = new CSFunctionCall("FooClassCtor.FooClassCtor_b", false, CSConstant.Val(14)); CSLine printer = CSFunctionCall.ConsoleWriteLine(call.Dot(new CSIdentifier("X"))); CSLine printer1 = CSFunctionCall.ConsoleWriteLine(call1.Dot(new CSIdentifier("X"))); CSCodeBlock callingCode = CSCodeBlock.Create(printer, printer1); TestRunning.TestAndExecute(swiftCode, callingCode, "14\n28\n"); }
public void TestGenericConstructorClassHomonym() { var swiftCode = "public class FooGeneric<T> {\n" + " public var x:Int\n" + " public var t:T\n" + " public init(a:Int, c:T) { x = a\n t = c\n}\n" + " public init(b:Int, c:T) { x = b + b\n t = c\n}\n" + "}\n"; var call = new CSFunctionCall("FooGeneric<bool>.FooGeneric_a_c", false, CSConstant.Val(14), CSConstant.Val(true)); var call1 = new CSFunctionCall("FooGeneric<bool>.FooGeneric_b_c", false, CSConstant.Val(14), CSConstant.Val(true)); CSLine printer = CSFunctionCall.ConsoleWriteLine(call.Dot(new CSIdentifier("X"))); CSLine printer1 = CSFunctionCall.ConsoleWriteLine(call1.Dot(new CSIdentifier("X"))); CSCodeBlock callingCode = CSCodeBlock.Create(printer, printer1); TestRunning.TestAndExecute(swiftCode, callingCode, "14\n28\n"); }
public void VirtualPropIsVirtual() { string swiftCode = "open class ItsAVirtProp {\n" + " open var x = 0\n" + " public init (ix: Int) {\n" + " x = ix\n" + " }\n" + "}\n"; // var pi = typeof (ItsAVirtProp).GetProperty ("X"); // Console.WriteLine(pi.GetGetMethod().IsVirtual); var piID = new CSIdentifier("pi"); var getProp = new CSFunctionCall("GetProperty", false, CSConstant.Val("X")); var propInfo = CSVariableDeclaration.VarLine(CSSimpleType.Var, piID, new CSSimpleType("ItsAVirtProp").Typeof().Dot(getProp)); var getGet = new CSFunctionCall("GetGetMethod", false); var printer = CSFunctionCall.ConsoleWriteLine(piID.Dot(getGet.Dot(new CSIdentifier("IsVirtual")))); var callingCode = CSCodeBlock.Create(propInfo, printer); TestRunning.TestAndExecute(swiftCode, callingCode, "True\n", platform: PlatformName.macOS); }