Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit 28e59f8

Browse files
authored
Fix Linux build (#12)
* `NSError()` is not available on Linux * Import Foundation and fulfill expectations explicitly in a closure * Fix incorrect import * Enumerate all tests to run on Linux * Fix incorrect declaration of tests
1 parent f82f75d commit 28e59f8

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

Sources/ReactiveArray.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ extension ReactiveArray {
3333

3434
public var producer: SignalProducer<Change, NoError> {
3535
return SignalProducer<Change, NSError>.attempt { [weak self] in
36-
guard let `self` = self else { return .failure(NSError()) }
36+
guard let `self` = self
37+
else { return .failure(NSError(domain: "org.RACCommunity.ReactiveCollections", code: 0, userInfo: nil)) }
3738

3839
return .success(
3940
Delta(

Tests/LinuxMain.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import XCTest
22
import Quick
33

4-
@testable import ReactiveSwiftTests
4+
@testable import ReactiveCollectionsTests
55

6-
XCTMain([ReactiveCollectionsTests.allTests()])
6+
XCTMain([
7+
testCase(ReactiveArrayTests.allTests)
8+
])
79
// Quick.QCKMain([])

Tests/ReactiveCollectionsTests/ReactiveArrayTests.swift

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Foundation
12
import XCTest
23
import ReactiveSwift
34
import Result
@@ -47,9 +48,9 @@ class ReactiveArrayTests: XCTestCase {
4748
var array = ReactiveArray([1, 2, 3]) as Optional
4849

4950

50-
_ = array?.signal.observeCompleted(completedExpectation.fulfill)
51+
_ = array?.signal.observeCompleted { completedExpectation.fulfill() }
5152

52-
_ = array?.signal.on(disposed: disposedExpectation.fulfill)
53+
_ = array?.signal.on(disposed: { disposedExpectation.fulfill() })
5354

5455
array = nil
5556

@@ -659,6 +660,48 @@ class ReactiveArrayTests: XCTestCase {
659660
}
660661
}
661662

663+
// MARK: - Linux support
664+
665+
#if os(Linux)
666+
extension ReactiveArrayTests {
667+
668+
static var allTests: [(String, (ReactiveArrayTests) -> () throws -> Void)] {
669+
return [
670+
("test_initializer", test_initializer),
671+
("test_empty_initializer", test_empty_initializer),
672+
("test_literal_initializer", test_literal_initializer),
673+
("test_repeating_initializer", test_repeating_initializer),
674+
("test_lifecycle", test_lifecycle),
675+
("test_count", test_count),
676+
("test_first", test_first),
677+
("test_is_empty", test_is_empty),
678+
("test_end_index", test_end_index),
679+
("test_start_index", test_start_index),
680+
("test_subscripting_access", test_subscripting_access),
681+
("test_subscripting_replace_at_head", test_subscripting_replace_at_head),
682+
("test_replace_range", test_replace_range),
683+
("test_append", test_append),
684+
("test_append_contents_of", test_append_contents_of),
685+
("test_insert_at_index", test_insert_at_index),
686+
("test_insert_contents_of", test_insert_contents_of),
687+
("test_remove_all", test_remove_all),
688+
("test_remove_all_and_keep_capacity", test_remove_all_and_keep_capacity),
689+
("test_remove_first", test_remove_first),
690+
("test_remove_first2", test_remove_first2),
691+
("test_remove_first_all", test_remove_first_all),
692+
("test_remove_last", test_remove_last),
693+
("test_remove_last2", test_remove_last2),
694+
("test_remove_last_all", test_remove_last_all),
695+
("test_remove_at_index", test_remove_at_index),
696+
("test_remove_subrange", test_remove_subrange),
697+
("test_producer", test_producer),
698+
("test_producer_with_up_to_date_changes", test_producer_with_up_to_date_changes),
699+
("test_producer_not_retaining_array", test_producer_not_retaining_array)
700+
]
701+
}
702+
}
703+
#endif
704+
662705
// MARK: - Helpers
663706

664707
func XCTAssertEqual<T>(

0 commit comments

Comments
 (0)