Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add EM::Synchrony.sync for inline fiber sync (aka, inlineCallbacks in
Python)
- Loading branch information
Showing
2 changed files
with
63 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require "spec/helper/all" | ||
require "em-synchrony/iterator" | ||
|
||
describe EventMachine::Synchrony do | ||
|
||
URL = "http://localhost:8081/" | ||
DELAY = 0.01 | ||
|
||
it "should allow inline callbacks for Deferrable object" do | ||
EM.synchrony do | ||
s = StubServer.new("HTTP/1.0 200 OK\r\nConnection: close\r\n\r\nFoo", DELAY) | ||
|
||
result = EM::Synchrony.sync EventMachine::HttpRequest.new(URL).aget | ||
result.response.should match(/Foo/) | ||
|
||
EM.stop | ||
end | ||
end | ||
|
||
it "should inline errback/callback cases" do | ||
EM.synchrony do | ||
class E | ||
include EventMachine::Deferrable | ||
def run | ||
EM.add_timer(0.01) {fail("uh oh!")} | ||
self | ||
end | ||
end | ||
|
||
result = EM::Synchrony.sync E.new.run | ||
result.should match(/uh oh!/) | ||
|
||
EM.stop | ||
end | ||
end | ||
|
||
end |
Typo: methond to method