-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
Sources/GenericProtocolVariable/Helper+abstractFunction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
// | ||
/* | ||
/* | ||
* Created by 游宗諭 in 2021/8/4 | ||
* | ||
* | ||
* Using Swift 5.0 | ||
* | ||
* | ||
* Running on macOS 12.0 | ||
*/ | ||
|
||
|
||
|
||
func abstractFunction(file: StaticString = #file, line: UInt = #line) -> Never{ | ||
func abstractFunction(file: StaticString = #file, line: UInt = #line) -> Never { | ||
fatalError("abstract Function should never be call", file: file, line: line) | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/GenericProtocolVariable/ReturnSelf/ReturnSelf.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
/* | ||
* Created by 游宗諭 in 2021/8/4 | ||
* | ||
* Using Swift 5.0 | ||
* | ||
* Running on macOS 12.0 | ||
*/ | ||
|
||
public protocol ReturnSelf { | ||
static func dequeue() -> ReturnSelf | ||
var name: String { get } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
import GenericProtocolVariable | ||
import XCTest | ||
|
||
|
||
// MARK: - Tests | ||
|
||
final class Tests: XCTestCase { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
/* | ||
* Created by 游宗諭 in 2021/8/5 | ||
* | ||
* Using Swift 5.0 | ||
* | ||
* Running on macOS 12.0 | ||
*/ | ||
|
||
import GenericProtocolVariable | ||
|
||
// MARK: - TableViewCell | ||
|
||
class TableViewCell: ReturnSelf { | ||
var name: String { "a name" } | ||
|
||
class func dequeue() -> ReturnSelf { | ||
TableViewCell() | ||
} | ||
} | ||
|
||
// MARK: - TestingReturnSelf | ||
|
||
class TestingReturnSelf: TableViewCell { | ||
override var name: String { | ||
"another name" | ||
} | ||
|
||
override class func dequeue() -> ReturnSelf { | ||
TestingReturnSelf() | ||
} | ||
} | ||
|
||
import XCTest | ||
|
||
// MARK: - ReturnSelfTests | ||
|
||
final class ReturnSelfTests: XCTestCase { | ||
func test() { | ||
let list: [ReturnSelf.Type] = [ | ||
TableViewCell.self, | ||
TestingReturnSelf.self, | ||
] | ||
|
||
let names = list | ||
.map { $0.dequeue() } | ||
.map(\.name) | ||
|
||
XCTAssertEqual(names, ["a name", | ||
"another name"]) | ||
} | ||
} |