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
5568df5e
Commit
5568df5e
authored
Feb 18, 2013
by
Yukihiro Matz Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
:Merge branch 'master' of github.com:mruby/mruby
Conflicts: src/class.c
parents
df38a31d
b04183fd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
4 deletions
+36
-4
mrblib/string.rb
mrblib/string.rb
+3
-1
src/class.c
src/class.c
+1
-1
test/t/module.rb
test/t/module.rb
+22
-0
test/t/string.rb
test/t/string.rb
+6
-2
tools/mirb/mirb.c
tools/mirb/mirb.c
+4
-0
No files found.
mrblib/string.rb
View file @
5568df5e
...
...
@@ -28,8 +28,10 @@ class String
#
# ISO 15.2.10.5.18
def
gsub
(
*
args
,
&
block
)
lc
=
''
if
args
.
size
==
2
split
(
args
[
0
]).
join
(
args
[
1
])
lc
=
args
[
1
]
if
self
[
-
1
]
==
args
[
0
]
split
(
args
[
0
]).
join
(
args
[
1
])
+
lc
elsif
args
.
size
==
1
&&
block
split
(
args
[
0
]).
join
(
block
.
call
(
args
[
0
]))
else
...
...
src/class.c
View file @
5568df5e
...
...
@@ -1737,7 +1737,7 @@ mrb_mod_remove_const(mrb_state *mrb, mrb_value mod)
check_const_name
(
mrb
,
id
);
val
=
mrb_iv_remove
(
mrb
,
mod
,
id
);
if
(
mrb_undef_p
(
val
))
{
mrb_name_error
(
mrb
,
id
,
"instance variable %s not defined"
,
mrb_sym2name
(
mrb
,
id
));
mrb_name_error
(
mrb
,
sym
,
"constant %s not defined"
,
mrb_sym2name
(
mrb
,
sym
));
}
return
val
;
}
...
...
test/t/module.rb
View file @
5568df5e
...
...
@@ -241,6 +241,28 @@ assert('Module#remove_class_variable', '15.2.2.4.39') do
not
Test4RemoveClassVariable
.
class_variables
.
include?
:@@cv
end
assert
(
'Module#remove_const'
,
'15.2.2.4.40'
)
do
module
Test4RemoveConst
ExistingConst
=
23
end
result
=
Test4RemoveConst
.
module_eval
{
remove_const
:ExistingConst
}
name_error
=
false
begin
Test4RemoveConst
.
module_eval
{
remove_const
:NonExistingConst
}
rescue
NameError
name_error
=
true
end
# Constant removed from Module
not
Test4RemoveConst
.
const_defined?
:ExistingConst
and
# Return value of binding
result
==
23
and
# Name Error raised when Constant doesn't exist
name_error
end
assert
(
'Module#remove_method'
,
'15.2.2.4.41'
)
do
module
Test4RemoveMethod
class
Parent
...
...
test/t/string.rb
View file @
5568df5e
...
...
@@ -193,7 +193,9 @@ assert('String#eql?', '15.2.10.5.17') do
end
assert
(
'String#gsub'
,
'15.2.10.5.18'
)
do
'abcabc'
.
gsub
(
'b'
,
'B'
)
==
'aBcaBc'
&&
'abcabc'
.
gsub
(
'b'
)
{
|
w
|
w
.
capitalize
}
==
'aBcaBc'
'abcabc'
.
gsub
(
'b'
,
'B'
)
==
'aBcaBc'
and
'abcabc'
.
gsub
(
'b'
)
{
|
w
|
w
.
capitalize
}
==
'aBcaBc'
and
'#a#a#'
.
gsub
(
'#'
,
'$'
)
==
'$a$a$'
end
assert
(
'String#gsub!'
,
'15.2.10.5.19'
)
do
...
...
@@ -318,7 +320,9 @@ assert('String#split', '15.2.10.5.35') do
end
assert
(
'String#sub'
,
'15.2.10.5.36'
)
do
'abcabc'
.
sub
(
'b'
,
'B'
)
==
'aBcabc'
&&
'abcabc'
.
sub
(
'b'
)
{
|
w
|
w
.
capitalize
}
==
'aBcabc'
'abcabc'
.
sub
(
'b'
,
'B'
)
==
'aBcabc'
and
'abcabc'
.
sub
(
'b'
)
{
|
w
|
w
.
capitalize
}
==
'aBcabc'
and
'aa#'
.
sub
(
'#'
,
'$'
)
==
'aa$'
end
assert
(
'String#sub!'
,
'15.2.10.5.37'
)
do
...
...
tools/mirb/mirb.c
View file @
5568df5e
...
...
@@ -191,6 +191,10 @@ main(void)
last_code_line
[
char_index
]
=
'\0'
;
#else
char
*
line
=
readline
(
code_block_open
?
"* "
:
"> "
);
if
(
line
==
NULL
)
{
printf
(
"
\n
"
);
break
;
}
strncat
(
last_code_line
,
line
,
sizeof
(
last_code_line
)
-
1
);
add_history
(
line
);
free
(
line
);
...
...
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