<commit_before>#if canImport(Combine)

import Foundation
import XCTest
import Combine
import APIKit

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
final class CombineTests: XCTestCase {

    var adapter: TestSessionAdapter!
    var session: Session!
    var cancellables: Set<AnyCancellable> = []

    override func setUp() {
        super.setUp()
        adapter = TestSessionAdapter()
        session = Session(adapter: adapter)
    }

    override func tearDown() {
        super.tearDown()
        cancellables = []
    }

    func testSuccess() {
        let dictionary = ["key": "value"]
        adapter.data = try! JSONSerialization.data(withJSONObject: dictionary, options: [])

        let expectation = self.expectation(description: "wait for response")
        let request = TestRequest()

        session.publisher(request)
            .sink { completion in
                switch completion {
                case .failure:
                    XCTFail()
                case .finished:
                    expectation.fulfill()
                }
            } receiveValue: { response in
                XCTAssertEqual((response as? [String: String])?["key"], "value")
            }
            .store(in: &cancellables)

        waitForExpectations(timeout: 1.0, handler: nil)
    }

    func testParseDataError() {
        adapter.data = "{\"broken\": \"json}".data(using: .utf8, allowLossyConversion: false)

        let expectation = self.expectation(description: "wait for response")
        let request = TestRequest()

        session.publisher(request)
            .sink { completion in
                if case .failure(let error) = completion, case .responseError(let responseError as NSError) = error {
                    XCTAssertEqual(responseError.domain, NSCocoaErrorDomain)
                    XCTAssertEqual(responseError.code, 3840)
                } else {
                    XCTFail()
                }
                expectation.fulfill()
            } receiveValue: { response in
                XCTFail()
            }
            .store(in: &cancellables)

        waitForExpectations(timeout: 1.0, handler: nil)
    }

    func testCancel() {
        let expectation = self.expectation(description: "wait for response")
        let request = TestRequest()

        let cancellable = session.publisher(request)
            .sink { completion in
                if case .failure(let error) = completion, case .connectionError(let connectionError as NSError) = error {
                    XCTAssertEqual(connectionError.code, 0)
                } else {
                    XCTFail()
                }
                expectation.fulfill()
            } receiveValue: { response in
                XCTFail()
            }

        cancellable.cancel()

        waitForExpectations(timeout: 1.0, handler: nil)
    }

}

#endif
<commit_msg>fix compile error<commit_after>#if canImport(Combine)

import Foundation
import XCTest
import Combine
import APIKit

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
final class CombineTests: XCTestCase {

    var adapter: TestSessionAdapter!
    var session: Session!
    var cancellables: Set<AnyCancellable> = []

    override func setUp() {
        super.setUp()
        adapter = TestSessionAdapter()
        session = Session(adapter: adapter)
    }

    override func tearDown() {
        super.tearDown()
        cancellables = []
    }

    func testSuccess() {
        let dictionary = ["key": "value"]
        adapter.data = try! JSONSerialization.data(withJSONObject: dictionary, options: [])

        let expectation = self.expectation(description: "wait for response")
        let request = TestRequest()

        session.publisher(request)
            .sink(receiveCompletion: { completion in
                switch completion {
                case .failure:
                    XCTFail()
                case .finished:
                    expectation.fulfill()
                }
            }, receiveValue: { response in
                XCTAssertEqual((response as? [String: String])?["key"], "value")
            })
            .store(in: &cancellables)

        waitForExpectations(timeout: 1.0, handler: nil)
    }

    func testParseDataError() {
        adapter.data = "{\"broken\": \"json}".data(using: .utf8, allowLossyConversion: false)

        let expectation = self.expectation(description: "wait for response")
        let request = TestRequest()

        session.publisher(request)
            .sink(receiveCompletion: { completion in
                if case .failure(let error) = completion, case .responseError(let responseError as NSError) = error {
                    XCTAssertEqual(responseError.domain, NSCocoaErrorDomain)
                    XCTAssertEqual(responseError.code, 3840)
                    expectation.fulfill()
                } else {
                    XCTFail()
                }
            }, receiveValue: { response in
                XCTFail()
            })
            .store(in: &cancellables)

        waitForExpectations(timeout: 1.0, handler: nil)
    }

    func testCancel() {
        let expectation = self.expectation(description: "wait for response")
        let request = TestRequest()

        let cancellable = session.publisher(request)
            .sink(receiveCompletion: { completion in
                if case .failure(let error) = completion, case .connectionError(let connectionError as NSError) = error {
                    XCTAssertEqual(connectionError.code, 0)
                    expectation.fulfill()
                } else {
                    XCTFail()
                }
            }, receiveValue: { response in
                XCTFail()
            })

        cancellable.cancel()

        waitForExpectations(timeout: 1.0, handler: nil)
    }

}

#endif

{'fraction_non_alphanumeric': 0.09515659763819956, 'fraction_numerical': 0.007188088310799247, 'mean_word_length': 1.8272859216255444, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5890274', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1478, 'n_words': 368}