torture.rb 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. # frozen_string_literal: true
  2. require "json"
  3. require "sidekiq/fetch"
  4. require_relative "../shared/helper"
  5. require %q(pct/lib)
  6. require :sym_form
  7. Kernel.require "some/lib"
  8. require "interp/#{RUBY_VERSION}"
  9. TOP_LIMIT = 100
  10. RETRY_MAX = 3
  11. lower_conf = "x"
  12. top_var = compute_default
  13. m1, m2 = 3, 4
  14. counter ||= 0
  15. @ivar_top = 1
  16. $global_top = 2
  17. X_WITH_NEW = Widget.new
  18. WORDS = %w[alpha beta]
  19. module Outer
  20. module Inner
  21. class Deep < Base
  22. before_action :hooked
  23. def greet; end
  24. end
  25. end
  26. end
  27. module A::B
  28. A_B_CONST = 5
  29. end
  30. class TopDoc; end
  31. class Bare; end
  32. class A::B::C
  33. def compact_method; end
  34. end
  35. class ExprSuper < Struct.new(:a)
  36. end
  37. class ScopedSuper < A::B::C
  38. end
  39. # Class docs line one.
  40. # Class docs line two.
  41. class Documented < BaseThing
  42. include Comparable
  43. include Helpers, Sortable
  44. extend self
  45. prepend Memoizer
  46. Foo.include Bar
  47. include dynamic_mod()
  48. CLASS_LIMIT = 9
  49. not_extracted = 1
  50. attr_accessor :name, :email
  51. attr_reader :created_at
  52. alias_method :handle, :name
  53. alias fast_name name
  54. define_method :dyn do
  55. invisible_call
  56. end
  57. before_action :hooked_here
  58. skip_before_action :check_thing, only: [:index]
  59. around_create :wrap_it
  60. rescue_from ArgumentError, with: :render_404
  61. validates :name
  62. validate :custom_check
  63. helper_method :help_me
  64. set_callback :save, :before, :cb_sym
  65. def self.build(arg)
  66. helper_build(arg)
  67. end
  68. class << self
  69. def singleton_style
  70. reset_cache
  71. end
  72. end
  73. def done?; end
  74. def save!; end
  75. def value=(v); end
  76. def visible_before; end
  77. private
  78. def still_public_after_bare_private; end
  79. private :some_sym
  80. def now_private; end
  81. private def inner_public; end
  82. def also_private; end
  83. public def public_again; end
  84. def after_public_def; end
  85. protected
  86. def bare_protected_is_invisible_so_still_public; end
  87. def target_cb; end
  88. def wire(list, button)
  89. register(method(:target_cb))
  90. register(&method(:target_cb))
  91. register(method(:missing_cb))
  92. store = method(:target_cb)
  93. list.each(&:map_sym)
  94. end
  95. def calls_zoo(cb, lower, neg, other, deep, obj, h)
  96. reset
  97. compute(1)
  98. puts "hi"
  99. done? ? cleanup_now : 0
  100. helper unless finished?
  101. compute rescue nil
  102. self.own_method
  103. @name.upcase
  104. @@class_var.inspect
  105. $global.freeze
  106. "literal".upcase
  107. 5.times { beep }
  108. [1, 2].sum
  109. Klass.static_call
  110. NS::Klass.other_call
  111. RETRY_MAX.times
  112. Widget.new
  113. NS::Widget.new
  114. lower.new
  115. chained.first_call.second_call
  116. Widget.create(cb).save
  117. deep&.safe_call
  118. neg&.!= other
  119. obj.attr = 1
  120. obj.attr2 &&= refresh
  121. h[:k] = 2
  122. puts "#{@name.upcase} interp"
  123. body = <<~SQL
  124. select #{col_name.downcase}
  125. SQL
  126. yield
  127. lam = lambda { inner_lambda_call }
  128. pr = proc { inner_proc_call }
  129. arrow = ->(a) { arrow_call(a) }
  130. end
  131. def flow_control(list)
  132. begin
  133. begin_stmt_call
  134. rescue ArgumentError => e
  135. rescue_stmt_call
  136. else
  137. else_stmt_call
  138. ensure
  139. ensure_stmt_call
  140. end
  141. case list
  142. when Array then when_then_call
  143. end
  144. while list.any? do
  145. while_body_call
  146. break
  147. end
  148. if list
  149. then_call
  150. end
  151. end
  152. def body_requires
  153. require "in/body"
  154. Kernel.require "other/lib"
  155. end
  156. def container_method
  157. def nested_def; end
  158. class InnerClass; end
  159. module InnerMod
  160. def mod_method; end
  161. end
  162. nested_def
  163. end
  164. def reader_one
  165. TOP_LIMIT + CLASS_LIMIT
  166. end
  167. def reader_two
  168. a = RETRY_MAX
  169. b = TOP_LIMIT
  170. lower_conf
  171. end
  172. def shadower
  173. lower_conf = "y"
  174. lower_conf.upcase
  175. end
  176. end
  177. # Doc for documented_fn.
  178. # Second line.
  179. def documented_fn; end
  180. =begin
  181. Block comment body.
  182. * star line
  183. -- dash line
  184. =end
  185. def block_doc_fn; end
  186. # lost doc
  187. private def priv_doc_fn; end
  188. def self.top_singleton
  189. singleton_body_call
  190. end
  191. def obj.weird_singleton; end
  192. __END__
  193. raw data trailer here