private VMObject GenerateTestObject(VarType type) { VMObject obj; switch (type.Kind) { case VarKind.Number: obj = VMObject.FromObject(new BigInteger(123)); break; case VarKind.String: obj = VMObject.FromObject("test"); break; case VarKind.Bool: obj = VMObject.FromObject(true); break; case VarKind.Struct: var fields = new Dictionary <VMObject, VMObject>(); var structInfo = type as StructVarType; foreach (var field in structInfo.decl.fields) { fields[VMObject.FromObject(field.name)] = GenerateTestObject(field.type); } obj = new VMObject(); obj.SetValue(fields); using (var stream = new MemoryStream()) { using (var writer = new BinaryWriter(stream)) { obj.SerializeData(writer); } var bytes = stream.ToArray(); obj.SetValue(bytes); } break; default: throw new CompilerException($"Can't initialize test object with type: {type}"); } return(obj); }