Skip to content

Commit

Permalink
Revert "Await async process in unit tests"
Browse files Browse the repository at this point in the history
This reverts commit c186af3.
  • Loading branch information
1024jp committed Oct 2, 2024
1 parent 73fc6c7 commit 4aff102
Showing 1 changed file with 38 additions and 41 deletions.
79 changes: 38 additions & 41 deletions Tests/Sources/Models/EditorCounterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import Testing
}


@Test func allRequiredInfo() async throws {
@Test func allRequiredInfo() throws {

let source = Source(string: self.testString, selectedRange: NSRange(11..<21))

Expand All @@ -77,24 +77,23 @@ import Testing
counter.invalidateContent()
counter.invalidateSelection()

// wait for async process
try await Task.sleep(for: .seconds(0.5))

#expect(counter.result.lines.entire == 3)
#expect(counter.result.characters.entire == 31)
#expect(counter.result.words.entire == 6)

#expect(counter.result.characters.selected == 9)
#expect(counter.result.lines.selected == 1)
#expect(counter.result.words.selected == 2)

#expect(counter.result.location == 10)
#expect(counter.result.column == 0)
#expect(counter.result.line == 2)
withKnownIssue("values will be updated asynchronously (This is the issue on the test side.)") {
#expect(counter.result.lines.entire == 3)
#expect(counter.result.characters.entire == 31)
#expect(counter.result.words.entire == 6)

#expect(counter.result.characters.selected == 9)
#expect(counter.result.lines.selected == 1)
#expect(counter.result.words.selected == 2)

#expect(counter.result.location == 10)
#expect(counter.result.column == 0)
#expect(counter.result.line == 2)
}
}


@Test func skipWholeText() async throws {
@Test func skipWholeText() throws {

let source = Source(string: self.testString, selectedRange: NSRange(11..<21))

Expand All @@ -107,20 +106,19 @@ import Testing
#expect(counter.result.characters.entire == nil)
#expect(counter.result.words.entire == nil)

// wait for async process
try await Task.sleep(for: .seconds(0.5))

#expect(counter.result.lines.selected == 1)
#expect(counter.result.characters.selected == 9)
#expect(counter.result.words.selected == 2)

#expect(counter.result.location == 10)
#expect(counter.result.column == 0)
#expect(counter.result.line == 2)
withKnownIssue("values will be updated asynchronously (This is the issue on the test side.)") {
#expect(counter.result.lines.selected == 1)
#expect(counter.result.characters.selected == 9)
#expect(counter.result.words.selected == 2)

#expect(counter.result.location == 10)
#expect(counter.result.column == 0)
#expect(counter.result.line == 2)
}
}


@Test func crlf() async throws {
@Test func crlf() throws {

let source = Source(string: "a\r\nb", selectedRange: NSRange(1..<4))

Expand All @@ -130,20 +128,19 @@ import Testing
counter.invalidateContent()
counter.invalidateSelection()

// wait for async process
try await Task.sleep(for: .seconds(0.5))

#expect(counter.result.lines.entire == 2)
#expect(counter.result.characters.entire == 3)
#expect(counter.result.words.entire == 2)

#expect(counter.result.lines.selected == 2)
#expect(counter.result.characters.selected == 2)
#expect(counter.result.words.selected == 1)

#expect(counter.result.location == 1)
#expect(counter.result.column == 1)
#expect(counter.result.line == 1)
withKnownIssue("values will be updated asynchronously (This is the issue on the test side.)") {
#expect(counter.result.lines.entire == 2)
#expect(counter.result.characters.entire == 3)
#expect(counter.result.words.entire == 2)

#expect(counter.result.lines.selected == 2)
#expect(counter.result.characters.selected == 2)
#expect(counter.result.words.selected == 1)

#expect(counter.result.location == 1)
#expect(counter.result.column == 1)
#expect(counter.result.line == 1)
}
}


Expand Down

0 comments on commit 4aff102

Please sign in to comment.