lib/raap/cli.rb in raap-0.1.0 vs lib/raap/cli.rb in raap-0.2.0

- old
+ new

@@ -101,11 +101,15 @@ self end def run_by_instance(tag:) t, m = tag.split('#', 2) + t or raise + m or raise type = RBS.parse_type(t) + type = __skip__ = type + raise "cannot specified #{type}" unless type.respond_to?(:name) receiver_type = Type.new(type.to_s) method_name = m.to_sym definition = RBS.builder.build_instance(type.name) type_params_decl = definition.type_params_decl method = definition.methods[method_name] @@ -119,11 +123,15 @@ ] end def run_by_singleton(tag:) t, m = tag.split('.', 2) + t or raise + m or raise type = RBS.parse_type(t) + raise "cannot specified #{type.class}" unless type.respond_to?(:name) + type = __skip__ = type receiver_type = Type.new("singleton(#{type.name})") method_name = m.to_sym definition = RBS.builder.build_singleton(type.name) method = definition.methods[method_name] type_params_decl = definition.type_params_decl @@ -148,17 +156,20 @@ ret.flatten(1) end def run_by_type_name(tag:) type = RBS.parse_type(tag) + type = __skip__ = type + raise "cannot specified #{type.class}" unless type.respond_to?(:name) type_name = type.name.absolute! ret = [] definition = RBS.builder.build_singleton(type_name) type_params_decl = definition.type_params_decl definition.methods.filter_map do |method_name, method| + next unless method.accessibility == :public next if method.defined_in != type_name next if method_name == :fork || method_name == :spawn # TODO: skip solution puts "# #{type_name}.#{method_name}" puts ret << method.method_types.map do |method_type| @@ -167,10 +178,11 @@ end definition = RBS.builder.build_instance(type_name) type_params_decl = definition.type_params_decl definition.methods.filter_map do |method_name, method| + next unless method.accessibility == :public next if method.defined_in != type_name next if method_name == :fork || method_name == :spawn # TODO: skip solution puts "# #{type_name}##{method_name}" puts ret << method.method_types.map do |method_type| @@ -180,54 +192,56 @@ ret end def property(receiver_type:, type_params_decl:, method_type:, method_name:) + rtype = __skip__ = receiver_type.type if receiver_type.type.instance_of?(::RBS::Types::ClassSingleton) prefix = 'self.' type_args = [] else prefix = '' - type_args = receiver_type.type.args + type_args = rtype.args end puts "## def #{prefix}#{method_name}: #{method_type}" status = 0 stats = MethodProperty.new( receiver_type:, method_name: method_name, method_type: MethodType.new( method_type, type_params_decl:, type_args:, - self_type: receiver_type.type, - instance_type: ::RBS::Types::ClassInstance.new(name: receiver_type.type.name, args: type_args, location: nil), - class_type: ::RBS::Types::ClassSingleton.new(name: receiver_type.type.name, location: nil), + self_type: rtype, + instance_type: ::RBS::Types::ClassInstance.new(name: rtype.name, args: type_args, location: nil), + class_type: ::RBS::Types::ClassSingleton.new(name: rtype.name, location: nil), ), size_step: CLI.option.size_from.step(to: CLI.option.size_to, by: CLI.option.size_by), timeout: CLI.option.timeout, ).run do |called| case called in Result::Success => s - RaaP.logger.debug { "Success: #{s.called_str}" } print '.' + RaaP.logger.debug { "Success: #{s.called_str}" } in Result::Failure => f puts 'F' puts "Failed in case of `#{f.called_str}`" puts RaaP.logger.debug { PP.pp(f.symbolic_call, ''.dup) } - puts "# call stack:" + puts "### call stack:" puts puts "```" puts SymbolicCaller.new(f.symbolic_call).to_lines.join("\n") puts "```" status = 1 throw :break in Result::Skip => s print 'S' + RaaP::logger.debug("Skip: [#{s.exception.class}] #{s.exception.message}") in Result::Exception => e - RaaP.logger.info("#{e.exception.class}: #{e.exception.message}") - RaaP.logger.debug(e.exception.backtrace.join("\n")) print 'E' + RaaP.logger.info("Exception: [#{e.exception.class}] #{e.exception.message}") + RaaP.logger.debug(e.exception.backtrace.join("\n")) end end puts puts "success: #{stats.success}, skip: #{stats.skip}, exception: #{stats.exception}" puts