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
9d2272ec
Commit
9d2272ec
authored
Jul 17, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `String#[]` test
parent
d5939879
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
32 deletions
+15
-32
test/t/string.rb
test/t/string.rb
+15
-32
No files found.
test/t/string.rb
View file @
9d2272ec
...
...
@@ -45,44 +45,27 @@ assert('String#*', '15.2.10.5.5') do
assert_raise
(
TypeError
)
{
'a'
*
'1'
}
assert_raise
(
TypeError
)
{
'a'
*
nil
}
end
assert
(
'String#[]'
,
'15.2.10.5.6'
)
do
# length of args is 1
a
=
'abc'
[
0
]
b
=
'abc'
[
-
1
]
c
=
'abc'
[
10
]
d
=
'abc'
[
-
10
]
e
=
'abc'
[
1.1
]
a
ssert_equal
'a'
,
'abc'
[
0
]
assert_equal
'c'
,
'abc'
[
-
1
]
assert_nil
'abc'
[
10
]
assert_nil
'abc'
[
-
10
]
assert_equal
'b'
,
'abc'
[
1.1
]
if
Object
.
const_defined?
(
:Float
)
# length of args is 2
a1
=
'abc'
[
0
,
-
1
]
b1
=
'abc'
[
10
,
0
]
c1
=
'abc'
[
-
10
,
0
]
d1
=
'abc'
[
0
,
0
]
e1
=
'abc'
[
1
,
2
]
# args is RegExp
# It will be tested in mrbgems.
assert_nil
'abc'
[
0
,
-
1
]
assert_nil
'abc'
[
10
,
0
]
assert_nil
'abc'
[
-
10
,
0
]
assert_equal
''
,
'abc'
[
0
,
0
]
assert_equal
'bc'
,
'abc'
[
1
,
2
]
# args is String
a3
=
'abc'
[
'bc'
]
b3
=
'abc'
[
'XX'
]
assert_equal
'a'
,
'a'
# assert_equal 'c', b
# assert_nil c
# assert_nil d
# assert_equal 'b', e
# assert_nil a1
# assert_nil b1
# assert_nil c1
# assert_equal '', d1
# assert_equal 'bc', e1
# assert_equal 'bc', a3
# assert_nil b3
# assert_raise(TypeError) do
# a[nil]
# end
assert_equal
'bc'
,
'abc'
[
'bc'
]
assert_nil
'abc'
[
'XX'
]
assert_raise
(
TypeError
)
{
'abc'
[
nil
]
}
end
assert
(
'String#[](UTF-8)'
,
'15.2.10.5.6'
)
do
...
...
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