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
955464ca
Commit
955464ca
authored
Feb 12, 2021
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `UncaughtThrowError#{tag,value}` for Ruby compatibility
parent
2af8e16c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
mrbgems/mruby-catch/mrblib/catch.rb
mrbgems/mruby-catch/mrblib/catch.rb
+4
-4
mrbgems/mruby-catch/test/catch.rb
mrbgems/mruby-catch/test/catch.rb
+15
-8
No files found.
mrbgems/mruby-catch/mrblib/catch.rb
View file @
955464ca
class
UncaughtThrowError
<
ArgumentError
attr_reader
:
_tag
,
:_val
def
initialize
(
tag
,
val
)
@
_
tag
=
tag
@
_val
=
val
attr_reader
:
tag
,
:value
def
initialize
(
tag
,
val
ue
)
@tag
=
tag
@
value
=
value
super
(
"uncaught throw
#{
tag
.
inspect
}
"
)
end
end
mrbgems/mruby-catch/test/catch.rb
View file @
955464ca
...
...
@@ -3,10 +3,14 @@ assert "return throw value" do
result
=
catch
:foo
do
loop
do
loop
do
throw
:foo
,
val
begin
throw
:foo
,
val
rescue
Exception
flunk
(
"should not reach here 1"
)
end
break
end
flunk
(
"should not reach here"
)
flunk
(
"should not reach here
2
"
)
end
false
end
...
...
@@ -30,13 +34,16 @@ assert "pass the given tag to block" do
catch
(
tag
){
|
t
|
assert_same
(
tag
,
t
)}
end
assert
"tag identity"
do
assert_raise_with_message_pattern
(
Exception
,
"uncaught throw *"
)
do
catch
[
:tag
]
do
throw
[
:tag
]
end
flunk
(
"should not reach here"
)
assert
"tag identity, uncaught throw"
do
tag
,
val
=
[
:tag
],
[
:val
]
catch
[
:tag
]
do
throw
tag
,
val
end
flunk
(
"should not reach here"
)
rescue
Exception
=>
e
assert_match
(
"uncaught throw *"
,
e
.
message
)
assert_same
(
tag
,
e
.
tag
)
assert_same
(
val
,
e
.
value
)
end
assert
"without catch arguments"
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