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
d25d343e
Commit
d25d343e
authored
May 08, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2208 from yui-knk/array-error
Make Array#[]= raise IndexError.
parents
09b9c776
eafc4dd0
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 @
d25d343e
...
@@ -561,6 +561,10 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
...
@@ -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
;
mrb_int
i
,
argc
;
ary_modify
(
mrb
,
a
);
ary_modify
(
mrb
,
a
);
/* len check */
if
(
len
<
0
)
mrb_raisef
(
mrb
,
E_INDEX_ERROR
,
"negative length (%S)"
,
mrb_fixnum_value
(
len
));
/* range check */
/* range check */
if
(
head
<
0
)
{
if
(
head
<
0
)
{
head
+=
a
->
len
;
head
+=
a
->
len
;
...
...
test/t/array.rb
View file @
d25d343e
...
@@ -66,6 +66,11 @@ assert('Array#[]=', '15.2.12.5.5') do
...
@@ -66,6 +66,11 @@ assert('Array#[]=', '15.2.12.5.5') do
# this will cause an exception due to the wrong arguments
# this will cause an exception due to the wrong arguments
a
.
[
]
=
(
1
,
2
,
3
,
4
)
a
.
[
]
=
(
1
,
2
,
3
,
4
)
end
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
(
4
,
[
1
,
2
,
3
].
[
]
=
(
1
,
4
))
assert_equal
(
3
,
[
1
,
2
,
3
].
[
]
=
(
1
,
2
,
3
))
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