linda 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/README.md +77 -6
- data/lib/linda/test/tuple.rb +56 -0
- data/lib/linda/test/tuplespace.rb +134 -0
- data/lib/linda/version.rb +1 -1
- data/test/test_tuple.rb +4 -47
- data/test/test_tuplespace.rb +6 -124
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70d0f9c426b9d5b9aaf4105883f9a5e63a1aecb1
|
4
|
+
data.tar.gz: a4ff1571d734b2c0d7064edb2c7475a9b7c41584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c24929e587bd7a72822e61d1ddf01d38a7a9194f2b542041d9231fa69a3a82e1e9fec84988d0199a134bc3b50efa08561cebda2b57facd07ac6dae8301118df4
|
7
|
+
data.tar.gz: b7b1248e760c20aff1fa7736ba205d6f345848d8585066dc999d4d5d15628908ce8320179226a9709fd136dd2bae1656be3470f92519b32032936290671bddc1
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -60,46 +60,117 @@ Linda::Tuple.new(:a => 1, :b => 2).match?(:a => 1, :b => 5) # => false
|
|
60
60
|
Tuple/TupleSpace Functions
|
61
61
|
--------------------------
|
62
62
|
|
63
|
-
### TupleSpace#write(
|
63
|
+
### TupleSpace#write(tuple, options={})
|
64
64
|
|
65
65
|
- write a Tuple into TupleSpace.
|
66
66
|
- default : options = {:expire => 300}
|
67
67
|
- expire 300(sec) after.
|
68
68
|
- similar to `out` function in C-Linda.
|
69
69
|
|
70
|
-
### TupleSpace#read(
|
70
|
+
### TupleSpace#read(tuple)
|
71
71
|
|
72
72
|
- return a Tuple which matches in TupleSpace. return `nil` if not exists.
|
73
73
|
- similar to `rdp` function in C-Linda.
|
74
74
|
|
75
75
|
|
76
|
-
### TupleSpace#read(
|
76
|
+
### TupleSpace#read(tuple, &callback(tuple))
|
77
77
|
|
78
78
|
- callback a Tuple which matches in TupleSpace. wait until available.
|
79
79
|
- async function : it does not return a value.
|
80
80
|
- similar to `rd` function in C-Linda.
|
81
81
|
|
82
82
|
|
83
|
-
### TupleSpace#take(
|
83
|
+
### TupleSpace#take(tuple)
|
84
84
|
|
85
85
|
- delete a Tuple, then return it which matches in TupleSpace. return `nil` if not exists.
|
86
86
|
- similar to `inp` function in C-Linda.
|
87
87
|
|
88
88
|
|
89
|
-
### TupleSpace#take(
|
89
|
+
### TupleSpace#take(tuple, &callback(tuple))
|
90
90
|
|
91
91
|
- delete a Tuple, then callback it which matches in TupleSpace. wait until available.
|
92
92
|
- async function : it does not return a value.
|
93
93
|
- similar to `in` function in C-Linda.
|
94
94
|
|
95
95
|
|
96
|
-
### TupleSpace#watch(
|
96
|
+
### TupleSpace#watch(tuple, &callback(tuple))
|
97
97
|
|
98
98
|
- callback Tuples which matches when TupleSpace#write(tuple) is called.
|
99
99
|
|
100
100
|
|
101
|
+
Test your Linda implementation
|
102
|
+
------------------------------
|
103
|
+
|
104
|
+
with [minitest](https://github.com/seattlerb/minitest).
|
105
|
+
|
106
|
+
### Test Tuple
|
107
|
+
|
108
|
+
`test/test_tuple.rb`
|
109
|
+
```ruby
|
110
|
+
require 'rubygems'
|
111
|
+
require 'minitest/autorun'
|
112
|
+
require 'linda/test/tuple'
|
113
|
+
require 'path/to/my/linda/tuple' # load your Tuple class
|
114
|
+
|
115
|
+
class TestMyTuple < MiniTest::Test
|
116
|
+
include Linda::Test::Tuple # mix-in test code
|
117
|
+
|
118
|
+
def target_tuple
|
119
|
+
My::Linda::Tuple # set your Tuple class name
|
120
|
+
end
|
121
|
+
end
|
122
|
+
```
|
123
|
+
|
124
|
+
% ruby test/test_tuple.rb
|
125
|
+
|
126
|
+
|
127
|
+
### Test TupleSpace
|
128
|
+
|
129
|
+
`test/test_tuplespace.rb`
|
130
|
+
```ruby
|
131
|
+
require 'rubygems'
|
132
|
+
require 'minitest/autorun'
|
133
|
+
require 'linda/test/tuplespace'
|
134
|
+
require 'path/to/my/linda/tuple' # load your Tuple class
|
135
|
+
require 'path/to/my/linda/tuplespace' # load your TupleSpace class
|
136
|
+
|
137
|
+
class TestMyTupleSpace < MiniTest::Test
|
138
|
+
include Linda::Test::TupleSpace # mix-in test code
|
139
|
+
|
140
|
+
def target_tuple
|
141
|
+
My::Linda::Tuple # set your Tuple class name
|
142
|
+
end
|
143
|
+
|
144
|
+
def target_tuplespace
|
145
|
+
My::Linda::TupleSpace # set your TupleSpace class name
|
146
|
+
end
|
147
|
+
end
|
148
|
+
```
|
149
|
+
|
150
|
+
% ruby test/test_tuplespace.rb
|
151
|
+
|
152
|
+
|
153
|
+
### Rake
|
154
|
+
|
155
|
+
`Rakefile`
|
156
|
+
```ruby
|
157
|
+
require "rake/testtask"
|
158
|
+
|
159
|
+
Rake::TestTask.new do |t|
|
160
|
+
t.pattern = "test/test_*.rb"
|
161
|
+
end
|
162
|
+
|
163
|
+
task :default => :test
|
164
|
+
```
|
165
|
+
|
166
|
+
% rake test
|
167
|
+
|
168
|
+
=> run all tests
|
169
|
+
|
170
|
+
|
101
171
|
Test
|
102
172
|
----
|
173
|
+
test this gem
|
103
174
|
|
104
175
|
% gem install bundler
|
105
176
|
% bundle install
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Linda
|
2
|
+
module Test
|
3
|
+
module Tuple
|
4
|
+
|
5
|
+
def test_match_array_tuple
|
6
|
+
tuple = target_tuple.new [1,2,3]
|
7
|
+
assert tuple.match? target_tuple.new [1,2,3]
|
8
|
+
assert tuple.match? target_tuple.new [1,2,3,4]
|
9
|
+
assert !tuple.match?(target_tuple.new [1,2])
|
10
|
+
assert !tuple.match?(target_tuple.new [1,"a",3])
|
11
|
+
assert !tuple.match?(target_tuple.new :a => 1, :b => 2)
|
12
|
+
tuple = target_tuple.new ["a","b","c"]
|
13
|
+
assert tuple.match? target_tuple.new ["a","b","c"]
|
14
|
+
assert tuple.match? target_tuple.new ["a","b","c","d","efg",123,"h"]
|
15
|
+
assert !tuple.match?(target_tuple.new ["a","b"])
|
16
|
+
assert !tuple.match?(target_tuple.new ["a","b",789])
|
17
|
+
assert !tuple.match?(target_tuple.new :foo => 1, :bar => 2)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_match_array
|
21
|
+
tuple = target_tuple.new [1,2,3]
|
22
|
+
assert tuple.match? [1,2,3]
|
23
|
+
assert tuple.match? [1,2,3,4]
|
24
|
+
assert !tuple.match?([1,2])
|
25
|
+
assert !tuple.match?([1,"a",3])
|
26
|
+
assert !tuple.match?(:a => 1, :b => 2)
|
27
|
+
tuple = target_tuple.new ["a","b","c"]
|
28
|
+
assert tuple.match? ["a","b","c"]
|
29
|
+
assert tuple.match? ["a","b","c","d","efg",123,"h"]
|
30
|
+
assert !tuple.match?(["a","b"])
|
31
|
+
assert !tuple.match?(["a","b",789])
|
32
|
+
assert !tuple.match?(:foo => 1, :bar => 2)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_match_hash_tuple
|
36
|
+
tuple = target_tuple.new :a => 1, :b => 2
|
37
|
+
assert tuple.match? target_tuple.new :a => 1, :b => 2
|
38
|
+
assert tuple.match? target_tuple.new :a => 1, :b => 2, :c => 3
|
39
|
+
assert tuple.match? target_tuple.new :a => 1, :b => 2, :c => {:foo => "bar"}
|
40
|
+
assert !tuple.match?(target_tuple.new :a => 0, :b => 2)
|
41
|
+
assert !tuple.match?(target_tuple.new :b => 2, :c => 3)
|
42
|
+
assert !tuple.match?(target_tuple.new [1,2,3])
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_match_hash
|
46
|
+
tuple = target_tuple.new :a => 1, :b => 2
|
47
|
+
assert tuple.match? :a => 1, :b => 2
|
48
|
+
assert tuple.match? :a => 1, :b => 2, :c => 3
|
49
|
+
assert tuple.match? :a => 1, :b => 2, :c => {:foo => "bar"}
|
50
|
+
assert !tuple.match?(:a => 0, :b => 2)
|
51
|
+
assert !tuple.match?(:b => 2, :c => 3)
|
52
|
+
assert !tuple.match?([1,2,3])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Linda
|
2
|
+
module Test
|
3
|
+
module TupleSpace
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@space = target_tuplespace.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_write_read
|
10
|
+
assert_equal @space.size, 0
|
11
|
+
@space.write target_tuple.new [1,2,3]
|
12
|
+
assert_equal @space.size, 1
|
13
|
+
assert_equal @space.read([1,2]).data, [1,2,3]
|
14
|
+
@space.write :a => 1, :b => 2, :c => 999
|
15
|
+
@space.write :a => 1, :b => 2, :c => 3
|
16
|
+
assert_equal @space.size, 3
|
17
|
+
assert_equal @space.read(:a => 1, :c => 999).data, {:a => 1, :b => 2, :c => 999}
|
18
|
+
assert_equal @space.read(:a => 1, :c => 999).data, {:a => 1, :b => 2, :c => 999}
|
19
|
+
assert_equal @space.read(:a => 1).data, {:a => 1, :b => 2, :c => 3}
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_write_read_callback
|
23
|
+
assert_equal @space.size, 0
|
24
|
+
_tuple1 = nil
|
25
|
+
@space.read [1,2] do |tuple|
|
26
|
+
_tuple1 = tuple
|
27
|
+
end
|
28
|
+
_tuple2 = nil
|
29
|
+
@space.read [1,"a"] do |tuple|
|
30
|
+
_tuple2 = tuple
|
31
|
+
end
|
32
|
+
_tuple3 = nil
|
33
|
+
@space.read [1,2,3] do |tuple|
|
34
|
+
_tuple3 = tuple
|
35
|
+
end
|
36
|
+
@space.write [1,2,3]
|
37
|
+
assert_equal _tuple1.data, [1,2,3]
|
38
|
+
assert_equal _tuple2, nil
|
39
|
+
assert_equal _tuple3.data, [1,2,3]
|
40
|
+
assert_equal @space.read([1]).data, [1,2,3]
|
41
|
+
assert_equal @space.size, 1
|
42
|
+
@space.write [1,2,4]
|
43
|
+
assert_equal _tuple1.data, [1,2,3]
|
44
|
+
assert_equal @space.size, 2
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_take
|
48
|
+
assert_equal @space.size, 0
|
49
|
+
1.upto(3) do |i|
|
50
|
+
@space.write [1,2,3,"a"*i]
|
51
|
+
end
|
52
|
+
assert_equal @space.size, 3
|
53
|
+
assert_equal @space.take([1,2,3]).data, [1,2,3,"aaa"]
|
54
|
+
assert_equal @space.size, 2
|
55
|
+
@space.write :a => 1, :b => 2, :c => 3
|
56
|
+
assert_equal @space.size, 3
|
57
|
+
assert_equal @space.take([1,3]), nil
|
58
|
+
assert_equal @space.take(:a => 1, :b => 2, :c => 4), nil
|
59
|
+
assert_equal @space.take([1,2,3]).data, [1,2,3,"aa"]
|
60
|
+
assert_equal @space.size, 2
|
61
|
+
assert_equal @space.take([1,2,3]).data, [1,2,3,"a"]
|
62
|
+
assert_equal @space.size, 1
|
63
|
+
assert_equal @space.take(:b => 2, :a => 1).data, {:a => 1, :b => 2, :c => 3}
|
64
|
+
assert_equal @space.size, 0
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_take_callback
|
68
|
+
assert_equal @space.size, 0
|
69
|
+
_tuple1 = nil
|
70
|
+
@space.take [1,2] do |tuple|
|
71
|
+
_tuple1 = tuple
|
72
|
+
end
|
73
|
+
_tuple2 = nil
|
74
|
+
@space.take [1,"a"] do |tuple|
|
75
|
+
_tuple2 = tuple
|
76
|
+
end
|
77
|
+
_tuple3 = nil
|
78
|
+
@space.read [1,2,3] do |tuple|
|
79
|
+
_tuple3 = tuple
|
80
|
+
end
|
81
|
+
_tuple4 = nil
|
82
|
+
@space.take [1,2,3] do |tuple|
|
83
|
+
_tuple4 = tuple
|
84
|
+
end
|
85
|
+
1.upto(3) do |i|
|
86
|
+
@space.write [1,2,3,"a"*i]
|
87
|
+
end
|
88
|
+
assert_equal @space.size, 1
|
89
|
+
assert_equal _tuple1.data, [1,2,3,"a"]
|
90
|
+
assert_equal _tuple2, nil
|
91
|
+
assert_equal _tuple3.data, [1,2,3,"aa"]
|
92
|
+
assert_equal _tuple4.data, [1,2,3,"aa"]
|
93
|
+
assert_equal @space.take([1]).data, [1,2,3,"aaa"]
|
94
|
+
assert_equal @space.size, 0
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_watch
|
98
|
+
assert_equal @space.size, 0
|
99
|
+
_tuple1 = nil
|
100
|
+
@space.take [1] do |tuple|
|
101
|
+
_tuple1 = tuple
|
102
|
+
end
|
103
|
+
results = []
|
104
|
+
@space.watch [1,2] do |tuple|
|
105
|
+
results << tuple
|
106
|
+
end
|
107
|
+
@space.write [1,2,3]
|
108
|
+
@space.write [1,2,"aa"]
|
109
|
+
@space.write [1,"a",3]
|
110
|
+
assert_equal _tuple1.data, [1,2,3]
|
111
|
+
assert_equal @space.size, 2
|
112
|
+
assert_equal results.size, 2
|
113
|
+
assert_equal results[0].data, [1,2,3]
|
114
|
+
assert_equal results[1].data, [1,2,"aa"]
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_tuple_expire
|
118
|
+
@space.write [1,2,999], :expire => false
|
119
|
+
@space.write [1,2,3], :expire => 3
|
120
|
+
@space.write [1,2,"a","b"], :expire => 2
|
121
|
+
assert_equal @space.size, 3
|
122
|
+
sleep 2
|
123
|
+
@space.check_expire
|
124
|
+
assert_equal @space.size, 2
|
125
|
+
assert_equal @space.take([1,2]).data, [1,2,3]
|
126
|
+
assert_equal @space.size, 1
|
127
|
+
sleep 1
|
128
|
+
assert_equal @space.take([1,2]).data, [1,2,999]
|
129
|
+
assert_equal @space.size, 0
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/lib/linda/version.rb
CHANGED
data/test/test_tuple.rb
CHANGED
@@ -1,53 +1,10 @@
|
|
1
1
|
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
2
|
+
require 'linda/test/tuple'
|
2
3
|
|
3
4
|
class TestTuple < MiniTest::Test
|
4
|
-
|
5
|
-
tuple = Linda::Tuple.new [1,2,3]
|
6
|
-
assert tuple.match? Linda::Tuple.new [1,2,3]
|
7
|
-
assert tuple.match? Linda::Tuple.new [1,2,3,4]
|
8
|
-
assert !tuple.match?(Linda::Tuple.new [1,2])
|
9
|
-
assert !tuple.match?(Linda::Tuple.new [1,"a",3])
|
10
|
-
assert !tuple.match?(Linda::Tuple.new :a => 1, :b => 2)
|
11
|
-
tuple = Linda::Tuple.new ["a","b","c"]
|
12
|
-
assert tuple.match? Linda::Tuple.new ["a","b","c"]
|
13
|
-
assert tuple.match? Linda::Tuple.new ["a","b","c","d","efg",123,"h"]
|
14
|
-
assert !tuple.match?(Linda::Tuple.new ["a","b"])
|
15
|
-
assert !tuple.match?(Linda::Tuple.new ["a","b",789])
|
16
|
-
assert !tuple.match?(Linda::Tuple.new :foo => 1, :bar => 2)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_match_array
|
20
|
-
tuple = Linda::Tuple.new [1,2,3]
|
21
|
-
assert tuple.match? [1,2,3]
|
22
|
-
assert tuple.match? [1,2,3,4]
|
23
|
-
assert !tuple.match?([1,2])
|
24
|
-
assert !tuple.match?([1,"a",3])
|
25
|
-
assert !tuple.match?(:a => 1, :b => 2)
|
26
|
-
tuple = Linda::Tuple.new ["a","b","c"]
|
27
|
-
assert tuple.match? ["a","b","c"]
|
28
|
-
assert tuple.match? ["a","b","c","d","efg",123,"h"]
|
29
|
-
assert !tuple.match?(["a","b"])
|
30
|
-
assert !tuple.match?(["a","b",789])
|
31
|
-
assert !tuple.match?(:foo => 1, :bar => 2)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_match_hash_tuple
|
35
|
-
tuple = Linda::Tuple.new :a => 1, :b => 2
|
36
|
-
assert tuple.match? Linda::Tuple.new :a => 1, :b => 2
|
37
|
-
assert tuple.match? Linda::Tuple.new :a => 1, :b => 2, :c => 3
|
38
|
-
assert tuple.match? Linda::Tuple.new :a => 1, :b => 2, :c => {:foo => "bar"}
|
39
|
-
assert !tuple.match?(Linda::Tuple.new :a => 0, :b => 2)
|
40
|
-
assert !tuple.match?(Linda::Tuple.new :b => 2, :c => 3)
|
41
|
-
assert !tuple.match?(Linda::Tuple.new [1,2,3])
|
42
|
-
end
|
5
|
+
include Linda::Test::Tuple
|
43
6
|
|
44
|
-
def
|
45
|
-
|
46
|
-
assert tuple.match? :a => 1, :b => 2
|
47
|
-
assert tuple.match? :a => 1, :b => 2, :c => 3
|
48
|
-
assert tuple.match? :a => 1, :b => 2, :c => {:foo => "bar"}
|
49
|
-
assert !tuple.match?(:a => 0, :b => 2)
|
50
|
-
assert !tuple.match?(:b => 2, :c => 3)
|
51
|
-
assert !tuple.match?([1,2,3])
|
7
|
+
def target_tuple
|
8
|
+
Linda::Tuple
|
52
9
|
end
|
53
10
|
end
|
data/test/test_tuplespace.rb
CHANGED
@@ -1,132 +1,14 @@
|
|
1
1
|
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
2
|
+
require 'linda/test/tuplespace'
|
2
3
|
|
3
4
|
class TestTupleSpace < MiniTest::Test
|
5
|
+
include Linda::Test::TupleSpace
|
4
6
|
|
5
|
-
def
|
6
|
-
|
7
|
+
def target_tuplespace
|
8
|
+
Linda::TupleSpace
|
7
9
|
end
|
8
10
|
|
9
|
-
def
|
10
|
-
|
11
|
-
@space.write Linda::Tuple.new [1,2,3]
|
12
|
-
assert_equal @space.size, 1
|
13
|
-
assert_equal @space.read([1,2]).data, [1,2,3]
|
14
|
-
@space.write :a => 1, :b => 2, :c => 999
|
15
|
-
@space.write :a => 1, :b => 2, :c => 3
|
16
|
-
assert_equal @space.size, 3
|
17
|
-
assert_equal @space.read(:a => 1, :c => 999).data, {:a => 1, :b => 2, :c => 999}
|
18
|
-
assert_equal @space.read(:a => 1, :c => 999).data, {:a => 1, :b => 2, :c => 999}
|
19
|
-
assert_equal @space.read(:a => 1).data, {:a => 1, :b => 2, :c => 3}
|
11
|
+
def target_tuple
|
12
|
+
Linda::Tuple
|
20
13
|
end
|
21
|
-
|
22
|
-
def test_write_read_callback
|
23
|
-
assert_equal @space.size, 0
|
24
|
-
_tuple1 = nil
|
25
|
-
@space.read [1,2] do |tuple|
|
26
|
-
_tuple1 = tuple
|
27
|
-
end
|
28
|
-
_tuple2 = nil
|
29
|
-
@space.read [1,"a"] do |tuple|
|
30
|
-
_tuple2 = tuple
|
31
|
-
end
|
32
|
-
_tuple3 = nil
|
33
|
-
@space.read [1,2,3] do |tuple|
|
34
|
-
_tuple3 = tuple
|
35
|
-
end
|
36
|
-
@space.write [1,2,3]
|
37
|
-
assert_equal _tuple1.data, [1,2,3]
|
38
|
-
assert_equal _tuple2, nil
|
39
|
-
assert_equal _tuple3.data, [1,2,3]
|
40
|
-
assert_equal @space.read([1]).data, [1,2,3]
|
41
|
-
assert_equal @space.size, 1
|
42
|
-
@space.write [1,2,4]
|
43
|
-
assert_equal _tuple1.data, [1,2,3]
|
44
|
-
assert_equal @space.size, 2
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_take
|
48
|
-
assert_equal @space.size, 0
|
49
|
-
1.upto(3) do |i|
|
50
|
-
@space.write [1,2,3,"a"*i]
|
51
|
-
end
|
52
|
-
assert_equal @space.size, 3
|
53
|
-
assert_equal @space.take([1,2,3]).data, [1,2,3,"aaa"]
|
54
|
-
assert_equal @space.size, 2
|
55
|
-
@space.write :a => 1, :b => 2, :c => 3
|
56
|
-
assert_equal @space.size, 3
|
57
|
-
assert_equal @space.take([1,3]), nil
|
58
|
-
assert_equal @space.take(:a => 1, :b => 2, :c => 4), nil
|
59
|
-
assert_equal @space.take([1,2,3]).data, [1,2,3,"aa"]
|
60
|
-
assert_equal @space.size, 2
|
61
|
-
assert_equal @space.take([1,2,3]).data, [1,2,3,"a"]
|
62
|
-
assert_equal @space.size, 1
|
63
|
-
assert_equal @space.take(:b => 2, :a => 1).data, {:a => 1, :b => 2, :c => 3}
|
64
|
-
assert_equal @space.size, 0
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_take_callback
|
68
|
-
assert_equal @space.size, 0
|
69
|
-
_tuple1 = nil
|
70
|
-
@space.take [1,2] do |tuple|
|
71
|
-
_tuple1 = tuple
|
72
|
-
end
|
73
|
-
_tuple2 = nil
|
74
|
-
@space.take [1,"a"] do |tuple|
|
75
|
-
_tuple2 = tuple
|
76
|
-
end
|
77
|
-
_tuple3 = nil
|
78
|
-
@space.read [1,2,3] do |tuple|
|
79
|
-
_tuple3 = tuple
|
80
|
-
end
|
81
|
-
_tuple4 = nil
|
82
|
-
@space.take [1,2,3] do |tuple|
|
83
|
-
_tuple4 = tuple
|
84
|
-
end
|
85
|
-
1.upto(3) do |i|
|
86
|
-
@space.write [1,2,3,"a"*i]
|
87
|
-
end
|
88
|
-
assert_equal @space.size, 1
|
89
|
-
assert_equal _tuple1.data, [1,2,3,"a"]
|
90
|
-
assert_equal _tuple2, nil
|
91
|
-
assert_equal _tuple3.data, [1,2,3,"aa"]
|
92
|
-
assert_equal _tuple4.data, [1,2,3,"aa"]
|
93
|
-
assert_equal @space.take([1]).data, [1,2,3,"aaa"]
|
94
|
-
assert_equal @space.size, 0
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_watch
|
98
|
-
assert_equal @space.size, 0
|
99
|
-
_tuple1 = nil
|
100
|
-
@space.take [1] do |tuple|
|
101
|
-
_tuple1 = tuple
|
102
|
-
end
|
103
|
-
results = []
|
104
|
-
@space.watch [1,2] do |tuple|
|
105
|
-
results << tuple
|
106
|
-
end
|
107
|
-
@space.write [1,2,3]
|
108
|
-
@space.write [1,2,"aa"]
|
109
|
-
@space.write [1,"a",3]
|
110
|
-
assert_equal _tuple1.data, [1,2,3]
|
111
|
-
assert_equal @space.size, 2
|
112
|
-
assert_equal results.size, 2
|
113
|
-
assert_equal results[0].data, [1,2,3]
|
114
|
-
assert_equal results[1].data, [1,2,"aa"]
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_tuple_expire
|
118
|
-
@space.write [1,2,999], :expire => false
|
119
|
-
@space.write [1,2,3], :expire => 3
|
120
|
-
@space.write [1,2,"a","b"], :expire => 2
|
121
|
-
assert_equal @space.size, 3
|
122
|
-
sleep 2
|
123
|
-
@space.check_expire
|
124
|
-
assert_equal @space.size, 2
|
125
|
-
assert_equal @space.take([1,2]).data, [1,2,3]
|
126
|
-
assert_equal @space.size, 1
|
127
|
-
sleep 1
|
128
|
-
assert_equal @space.take([1,2]).data, [1,2,999]
|
129
|
-
assert_equal @space.size, 0
|
130
|
-
end
|
131
|
-
|
132
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
@@ -67,6 +67,8 @@ files:
|
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
69
|
- lib/linda.rb
|
70
|
+
- lib/linda/test/tuple.rb
|
71
|
+
- lib/linda/test/tuplespace.rb
|
70
72
|
- lib/linda/tuple.rb
|
71
73
|
- lib/linda/tuplespace.rb
|
72
74
|
- lib/linda/version.rb
|