69 |
assert(!slot.is_queue_slot?) |
assert(!slot.is_queue_slot?) |
70 |
assert(!slot.is_stack_slot?) |
assert(!slot.is_stack_slot?) |
71 |
assert(!slot.is_proc_slot?) |
assert(!slot.is_proc_slot?) |
72 |
|
assert(!slot.is_hash_slot?) |
73 |
assert_equal(1, slot.data) |
assert_equal(1, slot.data) |
74 |
assert_exception(RuntimeError) {slot.proc} |
assert_exception(RuntimeError) {slot.proc} |
75 |
assert_exception(RuntimeError) {slot.queue} |
assert_exception(RuntimeError) {slot.queue} |
76 |
assert_exception(RuntimeError) {slot.stack} |
assert_exception(RuntimeError) {slot.stack} |
77 |
|
assert_exception(RuntimeError) {slot.hash} |
78 |
assert_exception(RuntimeError) {slot.set_proc {|param| return param} } |
assert_exception(RuntimeError) {slot.set_proc {|param| return param} } |
79 |
assert_exception(RuntimeError) {slot.call(2) } |
assert_exception(RuntimeError) {slot.call(2) } |
80 |
assert_exception(RuntimeError) {slot << 1} |
assert_exception(RuntimeError) {slot << 1} |
82 |
assert_exception(RuntimeError) {slot.leave} |
assert_exception(RuntimeError) {slot.leave} |
83 |
assert_exception(RuntimeError) {slot.push(1)} |
assert_exception(RuntimeError) {slot.push(1)} |
84 |
assert_exception(RuntimeError) {slot.pop} |
assert_exception(RuntimeError) {slot.pop} |
85 |
|
assert_exception(RuntimeError) {slot.put(1,2)} |
86 |
|
assert_exception(RuntimeError) {slot.get(1)} |
87 |
end |
end |
88 |
|
|
89 |
def test_4_slottype_queue |
def test_4_slottype_queue |
94 |
assert(!slot.is_data_slot?) |
assert(!slot.is_data_slot?) |
95 |
assert(!slot.is_stack_slot?) |
assert(!slot.is_stack_slot?) |
96 |
assert(!slot.is_proc_slot?) |
assert(!slot.is_proc_slot?) |
97 |
|
assert(!slot.is_hash_slot?) |
98 |
slot.join(2) |
slot.join(2) |
99 |
assert_equal(2, slot.count) |
assert_equal(2, slot.count) |
100 |
assert_equal(1, slot.leave) |
assert_equal(1, slot.leave) |
103 |
assert_exception(RuntimeError) {slot.proc} |
assert_exception(RuntimeError) {slot.proc} |
104 |
assert_exception(RuntimeError) {slot.data} |
assert_exception(RuntimeError) {slot.data} |
105 |
assert_exception(RuntimeError) {slot.stack} |
assert_exception(RuntimeError) {slot.stack} |
106 |
|
assert_exception(RuntimeError) {slot.hash} |
107 |
assert_exception(RuntimeError) {slot.call(2) } |
assert_exception(RuntimeError) {slot.call(2) } |
108 |
assert_exception(RuntimeError) {slot.set_proc {|param| return param} } |
assert_exception(RuntimeError) {slot.set_proc {|param| return param} } |
109 |
assert_exception(RuntimeError) {slot.push(1)} |
assert_exception(RuntimeError) {slot.push(1)} |
110 |
assert_exception(RuntimeError) {slot.pop} |
assert_exception(RuntimeError) {slot.pop} |
111 |
|
assert_exception(RuntimeError) {slot.put(1,2)} |
112 |
|
assert_exception(RuntimeError) {slot.get(1)} |
113 |
end |
end |
114 |
|
|
115 |
def test_5_slottype_stack |
def test_5_slottype_stack |
120 |
assert(!slot.is_queue_slot?) |
assert(!slot.is_queue_slot?) |
121 |
assert(!slot.is_data_slot?) |
assert(!slot.is_data_slot?) |
122 |
assert(!slot.is_proc_slot?) |
assert(!slot.is_proc_slot?) |
123 |
|
assert(!slot.is_hash_slot?) |
124 |
slot.push 2 |
slot.push 2 |
125 |
assert_equal(2, slot.count) |
assert_equal(2, slot.count) |
126 |
assert_equal(2, slot.pop) |
assert_equal(2, slot.pop) |
129 |
assert_exception(RuntimeError) {slot.proc} |
assert_exception(RuntimeError) {slot.proc} |
130 |
assert_exception(RuntimeError) {slot.data} |
assert_exception(RuntimeError) {slot.data} |
131 |
assert_exception(RuntimeError) {slot.queue} |
assert_exception(RuntimeError) {slot.queue} |
132 |
|
assert_exception(RuntimeError) {slot.hash} |
133 |
assert_exception(RuntimeError) {slot.set_proc {|param| return param} } |
assert_exception(RuntimeError) {slot.set_proc {|param| return param} } |
134 |
assert_exception(RuntimeError) {slot.call(2) } |
assert_exception(RuntimeError) {slot.call(2) } |
135 |
assert_exception(RuntimeError) {slot << 1} |
assert_exception(RuntimeError) {slot << 1} |
136 |
assert_exception(RuntimeError) {slot.join(1)} |
assert_exception(RuntimeError) {slot.join(1)} |
137 |
assert_exception(RuntimeError) {slot.leave} |
assert_exception(RuntimeError) {slot.leave} |
138 |
|
assert_exception(RuntimeError) {slot.put(1,2)} |
139 |
|
assert_exception(RuntimeError) {slot.get(1)} |
140 |
end |
end |
141 |
|
|
142 |
def test_6_slottype_proc |
def test_6_slottype_proc |
147 |
assert(!slot.is_stack_slot?) |
assert(!slot.is_stack_slot?) |
148 |
assert(!slot.is_queue_slot?) |
assert(!slot.is_queue_slot?) |
149 |
assert(!slot.is_data_slot?) |
assert(!slot.is_data_slot?) |
150 |
|
assert(!slot.is_hash_slot?) |
151 |
slot.call(4) |
slot.call(4) |
152 |
slot.proc.call(4) |
slot.proc.call(4) |
153 |
assert_exception(RuntimeError) {slot.stack} |
assert_exception(RuntimeError) {slot.stack} |
154 |
assert_exception(RuntimeError) {slot.data} |
assert_exception(RuntimeError) {slot.data} |
155 |
assert_exception(RuntimeError) {slot.queue} |
assert_exception(RuntimeError) {slot.queue} |
156 |
|
assert_exception(RuntimeError) {slot.hash} |
157 |
assert_exception(RuntimeError) {slot << 1} |
assert_exception(RuntimeError) {slot << 1} |
158 |
assert_exception(RuntimeError) {slot.join(1)} |
assert_exception(RuntimeError) {slot.join(1)} |
159 |
assert_exception(RuntimeError) {slot.leave} |
assert_exception(RuntimeError) {slot.leave} |
160 |
assert_exception(RuntimeError) {slot.push(1)} |
assert_exception(RuntimeError) {slot.push(1)} |
161 |
assert_exception(RuntimeError) {slot.pop} |
assert_exception(RuntimeError) {slot.pop} |
162 |
|
assert_exception(RuntimeError) {slot.put(1,2)} |
163 |
|
assert_exception(RuntimeError) {slot.get(1)} |
164 |
end |
end |
165 |
|
|
166 |
def test_7_slot_attributes |
def test_7_slottype_hash |
167 |
|
bus = FreeBASE::DataBus.new |
168 |
|
slot = bus["slot"] |
169 |
|
slot.put(1,2) |
170 |
|
assert(slot.is_hash_slot?) |
171 |
|
assert(!slot.is_stack_slot?) |
172 |
|
assert(!slot.is_queue_slot?) |
173 |
|
assert(!slot.is_data_slot?) |
174 |
|
assert(!slot.is_proc_slot?) |
175 |
|
assert_equal(2, slot.get(1)) |
176 |
|
assert_equal(1, slot.count) |
177 |
|
slot.clear |
178 |
|
assert_equal(0, slot.count) |
179 |
|
slot.hash.set_hash(1=>2, 2=>3) |
180 |
|
assert_equal(2, slot.get(1)) |
181 |
|
assert_equal(3, slot.get(2)) |
182 |
|
assert_exception(RuntimeError) {slot.proc} |
183 |
|
assert_exception(RuntimeError) {slot.stack} |
184 |
|
assert_exception(RuntimeError) {slot.data} |
185 |
|
assert_exception(RuntimeError) {slot.queue} |
186 |
|
assert_exception(RuntimeError) {slot << 1} |
187 |
|
assert_exception(RuntimeError) {slot.join(1)} |
188 |
|
assert_exception(RuntimeError) {slot.leave} |
189 |
|
assert_exception(RuntimeError) {slot.push(1)} |
190 |
|
assert_exception(RuntimeError) {slot.pop} |
191 |
|
assert_exception(RuntimeError) {slot.call(2) } |
192 |
|
assert_exception(RuntimeError) {slot.set_proc {|param| return param} } |
193 |
|
end |
194 |
|
|
195 |
|
def test_8_slot_attributes |
196 |
bus = FreeBASE::DataBus.new |
bus = FreeBASE::DataBus.new |
197 |
slot = bus["test/slot"] |
slot = bus["test/slot"] |
198 |
slot.attr_test=1 |
slot.attr_test=1 |