Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulofaria committed May 20, 2017
1 parent f18c421 commit 9f8a358
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Tests/VeniceTests/Venice/ChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public class ChannelTests : XCTestCase {
try channel2.send(0, deadline: .never)
}

try channel1.done()
channel1.done()

XCTAssertEqual(try channel2.receive(deadline: .never), 0)
XCTAssertEqual(try channel2.receive(deadline: .never), 0)
Expand Down
34 changes: 4 additions & 30 deletions Tests/VeniceTests/Venice/CoroutineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,6 @@ public class CoroutineTests : XCTestCase {

group.cancel()
}

func testPollFileDescriptor() throws {
let deadline = 1.second.fromNow()
let (socket1, socket2) = try createSocketPair()

try socket1.poll(event: .write, deadline: deadline)
try socket1.poll(event: .write, deadline: deadline)

XCTAssertThrowsError(
try socket1.poll(event: .read, deadline: deadline),
error: VeniceError.deadlineReached
)

var size = send(socket2.handle, "A", 1, 0)
XCTAssertEqual(size, 1)

try socket1.poll(event: .write, deadline: deadline)
try socket1.poll(event: .read, deadline: deadline)

var character: Int8 = 0
size = recv(socket1.handle, &character, 1, 0)

XCTAssertEqual(size, 1)
XCTAssertEqual(character, 65)
}

func testReadWriteFileDescriptor() throws {
let deadline = 1.second.fromNow()
Expand Down Expand Up @@ -173,7 +148,7 @@ public class CoroutineTests : XCTestCase {

let coroutine = try Coroutine {
XCTAssertThrowsError(
try socket1.poll(event: .read, deadline: .never),
try FileDescriptor.poll(socket1.handle, event: .read, deadline: .never),
error: VeniceError.canceledCoroutine
)
}
Expand All @@ -186,14 +161,14 @@ public class CoroutineTests : XCTestCase {

let coroutine1 = try Coroutine {
XCTAssertThrowsError(
try socket1.poll(event: .read, deadline: .never),
try FileDescriptor.poll(socket1.handle, event: .read, deadline: .never),
error: VeniceError.canceledCoroutine
)
}

let coroutine2 = try Coroutine {
XCTAssertThrowsError(
try socket1.poll(event: .read, deadline: .never),
try FileDescriptor.poll(socket1.handle, event: .read, deadline: .never),
error: VeniceError.fileDescriptorBlockedInAnotherCoroutine
)
}
Expand All @@ -219,7 +194,7 @@ public class CoroutineTests : XCTestCase {
XCTAssertEqual(fileDescriptor.handle, -1)

XCTAssertThrowsError(
try fileDescriptor.poll(event: .read, deadline: .never),
try FileDescriptor.poll(fileDescriptor.handle, event: .read, deadline: .never),
error: VeniceError.invalidFileDescriptor
)
}
Expand Down Expand Up @@ -258,7 +233,6 @@ extension CoroutineTests {
("testWakeUp", testWakeUp),
("testWakeUpOnCanceledCoroutine", testWakeUpOnCanceledCoroutine),
("testWakeUpWithChannels", testWakeUpWithChannels),
("testPollFileDescriptor", testPollFileDescriptor),
("testReadWriteFileDescriptor", testReadWriteFileDescriptor),
("testInvalidFileDescriptor", testInvalidFileDescriptor),
("testPollOnCanceledCoroutine", testPollOnCanceledCoroutine),
Expand Down

0 comments on commit 9f8a358

Please sign in to comment.