Skip to content

Commit

Permalink
update swift lazy version. Add test for actor
Browse files Browse the repository at this point in the history
  • Loading branch information
ivlevAstef committed Dec 25, 2024
1 parent 96a1bdd commit 56d2d8f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "a78bd8ab13fd306cff7fbfcbc2df0f27eba3a0b7ca535404c66bbd8e5eeab251",
"originHash" : "e7f5a8aee0196ef0caca4b5920d71fed416717ae63dfa83f9078e4cc617c33fe",
"pins" : [
{
"identity" : "swiftlazy",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ivlevAstef/SwiftLazy.git",
"state" : {
"branch" : "swift_concurrency",
"revision" : "33b14327d7395c1db90ab4ef634ecfd3ec2d1360"
"revision" : "9b267a90bde85f07f372b1ac90a7ad88f434cd06",
"version" : "1.5.0"
}
}
],
Expand Down
8 changes: 3 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:6.0
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand All @@ -8,16 +8,14 @@ let package = Package(
.library(name: "DITranquillity", targets: ["DITranquillity"])
],
dependencies: [
// .package(url: "https://github.com/ivlevAstef/SwiftLazy.git", from: "1.3.0")
.package(url: "https://github.com/ivlevAstef/SwiftLazy.git", branch: "swift_concurrency")
.package(url: "https://github.com/ivlevAstef/SwiftLazy.git", from: "1.5.0")
],
targets: [
.target(name: "DITranquillity", dependencies: [
"SwiftLazy"
], path: "./Sources", swiftSettings: [.swiftLanguageMode(.v6)]),
], path: "./Sources"),
.testTarget(name: "DITranquillity_Tests", dependencies: [
"DITranquillity"
], path: "./Tests")
]
)

29 changes: 28 additions & 1 deletion Tests/DITranquillityTests_ResolveByInit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ private final class TestMainActor {
}
}

private final class TestActorClassInjected: Sendable {
}

private actor TestActorActorInjected {
}

private actor TestActor {
let str: String = "bar"
let otherClass: TestActorClassInjected
let otherActor: TestActorActorInjected
init(otherClass: TestActorClassInjected, otherActor: TestActorActorInjected) {
self.otherClass = otherClass
self.otherActor = otherActor
}
}

class DITranquillityTests_ResolveByInit: XCTestCase {
override func setUp() {
super.setUp()
Expand Down Expand Up @@ -89,6 +105,7 @@ class DITranquillityTests_ResolveByInit: XCTestCase {
func test05_ResolveMainActor() {
let container = DIContainer()

// container.register(TestOtherMainActor.init)
container.register { @MainActor in TestOtherMainActor() }
container.register { @MainActor in TestMainActor(other: $0) }

Expand Down Expand Up @@ -122,6 +139,16 @@ class DITranquillityTests_ResolveByInit: XCTestCase {
XCTAssert(m2.str == "bar")
}
}
}

func test06_ResolveActor() {
let container = DIContainer()

container.register(TestActorClassInjected.init)
container.register(TestActorActorInjected.init)
container.register { TestActor(otherClass: $0, otherActor: $1) }

let m2: TestActor = container.resolve()

XCTAssert(m2.str == "bar")
}
}

0 comments on commit 56d2d8f

Please sign in to comment.