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
e129a4c8
Commit
e129a4c8
authored
Apr 02, 2013
by
Masaki Muranaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test cases.
parent
6bd49a3d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
2 deletions
+62
-2
test/t/array.rb
test/t/array.rb
+15
-1
test/t/class.rb
test/t/class.rb
+20
-0
test/t/hash.rb
test/t/hash.rb
+12
-1
test/t/module.rb
test/t/module.rb
+15
-0
No files found.
test/t/array.rb
View file @
e129a4c8
...
...
@@ -272,7 +272,7 @@ assert('Array#unshift', '15.2.12.5.30') do
a
==
[
1
,
2
,
3
]
and
b
==
[
1
,
2
,
3
]
and
c
==
[
0
,
1
,
2
,
3
]
and
d
==
[
0
,
1
,
2
,
3
]
end
assert
(
'Array#to_s'
,
'15.2.12.5.31'
)
do
assert
(
'Array#to_s'
,
'15.2.12.5.31
/ 15.2.12.5.32
'
)
do
a
=
[
2
,
3
,
4
,
5
]
r1
=
a
.
to_s
r2
=
a
.
inspect
...
...
@@ -288,6 +288,20 @@ assert('Array#==', '15.2.12.5.33') do
r1
==
false
and
r2
==
true
and
r3
==
false
end
assert
(
'Array#eql?'
,
'15.2.12.5.34'
)
do
a1
=
[
1
,
2
,
3
]
a2
=
[
1
,
2
,
3
]
a3
=
[
1.0
,
2.0
,
3.0
]
(
a1
.
eql?
a2
)
and
(
not
a1
.
eql?
a3
)
end
assert
(
'Array#hash'
,
'15.2.12.5.35'
)
do
a
=
[
1
,
2
,
3
]
a
.
hash
.
is_a?
Integer
end
assert
(
'Array#<=>'
,
'15.2.12.5.36'
)
do
r1
=
[
"a"
,
"a"
,
"c"
]
<=>
[
"a"
,
"b"
,
"c"
]
#=> -1
r2
=
[
1
,
2
,
3
,
4
,
5
,
6
]
<=>
[
1
,
2
]
#=> +1
...
...
test/t/class.rb
View file @
e129a4c8
...
...
@@ -9,6 +9,26 @@ assert('Class superclass', '15.2.3.2') do
Class
.
superclass
==
Module
end
# Class#initialize '15.2.3.3.1' is tested in Class#new
assert
(
'Class#initialize_copy'
,
'15.2.3.3.2'
)
do
class
TestClass
attr_accessor
:n
def
initialize
(
n
)
@n
=
n
end
def
initialize_copy
(
obj
)
@n
=
n
end
end
c1
=
TestClass
.
new
(
'Foo'
)
c2
=
c1
.
dup
c3
=
TestClass
.
new
(
'Bar'
)
c1
.
n
==
c2
.
n
and
c1
.
n
!=
c3
.
n
end
assert
(
'Class#new'
,
'15.2.3.3.3'
)
do
# at the moment no exception on singleton class
#e1 = nil
...
...
test/t/hash.rb
View file @
e129a4c8
...
...
@@ -138,7 +138,18 @@ assert('Hash#include?', '15.2.13.4.15') do
a
.
include?
(
'abc_key'
)
and
not
b
.
include?
(
'cba'
)
end
assert
(
'Hash#initialize copy'
,
'15.2.13.4.17'
)
do
assert
(
'Hash#initialize'
,
'15.2.13.4.16'
)
do
# Testing initialize by new.
h
=
Hash
.
new
h2
=
Hash
.
new
(
:not_found
)
h
.
is_a?
Hash
and
h
==
{
}
and
h
[
"hello"
]
==
nil
and
h2
[
"hello"
]
==
:not_found
end
assert
(
'Hash#initialize_copy'
,
'15.2.13.4.17'
)
do
a
=
{
'abc_key'
=>
'abc_value'
}
b
=
Hash
.
new
.
initialize_copy
(
a
)
...
...
test/t/module.rb
View file @
e129a4c8
...
...
@@ -129,6 +129,21 @@ assert('Module#const_get', '15.2.2.4.23') do
Test4ConstSet
.
const_get
(
:Const4Test4ConstSet
)
==
23
end
assert
(
'Module.constants'
,
'15.2.2.4.24'
)
do
$n
=
[]
module
TestA
Const
=
1
end
class
TestB
include
TestA
Const2
=
1
$n
=
constants
.
sort
end
TestA
.
constants
==
[
:Const
]
and
$n
==
[
:Const
,
:Const2
]
end
assert
(
'Module#include'
,
'15.2.2.4.27'
)
do
module
Test4Include
Const4Include
=
42
...
...
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