diff --git a/core/float.rbs b/core/float.rbs index 057d928..44d4481 100644 --- a/core/float.rbs +++ b/core/float.rbs @@ -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 diff --git a/core/integer.rbs b/core/integer.rbs index 5e96f19..ecfe803 100644 --- a/core/integer.rbs +++ b/core/integer.rbs @@ -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 diff --git a/core/object.rbs b/core/object.rbs index 7a8c495..f0a8776 100644 --- a/core/object.rbs +++ b/core/object.rbs @@ -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 diff --git a/core/string.rbs b/core/string.rbs index fadf996..1abbd72 100644 --- a/core/string.rbs +++ b/core/string.rbs @@ -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 diff --git a/test/object.rb b/test/object.rb index 8e9b8f9..2a828a3 100644 --- a/test/object.rb +++ b/test/object.rb @@ -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