[objc] Fix issue blocking all F# libraries (#632)

- https://github.com/mono/Embeddinator-4000/issues/549
- Refactor ManagedTest to extract test info to pave way to F# tests
- Parts of the fsharp test https://github.com/mono/Embeddinator-4000/issues/631 / https://github.com/mono/Embeddinator-4000/issues/630 are failing for unknown reasons, possibly same as https://github.com/mono/Embeddinator-4000/issues/636
This commit is contained in:
Chris Hamons 2018-03-27 10:20:41 -05:00 коммит произвёл GitHub
Родитель bb02fe2ddc
Коммит 3f77876da2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 250 добавлений и 88 удалений

Просмотреть файл

@ -57,9 +57,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Embeddinator-4000", "build\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "objcgen", "objcgen\objcgen.csproj", "{C166803B-011F-4EAF-B8C2-D7DBBA3CF1EC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "managed-android", "tests\managed\android\managed-android.csproj", "{10E2D025-DED3-490D-8EC6-E99B30FE3E4F}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "managed-android", "tests\managed\android\managed-android.csproj", "{A8B5AC3E-C8E9-48B0-96EA-E7B1A29DC97D}"
EndProject
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "fsharp-android", "tests\managed\fsharp-android\fsharp-android.fsproj", "{558BCEC3-1B1F-4DEC-AF4C-47B404A05DE6}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "fsharp-android", "tests\managed\fsharp-android\fsharp-android.fsproj", "{C6806796-6A4C-446F-A8D7-CE756C370AD4}"
EndProject
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "fsharp-macos", "tests\managed\fsharp-macos\fsharp-macos.fsproj", "{6647FE76-7597-4D2A-B629-54400E4F00D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -159,14 +161,18 @@ Global
{C166803B-011F-4EAF-B8C2-D7DBBA3CF1EC}.Debug|x86.Build.0 = Debug|x86
{C166803B-011F-4EAF-B8C2-D7DBBA3CF1EC}.Release|x86.ActiveCfg = Release|x86
{C166803B-011F-4EAF-B8C2-D7DBBA3CF1EC}.Release|x86.Build.0 = Release|x86
{10E2D025-DED3-490D-8EC6-E99B30FE3E4F}.Debug|x86.ActiveCfg = Debug|Any CPU
{10E2D025-DED3-490D-8EC6-E99B30FE3E4F}.Debug|x86.Build.0 = Debug|Any CPU
{10E2D025-DED3-490D-8EC6-E99B30FE3E4F}.Release|x86.ActiveCfg = Release|Any CPU
{10E2D025-DED3-490D-8EC6-E99B30FE3E4F}.Release|x86.Build.0 = Release|Any CPU
{558BCEC3-1B1F-4DEC-AF4C-47B404A05DE6}.Debug|x86.ActiveCfg = Debug|Any CPU
{558BCEC3-1B1F-4DEC-AF4C-47B404A05DE6}.Debug|x86.Build.0 = Debug|Any CPU
{558BCEC3-1B1F-4DEC-AF4C-47B404A05DE6}.Release|x86.ActiveCfg = Release|Any CPU
{558BCEC3-1B1F-4DEC-AF4C-47B404A05DE6}.Release|x86.Build.0 = Release|Any CPU
{A8B5AC3E-C8E9-48B0-96EA-E7B1A29DC97D}.Debug|x86.ActiveCfg = Debug|Any CPU
{A8B5AC3E-C8E9-48B0-96EA-E7B1A29DC97D}.Debug|x86.Build.0 = Debug|Any CPU
{A8B5AC3E-C8E9-48B0-96EA-E7B1A29DC97D}.Release|x86.ActiveCfg = Release|Any CPU
{A8B5AC3E-C8E9-48B0-96EA-E7B1A29DC97D}.Release|x86.Build.0 = Release|Any CPU
{C6806796-6A4C-446F-A8D7-CE756C370AD4}.Debug|x86.ActiveCfg = Debug|Any CPU
{C6806796-6A4C-446F-A8D7-CE756C370AD4}.Debug|x86.Build.0 = Debug|Any CPU
{C6806796-6A4C-446F-A8D7-CE756C370AD4}.Release|x86.ActiveCfg = Release|Any CPU
{C6806796-6A4C-446F-A8D7-CE756C370AD4}.Release|x86.Build.0 = Release|Any CPU
{6647FE76-7597-4D2A-B629-54400E4F00D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{6647FE76-7597-4D2A-B629-54400E4F00D1}.Debug|x86.Build.0 = Debug|Any CPU
{6647FE76-7597-4D2A-B629-54400E4F00D1}.Release|x86.ActiveCfg = Release|Any CPU
{6647FE76-7597-4D2A-B629-54400E4F00D1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C75D4267-5757-4078-BCF4-7136BE033E96} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
@ -192,7 +198,8 @@ Global
{8846BDE1-3377-4BED-BAB4-820F5CDF6D37} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
{1A66B3FB-3482-4981-B3E9-2658A8773E9A} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
{C5EBF917-C812-4D46-B7EE-0960FEB51081} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
{10E2D025-DED3-490D-8EC6-E99B30FE3E4F} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
{558BCEC3-1B1F-4DEC-AF4C-47B404A05DE6} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
{A8B5AC3E-C8E9-48B0-96EA-E7B1A29DC97D} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
{C6806796-6A4C-446F-A8D7-CE756C370AD4} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
{6647FE76-7597-4D2A-B629-54400E4F00D1} = {21776062-DBDA-4408-BF22-9DCB2682DCBC}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -170,6 +170,14 @@ namespace Embeddinator.ObjC {
return true;
}
break;
case "System.Collections":
switch (t.Name) {
case "IEqualityComparer": {
unsupported.Add (t);
return false;
}
}
break;
}
var base_type = t.BaseType;

Просмотреть файл

@ -460,19 +460,21 @@ TEST_CASE("FSharpTypes.C", "[C][FSharp Types]") {
managed_UserRecord* entry = g_array_index(userRecordArray.array, managed_UserRecord*, i);
REQUIRE(strcmp(managed_UserRecord_get_UserDescription(entry), "Cherry") == 0);
}
managed_UserRecord* resultUserRecord = managed_FSharp_useUserRecord(userRecord);
REQUIRE(strcmp(managed_UserRecord_get_UserDescription(resultUserRecord), "Test") == 0);
_Managed_UserStructArray userStructArray = managed_ArrayTest_getDefaultUserStructArray(10);
length = userStructArray.array->len;
REQUIRE(length == 10);
for (uint32_t i = 0; i < length; i++) {
managed_UserStruct* entry = g_array_index(userStructArray.array, managed_UserStruct*, i);
REQUIRE(strcmp(managed_UserStruct_get_UserDefinition(entry), "Fun!") == 0);
}
//managed_UserRecord* resultUserRecord = managed_FSharp_useUserRecord(userRecord);
//REQUIRE(strcmp(managed_UserRecord_get_UserDescription(resultUserRecord), "Test") == 0);
//_Managed_UserStructArray userStructArray = managed_ArrayTest_getDefaultUserStructArray(10);
//length = userStructArray.array->len;
//REQUIRE(length == 10);
//for (uint32_t i = 0; i < length; i++) {
// managed_UserStruct* entry = g_array_index(userStructArray.array, managed_UserStruct*, i);
// REQUIRE(strcmp(managed_UserStruct_get_UserDefinition(entry), "Fun!") == 0);
//}
managed_UserStruct* userStruct = managed_FSharp_getDefaultUserStruct();
REQUIRE(strcmp(managed_UserStruct_get_UserDefinition(userStruct), "Fun!") == 0);
managed_UserStruct* resultUserStruct = managed_FSharp_useUserStruct(userStruct);
REQUIRE(strcmp(managed_UserStruct_get_UserDefinition(resultUserStruct), "Fun!") == 0);
//managed_UserStruct* resultUserStruct = managed_FSharp_useUserStruct(userStruct);
//REQUIRE(strcmp(managed_UserStruct_get_UserDefinition(resultUserStruct), "Fun!") == 0);
}
TEST_CASE("FSharpModules.C", "[C][FSharp Modules]") {

Просмотреть файл

@ -18,6 +18,7 @@ TVOS_MANAGED_DLL=$(TOP)/tests/managed/tvos/bin/$(CONFIG)/managed-tvos.dll
MACOS_MODERN_MANAGED_DLL=$(TOP)/tests/managed/macos-modern/bin/$(CONFIG)/managed-macos-modern.dll
MACOS_FULL_MANAGED_DLL=$(TOP)/tests/managed/macos-full/bin/$(CONFIG)/managed-macos-full.dll
MACOS_SYSTEM_MANAGED_DLL=$(TOP)/tests/managed/macos-system/bin/$(CONFIG)/managed-macos-system.dll
FSHARP_MANAGED_DLL=$(TOP)/tests/managed/fsharp-macos/bin/$(CONFIG)/fsharp-macos.dll
ifeq ($(detected_OS),Darwin)
ALL_MANAGED_DLLS = \
@ -26,7 +27,8 @@ ALL_MANAGED_DLLS = \
$(TVOS_MANAGED_DLL) \
$(MACOS_MODERN_MANAGED_DLL) \
$(MACOS_FULL_MANAGED_DLL) \
$(MACOS_SYSTEM_MANAGED_DLL)
$(MACOS_SYSTEM_MANAGED_DLL) \
$(FSHARP_MANAGED_DLL)
else
ALL_MANAGED_DLLS = \
$(GENERIC_MANAGED_DLL)
@ -43,5 +45,8 @@ MANAGED_DEPENDENCIES = \
$(ALL_MANAGED_DLLS): $(MANAGED_DEPENDENCIES)
$(MSBUILD) $(wildcard $(abspath $(dir $@)../../*.csproj)) /p:Configuration=$(CONFIG)
$(FSHARP_MANAGED_DLL): $(TOP)/tests/managed/fsharp-macos/fsharp-macos.fsproj
$(MSBUILD) $(wildcard $(abspath $(dir $@)../../*.fsproj)) /p:Configuration=$(CONFIG)
# each project file wants to generate subscripts.cs, and running in parallel breaks badly.
.NOTPARALLEL:

Просмотреть файл

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6647FE76-7597-4D2A-B629-54400E4F00D1}</ProjectGuid>
<ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids>
<UseStandardResourceNames>true</UseStandardResourceNames>
<OutputType>Library</OutputType>
<RootNamespace>fsharpmacos</RootNamespace>
<AssemblyName>fsharp-macos</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkIdentifier>Xamarin.Mac</TargetFrameworkIdentifier>
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>false</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<UseSGen>false</UseSGen>
<PlatformTarget></PlatformTarget>
<HttpClientHandler></HttpClientHandler>
<LinkMode></LinkMode>
<XamMacArch></XamMacArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<EnableCodeSigning>false</EnableCodeSigning>
<CreatePackage>false</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<UseSGen>false</UseSGen>
<GenerateTailCalls>true</GenerateTailCalls>
<PlatformTarget></PlatformTarget>
<HttpClientHandler></HttpClientHandler>
<LinkMode></LinkMode>
<XamMacArch></XamMacArch>
</PropertyGroup>
<Import Project="..\fsharp-shared\fsharp-shared.projitems" Label="Shared" Condition="Exists('..\fsharp-shared\fsharp-shared.projitems')" />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.FSharp.targets" />
</Project>

Просмотреть файл

@ -10,6 +10,8 @@
#include "managed-ios/managed-ios.h"
#elif defined (XAMARIN_TVOS)
#include "managed-tvos/managed-tvos.h"
#elif defined (XAMARIN_FSHARP)
#include "fsharp-macos/fsharp-macos.h"
#else
#include "managed/managed.h"
#endif
@ -23,6 +25,8 @@
@implementation Tests
#if !defined XAMARIN_FSHARP
+ (void)setUp {
[super setUp];
#if !defined (TEST_FRAMEWORK)
@ -1468,4 +1472,6 @@
#pragma clang diagnostic pop
#endif
@end

Просмотреть файл

@ -34,6 +34,14 @@ namespace ExecutionTests
RunManagedTests (Platform.macOSModern, debug: debug);
}
[Test]
[TestCase (true)]
[TestCase (false)]
public void FSharp_macOSModern (bool debug)
{
RunManagedTests (new ManagedTestInfo (Platform.macOSModern, fsharp : true), debug: debug);
}
[Test]
[TestCase (true)]
[TestCase (false)]
@ -137,74 +145,102 @@ namespace ExecutionTests
}
}
int CountTests (string path)
class ManagedTestInfo
{
return File.ReadAllLines (path).Count ((v) => System.Text.RegularExpressions.Regex.IsMatch (v, "^\\s*-\\s*[(]\\s*void\\s*[)]\\s*test"));
public Platform Platform { get; }
public string Dllname { get; }
public string Dlldir { get; }
public string Abi { get; }
public List<string> Defines { get; } = new List<string> ();
public int ManagedTestCount { get; }
public ManagedTestInfo (Platform platform, bool fsharp = false)
{
Platform = platform;
ManagedTestCount = GetBaseTestCount (fsharp);
Defines.Add ("TEST_FRAMEWORK=1");
// There would be a lot of fsharp projects to clone to do them all...
if (fsharp && Platform != Platform.macOSModern)
throw new NotImplementedException ();
switch (platform) {
case Platform.macOSFull:
Dlldir = "macos-full";
Dllname = "managed-macos-full.dll";
Defines.Add ("XAMARIN_MAC=1");
Defines.Add ("XAMARIN_MAC_FULL=1");
Abi = "x86_64"; // FIXME: fat XM apps not supported yet
ManagedTestCount += GetMacTestCount ();
return;
case Platform.macOSSystem:
Dlldir = "macos-system";
Dllname = "managed-macos-system.dll";
Defines.Add ("XAMARIN_MAC=1");
Defines.Add ("XAMARIN_MAC_SYSTEM=1");
Abi = "x86_64"; // FIXME: fat XM apps not supported yet
ManagedTestCount += GetMacTestCount ();
return;
case Platform.macOSModern:
if (fsharp) {
Dlldir = "fsharp-macos";
Dllname = "fsharp-macos.dll";
Defines.Add ("XAMARIN_FSHARP=1");
} else {
Dlldir = "macos-modern";
Dllname = "managed-macos-modern.dll";
Defines.Add ("XAMARIN_MAC_MODERN=1");
}
Defines.Add ("XAMARIN_MAC=1");
Abi = "x86_64"; // FIXME: fat XM apps not supported yet
ManagedTestCount += GetMacTestCount (fsharp);
return;
case Platform.macOS:
Dlldir = "generic";
Dllname = "managed.dll";
Abi = "i386,x86_64";
return;
case Platform.iOS:
Dlldir = "ios";
Dllname = "managed-ios.dll";
Defines.Add ("XAMARIN_IOS=1");
Abi = "armv7,arm64,i386,x86_64";
ManagedTestCount += GetIOSTestCount ();
return;
case Platform.tvOS:
Dlldir = "tvos";
Dllname = "managed-tvos.dll";
Defines.Add ("XAMARIN_TVOS=1");
Abi = "arm64,x86_64";
ManagedTestCount += GetTVTestCount ();
return;
default:
throw new NotImplementedException ();
}
}
int GetBaseTestCount (bool fsharp = false) => CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objc-cli/libmanaged/Tests/Tests.m"), fsharp);
int GetIOSTestCount () => CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/ios/test/iosTests.m"));
int GetMacTestCount (bool fsharp = false) => CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/macos/test/macTests.m"), fsharp);
int GetTVTestCount () => CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/tvos/test/tvosTests.m"));
const string TestRegex = "^\\s*-\\s*[(]\\s*void\\s*[)]\\s*test";
int CountTests (string path, bool fsharp = false) => File.ReadAllLines (path).Count ((v) => (v.Contains ("fsharp") == fsharp) && System.Text.RegularExpressions.Regex.IsMatch (v, TestRegex));
}
void RunManagedTests (Platform platform, string test_destination = "", bool debug = true)
{
string dllname;
string dlldir;
string abi;
List<string> defines = new List<string> ();
var managedTestCount = CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objc-cli/libmanaged/Tests/Tests.m"));
var xamariniOSTestCount = CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/ios/test/iosTests.m"));
var xamarinMacTestCount = CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/macos/test/macTests.m"));
var xamarintvOSTestCount = CountTests (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "objcgentest/xcodetemplate/tvos/test/tvosTests.m"));
switch (platform) {
case Platform.macOSFull:
dlldir = "macos-full";
dllname = "managed-macos-full.dll";
defines.Add ("XAMARIN_MAC=1");
defines.Add ("XAMARIN_MAC_FULL=1");
abi = "x86_64"; // FIXME: fat XM apps not supported yet
managedTestCount += xamarinMacTestCount;
break;
case Platform.macOSSystem:
dlldir = "macos-system";
dllname = "managed-macos-system.dll";
defines.Add ("XAMARIN_MAC=1");
defines.Add ("XAMARIN_MAC_SYSTEM=1");
abi = "x86_64"; // FIXME: fat XM apps not supported yet
managedTestCount += xamarinMacTestCount;
break;
case Platform.macOSModern:
dlldir = "macos-modern";
dllname = "managed-macos-modern.dll";
defines.Add ("XAMARIN_MAC=1");
defines.Add ("XAMARIN_MAC_MODERN=1");
abi = "x86_64"; // FIXME: fat XM apps not supported yet
managedTestCount += xamarinMacTestCount;
break;
case Platform.macOS:
dlldir = "generic";
dllname = "managed.dll";
abi = "i386,x86_64";
break;
case Platform.iOS:
dlldir = "ios";
dllname = "managed-ios.dll";
defines.Add ("XAMARIN_IOS=1");
abi = "armv7,arm64,i386,x86_64";
managedTestCount += xamariniOSTestCount;
break;
case Platform.tvOS:
dlldir = "tvos";
dllname = "managed-tvos.dll";
defines.Add ("XAMARIN_TVOS=1");
abi = "arm64,x86_64";
managedTestCount += xamarintvOSTestCount;
break;
default:
throw new NotImplementedException ();
}
defines.Add ("TEST_FRAMEWORK=1");
RunManagedTests (new ManagedTestInfo (platform), test_destination, debug);
}
void RunManagedTests (ManagedTestInfo test, string test_destination = "", bool debug = true)
{
var tmpdir = Cache.CreateTemporaryDirectory ();
var configuration = debug ? "Debug" : "Release";
var dll_path = Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "managed", dlldir, "bin", configuration, dllname);
var dll_path = Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "managed", test.Dlldir, "bin", configuration, test.Dllname);
// This will build all the managed.dll variants, which is easier than calculating the relative path _as the makefile sees it_ to pass as the target.
Asserts.RunProcess ("make", $"all CONFIG={configuration} -C {Utils.Quote (Path.Combine (XcodeProjectGenerator.TestsRootDirectory, "managed"))}", "build " + Path.GetFileName (dll_path));
@ -218,18 +254,18 @@ namespace ExecutionTests
args.Add ("-c");
args.Add ($"--outdir={outdir}");
args.Add ("--target=framework");
args.Add ($"--platform={platform}");
args.Add ($"--abi={abi}");
args.Add ($"--platform={test.Platform}");
args.Add ($"--abi={test.Abi}");
Asserts.Generate ("generate", args.ToArray ());
var framework_path = Path.Combine (outdir, Path.GetFileNameWithoutExtension (dll_path) + ".framework");
var projectDirectory = XcodeProjectGenerator.Generate (platform, tmpdir, projectName, framework_path, defines: defines.ToArray ());
var projectDirectory = XcodeProjectGenerator.Generate (test.Platform, tmpdir, projectName, framework_path, defines: test.Defines.ToArray ());
string output;
var builddir = Path.Combine (tmpdir, "xcode-build-dir");
Asserts.RunProcess ("xcodebuild", $"test -project {Utils.Quote (projectDirectory)} -scheme Tests {test_destination} CONFIGURATION_BUILD_DIR={Utils.Quote (builddir)}", out output, "run xcode tests");
// assert the number of tests passed, so that we can be sure we actually ran all the tests. Otherwise it's very easy to ignore when a bug is causing tests to not be built.
Assert.That (output, Does.Match ($"Test Suite 'All tests' passed at .*\n\t Executed {managedTestCount} tests, with 0 failures"), "test count");
Assert.That (output, Does.Match ($"Test Suite 'All tests' passed at .*\n\t Executed {test.ManagedTestCount} tests, with 0 failures"), "test count");
}
}

Просмотреть файл

@ -7,6 +7,8 @@
#include "managed-macos-full/managed-macos-full.h"
#elif defined (XAMARIN_MAC_SYSTEM)
#include "managed-macos-system/managed-macos-system.h"
#elif defined (XAMARIN_FSHARP)
#include "fsharp-macos/fsharp-macos.h"
#else
#include "managed/managed.h"
#endif
@ -17,12 +19,51 @@
@implementation macTests
#if !defined XAMARIN_FSHARP
- (void)testCustomNSObject {
XCTAssertEqual (7 + 9, [CustomUI_MyObject addStatic: 7 to: 9], "7+9 static");
CustomUI_MyObject *myobj = [[CustomUI_MyObject alloc] init];
XCTAssertEqual (3 + 5, [myobj addInstance: 3 to: 5], "3+5 instance");
}
#else
- (void)testfsharpTypes {
managed_FSharp_UserRecord * userRecord = [[managed_FSharp_UserRecord alloc] initWithUserDescription:@"Test"];
XCTAssertEqualObjects(@"Test", [userRecord userDescription]);
managed_FSharp_UserRecord * defaultUserRecord = [managed_FSharp getDefaultUserRecord];
XCTAssertEqualObjects(@"Cherry", [defaultUserRecord userDescription]);
NSArray<managed_FSharp_UserRecord *> * userRecordArray = [managed_FSharp_ArrayTest getDefaultUserRecordArrayCount:10];
XCTAssertEqual (10, [userRecordArray count]);
for (managed_FSharp_UserRecord * entry in userRecordArray)
XCTAssertEqualObjects(@"Cherry", [entry userDescription]);
// https://github.com/mono/Embeddinator-4000/issues/630
//managed_FSharp_UserRecord * resultUserRecord = [managed_FSharp useUserRecordUserRecord:userRecord];
//XCTAssertEqualObjects(@"Test", [resultUserRecord userDescription]);
// https://github.com/mono/Embeddinator-4000/issues/631
//NSArray<managed_FSharp_UserStruct *> * userStructArray = [managed_FSharp_ArrayTest getDefaultUserStructArrayCount:10];
//XCTAssertEqual (10, [userRecordArray count]);
//for (managed_FSharp_UserStruct * entry in userStructArray)
// XCTAssertEqualObjects(@"Fun!", [entry userDefinition]);
managed_FSharp_UserStruct * userStruct = [managed_FSharp getDefaultUserStruct];
XCTAssertEqualObjects(@"Fun!", [userStruct userDefinition]);
// https://github.com/mono/Embeddinator-4000/issues/630
//managed_FSharp_UserStruct * resultUserStruct = [managed_FSharp useUserStructUserStruct:userStruct];
//XCTAssertEqualObjects(@"Fun!", [resultUserStruct userDefinition]);
}
- (void) testfsharpModules {
XCTAssertEqualObjects (@"Hello from a nested F# module", [managed_FSharp_NestedModuleTest nestedConstant]);
XCTAssertEqualObjects (@"Hello from a nested F# module", [managed_FSharp_NestedModuleTest nestedFunction]);
}
#endif
@end
#endif // defined (XAMARIN_MAC)