Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions core/float.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class Float < Object

def **: (Integer | Float) -> Float

def ==: (untyped other) -> bool

def !=: (untyped other) -> bool

def <: (Integer | Float other) -> bool

def <=: (Integer | Float other) -> bool
Expand Down
4 changes: 0 additions & 4 deletions core/integer.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class Integer < Object

def >>: (Integer) -> Integer

def ==: (untyped other) -> bool

def !=: (untyped other) -> bool

def <: (Integer | Float other) -> bool

def <=: (Integer | Float other) -> bool
Expand Down
90 changes: 90 additions & 0 deletions core/object.rbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,92 @@
class Object < BasicObject
def !: () -> bool
def self.!: () -> bool

def !=: (untyped other) -> bool
def self.!=: (untyped other) -> bool

def <=>: (untyped other) -> bool
def self.<=>: (untyped other) -> bool

def ==: (untyped other) -> bool
def self.==: (untyped other) -> bool

def ===: (untyped other) -> bool
def self.===: (untyped other) -> bool

def <: (untyped other) -> bool

def <=: (untyped other) -> bool

def >: (untyped other) -> bool

def >=: (untyped other) -> bool

def class: () -> class
def self.class: () -> self

def dup: () -> self
def self.dup: () -> self

def block_given?: () -> bool

# TODO: Module
def kind_of?: (Class) -> bool
def self.kind_of?: (Class) -> bool

alias is_a? kind_of?
alias self.is_a? self.kind_of?

def nil?: () -> bool
def self.nil?: () -> bool

# TODO: Array
def p: () -> nil
| [T](T arg0) -> T

def print: (*untyped args) -> nil

def puts: (*untyped args) -> nil

# TODO Exception
def raise: () -> bot
| (String message) -> bot
# | (Exception) -> bot
# | (singleton(Exception)) -> bot
# | (Exception, String message) -> bot
# | (singleton(Exception), String message) -> bot

# TODO: Symbol
# def self.attr_reader: (*String names) -> void

# TODO: Symbol
# def self.attr_accessor: (*Symbol names) -> void

# TODO: Module
# def include: (*Module mods) -> void
# def self.include: (*Module mods) -> void
#
# alias extend include
# alias self.extend include

# TODO: Array, Symbol
# def self.constants: (?bool inherit) -> Array[Symbol]

def self.public: () -> void

def self.private: () -> void

def self.protected: () -> void

def sprintf: (String format, *untyped args) -> String

def printf: (String format, *untyped args) -> nil

def to_s: () -> String
def self.to_s: () -> String

alias inspect to_s
alias self.inspect self.to_s

def loop: () { () -> void } -> bot
end
4 changes: 0 additions & 4 deletions core/string.rbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
class String < Object
def initialize: (?String source) -> void

def ==: (untyped other) -> bool

def !=: (untyped other) -> bool

def <: (String other) -> bool

def <=: (String other) -> bool
Expand Down
94 changes: 94 additions & 0 deletions test/object.rb
Original file line number Diff line number Diff line change
@@ -1 +1,95 @@
# frozen_string_literal: true

# rubocop:disable Lint/Void
# rubocop:disable Lint/UnreachableCode
# rubocop:disable Lint/UselessAccessModifier
# rubocop:disable Style/CaseEquality
# rubocop:disable Style/ClassCheck
# rubocop:disable Style/FormatString
# rubocop:disable Style/RedundantFormat

object = Object.new

!object
!Object

object != true
Object != true

object <=> true
Object <=> true

object == true
Object == true

object === true
Object === true

object < 1

object <= 1

object > 1

object >= 1

object.class
Object.class

object.dup
Object.dup

block_given?
object.block_given?

object.kind_of? Object
Object.kind_of? Object

object.is_a? Object
Object.is_a? Object

object.nil?
Object.nil?

p
p 1
object.p
object.p 1

print
print 1, true, 'a'
object.print
object.print 1, true, 'a'

puts
puts 1, true, 'a'
object.puts
object.puts 1, true, 'a'

raise
raise 'error'
object.raise
object.raise 'error'

# @type const A: A
class A
public

private

protected
end

sprintf "%d\n", 123

printf "%d\n", 123

object.to_s
Object.to_s

object.inspect
Object.inspect

loop { puts }

# rubocop:enable all