You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2024. It is now read-only.
[Test]
public void MakeABear () {
var swiftCode = @"
public enum Size {
case small, medium, large
internal func toString () -> String {
switch self {
case .small: return ""small""
case .medium: return ""medium""
case .large: return ""large""
}
}
}
public protocol Bearlike {
var name:String { get }
func speak ()
var size: Size { get }
}
public func describeBear (b: Bearlike)
{
print (""I am a bear \(b.toString()) named \(b.name)."")
b.speak ()
}
";
var altClass = new CSClass (CSVisibility.Public, "FuzzyWuzzy");
altClass.Inheritance.Add (new CSIdentifier ("IBearlike"));
var roar = CSFunctionCall.ConsoleWriteLine (CSConstant.Val ("RAwwr!"));
var speakBody = CSCodeBlock.Create (roar);
var speak = new CSMethod (CSVisibility.Public, CSMethodKind.None, CSSimpleType.Void, new CSIdentifier ("Speak"), new CSParameterList (), speakBody);
altClass.Methods.Add (speak);
var sizeReturn = CSReturn.ReturnLine (new CSIdentifier ("Size.Small"));
var sizeProp = new CSProperty (new CSSimpleType ("Size"), CSMethodKind.None, new CSIdentifier ("Size"),
CSVisibility.Public, CSCodeBlock.Create (sizeReturn),
CSVisibility.Public, null);
altClass.Properties.Add (sizeProp);
var nameReturn = CSReturn.ReturnLine (new CSFunctionCall ("SwiftString.FromString", false, CSConstant.Val ("FuzzyWuzzy")));
var nameProp = new CSProperty (new CSSimpleType ("SwiftString"), CSMethodKind.None, new CSIdentifier ("Name"),
CSVisibility.Public, CSCodeBlock.Create (nameReturn), CSVisibility.Public, null);
altClass.Properties.Add (nameProp);
var ctor = new CSMethod (CSVisibility.Public, CSMethodKind.None, null, new CSIdentifier ("FuzzyWuzzy"), new CSParameterList (),
CSCodeBlock.Create ());
altClass.Methods.Add (ctor);
var bearDecl = CSVariableDeclaration.VarLine ("bear", new CSFunctionCall ("FuzzyWuzzy", true));
var caller = CSFunctionCall.FunctionCallLine ("TopLevelEntities.DescribeBear", false, new CSIdentifier ("bear"));
var callingCode = CSCodeBlock.Create (bearDecl, caller);
TestRunning.TestAndExecute (swiftCode, callingCode, "OK\n", otherClass: altClass);
}
It crashes after accessing the size property.
The text was updated successfully, but these errors were encountered:
Here's a test:
It crashes after accessing the size property.
The text was updated successfully, but these errors were encountered: