-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'unreachable' method to express unreachable code explicitly
This is an implementation of #4749.
- Loading branch information
1 parent
d23db08
commit afd168c
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "spec" | ||
|
||
describe "unreachable!" do | ||
it "raises UnreachableError" do | ||
expect_raises(UnreachableError){ unreachable! } | ||
end | ||
|
||
it "raises an error with 'BUG: unreachable' message" do | ||
expect_raises(UnreachableError, "BUG: unreachable"){ unreachable! } | ||
end | ||
|
||
it "can set an error message" do | ||
expect_raises UnreachableError, "BUG: i'm bag" do | ||
unreachable! "i'm bag" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters