blob: 701ebe326eb8a3ebd728fa117533dae2cda190a8 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
##
# Chapter 13 "Class and modules" ISO Test
assert('The undef statement', '13.3.7 a) 4)') do
# check that undef is undefining method
# based on the method name
def existing_method_a; true; end
def existing_method_b; true; end
def existing_method_c; true; end
def existing_method_d; true; end
def existing_method_e; true; end
def existing_method_f; true; end
# check that methods are defined
assert_true(existing_method_a, 'Method should be defined')
assert_true(existing_method_b, 'Method should be defined')
assert_true(existing_method_c, 'Method should be defined')
assert_true(existing_method_d, 'Method should be defined')
assert_true(existing_method_e, 'Method should be defined')
assert_true(existing_method_f, 'Method should be defined')
# undefine in all possible ways and check that method
# is undefined
undef existing_method_a
assert_raise(NoMethodError) do
existing_method_a
end
undef :existing_method_b
assert_raise(NoMethodError) do
existing_method_b
end
undef existing_method_c, existing_method_d
assert_raise(NoMethodError) do
existing_method_c
end
assert_raise(NoMethodError) do
existing_method_d
end
undef :existing_method_e, :existing_method_f
assert_raise(NoMethodError) do
existing_method_e
end
assert_raise(NoMethodError) do
existing_method_f
end
end
assert('The undef statement (method undefined)', '13.3.7 a) 5)') do
# check that undef is raising NameError if
# non-existing method should be undefined
assert_raise(NameError) do
undef non_existing_method
end
assert_raise(NameError) do
undef :non_existing_method
end
end
|