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
0b5e1550
Unverified
Commit
0b5e1550
authored
Jul 17, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Jul 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4587 from shuujii/fix-String-aref-test
Fix `String#[]` test
parents
626c2146
9d2272ec
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 @
0b5e1550
...
@@ -45,44 +45,27 @@ assert('String#*', '15.2.10.5.5') do
...
@@ -45,44 +45,27 @@ assert('String#*', '15.2.10.5.5') do
assert_raise
(
TypeError
)
{
'a'
*
'1'
}
assert_raise
(
TypeError
)
{
'a'
*
'1'
}
assert_raise
(
TypeError
)
{
'a'
*
nil
}
assert_raise
(
TypeError
)
{
'a'
*
nil
}
end
end
assert
(
'String#[]'
,
'15.2.10.5.6'
)
do
assert
(
'String#[]'
,
'15.2.10.5.6'
)
do
# length of args is 1
# length of args is 1
a
=
'abc'
[
0
]
a
ssert_equal
'a'
,
'abc'
[
0
]
b
=
'abc'
[
-
1
]
assert_equal
'c'
,
'abc'
[
-
1
]
c
=
'abc'
[
10
]
assert_nil
'abc'
[
10
]
d
=
'abc'
[
-
10
]
assert_nil
'abc'
[
-
10
]
e
=
'abc'
[
1.1
]
assert_equal
'b'
,
'abc'
[
1.1
]
if
Object
.
const_defined?
(
:Float
)
# length of args is 2
# length of args is 2
a1
=
'abc'
[
0
,
-
1
]
assert_nil
'abc'
[
0
,
-
1
]
b1
=
'abc'
[
10
,
0
]
assert_nil
'abc'
[
10
,
0
]
c1
=
'abc'
[
-
10
,
0
]
assert_nil
'abc'
[
-
10
,
0
]
d1
=
'abc'
[
0
,
0
]
assert_equal
''
,
'abc'
[
0
,
0
]
e1
=
'abc'
[
1
,
2
]
assert_equal
'bc'
,
'abc'
[
1
,
2
]
# args is RegExp
# It will be tested in mrbgems.
# args is String
# args is String
a3
=
'abc'
[
'bc'
]
assert_equal
'bc'
,
'abc'
[
'bc'
]
b3
=
'abc'
[
'XX'
]
assert_nil
'abc'
[
'XX'
]
assert_equal
'a'
,
'a'
assert_raise
(
TypeError
)
{
'abc'
[
nil
]
}
# 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
end
end
assert
(
'String#[](UTF-8)'
,
'15.2.10.5.6'
)
do
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