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
eafc4dd0
Commit
eafc4dd0
authored
May 08, 2014
by
yui-knk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Array#[]= raise IndexError.
If second param is negative, Array#[] raise IndexError.
parent
09b9c776
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
src/array.c
src/array.c
+4
-0
test/t/array.rb
test/t/array.rb
+5
-0
No files found.
src/array.c
View file @
eafc4dd0
...
...
@@ -561,6 +561,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
mrb_int
i
,
argc
;
ary_modify
(
mrb
,
a
);
/* len check */
if
(
len
<
0
)
mrb_raisef
(
mrb
,
E_INDEX_ERROR
,
"negative length (%S)"
,
mrb_fixnum_value
(
len
));
/* range check */
if
(
head
<
0
)
{
head
+=
a
->
len
;
...
...
test/t/array.rb
View file @
eafc4dd0
...
...
@@ -66,6 +66,11 @@ assert('Array#[]=', '15.2.12.5.5') do
# this will cause an exception due to the wrong arguments
a
.
[
]
=
(
1
,
2
,
3
,
4
)
end
assert_raise
(
IndexError
)
do
# this will cause an exception due to the wrong arguments
a
=
[
1
,
2
,
3
,
4
,
5
]
a
[
1
,
-
1
]
=
10
end
assert_equal
(
4
,
[
1
,
2
,
3
].
[
]
=
(
1
,
4
))
assert_equal
(
3
,
[
1
,
2
,
3
].
[
]
=
(
1
,
2
,
3
))
...
...
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