Skip to content

Commit

Permalink
[NFC] Fix non-Darwin platform test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Nov 5, 2023
1 parent a280469 commit f070bd6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/OpenSwiftUIShims/ProtocolDescriptor.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
// ProtocolDescriptor.m
// ProtocolDescriptor.c
//
//
// Created by Kyle on 2023/10/3.
//

#import "ProtocolDescriptor.h"
#include "ProtocolDescriptor.h"

OF_EXPORT
const void *$s11OpenSwiftUI4ViewMp;
Expand Down
14 changes: 14 additions & 0 deletions Sources/OpenSwiftUIShims/dyld_Private.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// dyld_Private.c
//
//
// Created by Kyle on 2023/10/3.
//

#include "dyld_Private.h"

#if !TARGET_OS_DARWIN
bool dyld_program_sdk_at_least(dyld_build_version_t version) {
return true;
}
#endif
2 changes: 2 additions & 0 deletions Sources/OpenSwiftUIShims/include/dyld_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef dyld_Private_h
#define dyld_Private_h

#include <OpenFoundation/OpenFoundation.h>
#include <stdlib.h>
#include <stdbool.h>

Expand All @@ -18,6 +19,7 @@ typedef struct {
uint32_t version;
} dyld_build_version_t;

// Always return true on non-Darwin platform
extern bool dyld_program_sdk_at_least(dyld_build_version_t version);

#endif /* dyld_Private_h */
9 changes: 9 additions & 0 deletions Tests/OpenSwiftUITests/Shims/LockedPointerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,20 @@ final class LockedPointerTests: XCTestCase {
}

func testLocking() {
#if canImport(os)
let pointer = LockedPointer(type: Int.self)
XCTAssertEqual(pointer.rawValue.pointee.lock._os_unfair_lock_opaque, 0)
pointer.lock()
XCTAssertNotEqual(pointer.rawValue.pointee.lock._os_unfair_lock_opaque, 0)
pointer.unlock()
XCTAssertEqual(pointer.rawValue.pointee.lock._os_unfair_lock_opaque, 0)
#else
let pointer = LockedPointer(type: Int.self)
XCTAssertEqual(pointer.rawValue.pointee.lock, 0)
pointer.lock()
XCTAssertNotEqual(pointer.rawValue.pointee.lock, 0)
pointer.unlock()
XCTAssertEqual(pointer.rawValue.pointee.lock, 0)
#endif
}
}

0 comments on commit f070bd6

Please sign in to comment.