-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·46 lines (40 loc) · 918 Bytes
/
test
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
43
44
45
46
#!/usr/bin/ruby
# encoding: utf-8
# (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
$:.push("./lib")
$:.unshift("./lib")
require "callback-locker"
require "riot"
context "CallbackLocker" do
setup do
CallbackLocker::new
end
asserts("#initialize") do
not topic.locked? and topic.stack == [ ]
end
asserts("#lock, #locked?") do
topic.lock
topic.locked?
end
asserts("#unlock, #unlocked?") do
topic.unlock
topic.unlocked?
end
asserts("#synchronize") do
foo1 = nil
topic.synchronize do
foo1 = :a
end
foo2 = nil
topic.lock!
topic.synchronize do
foo2 = "1"
end
topic.synchronize do
foo2 << "2"
end
foo3 = foo2
topic.unlock!
foo1 == :a and foo2 == "12" and foo3.nil?
end
end