Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Exception signatures #119

Merged
merged 3 commits into from Dec 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions stdlib/builtin/exception.rbs
Expand Up @@ -122,6 +122,10 @@
#
# - fatal – impossible to rescue
class Exception < Object
def self.to_tty?: () -> bool

def self.exception: (?String msg) -> self

def ==: (untyped arg0) -> bool

# Returns any backtrace associated with the exception. The backtrace is an
Expand Down Expand Up @@ -184,4 +188,6 @@ class Exception < Object
# Returns exception’s message (or the name of the exception if no message
# is set).
def to_s: () -> String

def full_message: (?highlight: bool, ?order: :top | :bottom) -> String
end
24 changes: 24 additions & 0 deletions test/stdlib/Exception_test.rb
@@ -0,0 +1,24 @@
require_relative "test_helper"

class ExceptionTest < StdlibTest
target Exception
using hook.refinement

def test_full_message
Exception.new.full_message
Exception.new.full_message(highlight: true)
Exception.new.full_message(highlight: false)
Exception.new.full_message(order: :top)
Exception.new.full_message(order: :bottom)
end

def test_to_tty
Exception.to_tty?
end

def test_exception
Exception.exception
Exception.exception('test')
NameError.exception
end
end