File: synchrony_spec.rb

package info (click to toggle)
ruby-em-synchrony 1.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 556 kB
  • ctags: 304
  • sloc: ruby: 3,508; sh: 37; sql: 7; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 856 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require "helper/all"

describe EM::Synchrony do
  describe "#sync" do
    it "returns immediately if the syncee already succeeded" do
      args = stub("args")

      Fiber.new {
        df = EM::DefaultDeferrable.new
        df.succeed args
        EM::Synchrony.sync(df).should == args

        df = EM::DefaultDeferrable.new
        df.succeed nil
        EM::Synchrony.sync(df).should == nil
      }.resume
    end
  end

  describe "#next_tick" do
    xit "should wrap next_tick into a Fiber context" do
      EM.synchrony {
        begin
          fired = false
          f = Fiber.current

          EM::Synchrony.next_tick do
            fired = true
            Fiber.current.should_not eq(f)
          end

          EM::Synchrony.interrupt

          fired.should eq(true)
        ensure
          EM.stop
        end
      }
    end
  end

end