/
regitem_thattest.rb
executable file
·47 lines (40 loc) · 1.5 KB
/
regitem_thattest.rb
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
=begin copyright
reg - the ruby extended grammar
Copyright (C) 2005 Caleb Clausen
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
=end
require 'test/unit'
class Object
#define a more stable version of inspect (for testing purposes)
alias pristine_inspect inspect
def inspect
res=pristine_inspect
res[/^#</] or return res
res=["#<",self.class,": ",instance_variables.sort.collect{|v|
[v,"=",instance_variable_get(v).inspect," "]
}]
res.last.pop
res.push('>')
res.to_s
end
end
class T411 < Test::Unit::TestCase
def test_unnamed
_=require 'reg'
_=item_that<4===3
assert_equal 'true', _.inspect
_=item_that<4===5
assert_equal 'false', _.inspect
assert_nothing_thrown {_=item_that.respond_to?(false)==='ddd'}
end
end