Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
83d04a53
Commit
83d04a53
authored
Jun 09, 2013
by
Daniel Bovensiepen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve undef tests
parent
16424a14
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
59 deletions
+65
-59
test/t/class.rb
test/t/class.rb
+0
-59
test/t/methods.rb
test/t/methods.rb
+65
-0
No files found.
test/t/class.rb
View file @
83d04a53
...
...
@@ -252,62 +252,3 @@ assert('Class Alias 2') do
A
.
new
.
test
==
2
and
A
.
new
.
test2
==
1
end
assert
(
'Class Undef 1'
)
do
class
A
def
test1
;
1
;
end
def
test2
;
2
;
end
undef
test1
undef
:test2
end
result1
=
false
begin
A
.
new
.
test1
rescue
NoMethodError
result1
=
true
end
result2
=
false
begin
A
.
new
.
test2
rescue
NoMethodError
result2
=
true
end
result1
==
true
and
result2
==
true
end
assert
(
'Class Undef 2'
)
do
class
A
def
test1
;
1
;
end
def
test2
;
2
;
end
undef
test1
,
test2
end
result1
=
false
begin
A
.
new
.
test1
rescue
NoMethodError
result1
=
true
end
result2
=
false
begin
A
.
new
.
test2
rescue
NoMethodError
result2
=
true
end
result1
==
true
and
result2
==
true
end
assert
(
'Var undef'
)
do
assert_raise
(
NameError
)
do
a
=
1
undef
a
end
end
test/t/methods.rb
0 → 100644
View file @
83d04a53
##
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment