Browse files

Rsync'd spec dir from master.

  • Loading branch information...
1 parent 9ebee09 commit 0ca1252bbf8d7d5da29eeabea333217e1a084f77 Brian Ford committed Aug 20, 2008
Showing with 10,749 additions and 1,433 deletions.
  1. +9 −9 spec/compiler/array_spec.rb
  2. +194 −147 spec/compiler/call_spec.rb
  3. +75 −0 spec/compiler/conditional_compilation_spec.rb
  4. +205 −206 spec/compiler/control_spec.rb
  5. +22 −4 spec/compiler/defined_spec.rb
  6. +177 −179 spec/compiler/exception_spec.rb
  7. +0 −32 spec/compiler/file_spec.rb
  8. +0 −186 spec/compiler/marshal_spec.rb
  9. +76 −68 spec/compiler/masgn_spec.rb
  10. +62 −45 spec/compiler/op_assign_spec.rb
  11. +149 −115 spec/compiler/scopes_spec.rb
  12. +117 −85 spec/compiler/simple_spec.rb
  13. +32 −40 spec/compiler/spec_helper.rb
  14. +79 −58 spec/compiler/variables_spec.rb
  15. +123 −0 spec/core/array/remove_outer_arrays_spec.rb
  16. +12 −12 spec/core/bignum/bignum_spec.rb
  17. +18 −0 spec/core/breakpoint/calculate_next_breakpoint_spec.rb
  18. +0 −28 spec/core/breakpoint/disable_spec.rb
  19. +0 −32 spec/core/breakpoint/enable_spec.rb
  20. +31 −2 spec/core/breakpoint/fixtures/classes.rb
  21. +8 −12 spec/core/breakpoint/initialize_spec.rb
  22. +32 −0 spec/core/breakpoint/install_spec.rb
  23. +28 −0 spec/core/breakpoint/remove_spec.rb
  24. +8 −0 spec/core/breakpoint/wait_for_breakpoint_spec.rb
  25. +1 −1 spec/core/compiledmethod/decode_spec.rb
  26. +10 −0 spec/core/ctype/isctrl_spec.rb
  27. +8 −0 spec/core/ctype/tolower_spec.rb
  28. +40 −0 spec/core/ctype/toprint_spec.rb
  29. +8 −0 spec/core/ctype/toupper_spec.rb
  30. +348 −0 spec/core/inliner/self_methods_spec.rb
  31. +40 −0 spec/core/instructionsequence/encoder/replace_instruction_spec.rb
  32. +31 −0 spec/core/io/buffer_spec.rb
  33. +89 −54 spec/core/kernel/load_spec.rb
  34. +5 −2 spec/core/kernel/require_spec.rb
  35. +21 −23 spec/core/lookuptable/shared/clone.rb
  36. +13 −15 spec/core/lookuptable/shared/has_key.rb
  37. +13 −0 spec/core/module/add_method_spec.rb
  38. +12 −0 spec/core/module/fixtures/classes.rb
  39. +21 −0 spec/core/proc/arity_spec.rb
  40. +26 −0 spec/core/proc/call_spec.rb
  41. +14 −0 spec/core/proc/equal_value_spec.rb
  42. +8 −0 spec/core/proc/new_spec.rb
  43. +7 −0 spec/core/proc/to_s_spec.rb
  44. +22 −0 spec/core/string/apply_and_spec.rb
  45. +31 −0 spec/core/string/compare_substring_spec.rb
  46. +52 −0 spec/core/string/copy_from_spec.rb
  47. +41 −0 spec/core/string/count_table_spec.rb
  48. +26 −0 spec/core/string/modified_spec.rb
  49. +0 −8 spec/core/string/new_spec.rb
  50. +38 −0 spec/core/string/splice_spec.rb
  51. +19 −0 spec/core/string/substring_spec.rb
  52. +13 −0 spec/core/string/template_spec.rb
  53. +47 −0 spec/core/string/tr_expand_spec.rb
  54. +28 −0 spec/core/symbol/to_proc_spec.rb
  55. +6 −6 spec/core/task/debug_context_change_spec.rb
  56. +7 −7 spec/core/task/fixtures/classes.rb
  57. +15 −17 spec/core/tuple/shared/at.rb
  58. +14 −16 spec/core/tuple/shared/put.rb
  59. +9 −0 spec/core/tuple/template_spec.rb
  60. +7 −2 spec/core/tuple/to_a_spec.rb
  61. +27 −0 spec/debugger/commands/backtrace_spec.rb
  62. +26 −0 spec/debugger/commands/down_frame_spec.rb
  63. +4 −2 spec/debugger/commands/help_spec.rb
  64. +4 −1 spec/debugger/commands/quit_spec.rb
  65. +26 −0 spec/debugger/commands/up_frame_spec.rb
  66. +292 −0 spec/debugger/interface_spec.rb
  67. +93 −19 spec/debugger/output_spec.rb
  68. +24 −0 spec/default.mspec
  69. +259 −0 spec/ffi/attach_foreign_spec.rb
  70. +21 −0 spec/ffi/ffi_struct_spec.rb
  71. +35 −0 spec/ffi/native_function_spec.rb
  72. +34 −0 spec/frozen/1.8/core/argf/close_spec.rb
  73. +39 −0 spec/frozen/1.8/core/argf/closed_spec.rb
  74. +29 −0 spec/frozen/1.8/core/argf/each_byte_spec.rb
  75. +7 −0 spec/frozen/1.8/core/argf/each_line_spec.rb
  76. +7 −0 spec/frozen/1.8/core/argf/each_spec.rb
  77. +11 −0 spec/frozen/1.8/core/argf/eof_spec.rb
  78. +35 −0 spec/frozen/1.8/core/argf/file_spec.rb
  79. +7 −0 spec/frozen/1.8/core/argf/filename_spec.rb
  80. +7 −0 spec/frozen/1.8/core/argf/fileno_spec.rb
  81. +73 −0 spec/frozen/1.8/core/argf/fixtures/classes.rb
  82. +2 −0 spec/frozen/1.8/core/argf/fixtures/file1.txt
  83. +2 −0 spec/frozen/1.8/core/argf/fixtures/file2.txt
  84. +2 −0 spec/frozen/1.8/core/argf/fixtures/stdin.txt
  85. +37 −0 spec/frozen/1.8/core/argf/getc_spec.rb
  86. +104 −0 spec/frozen/1.8/core/argf/gets_spec.rb
  87. +43 −0 spec/frozen/1.8/core/argf/lineno_spec.rb
  88. +7 −0 spec/frozen/1.8/core/argf/path_spec.rb
  89. +47 −0 spec/frozen/1.8/core/argf/pos_spec.rb
  90. +108 −0 spec/frozen/1.8/core/argf/read_spec.rb
  91. +37 −0 spec/frozen/1.8/core/argf/readchar_spec.rb
  92. +99 −0 spec/frozen/1.8/core/argf/readline_spec.rb
  93. +7 −0 spec/frozen/1.8/core/argf/readlines_spec.rb
  94. +44 −0 spec/frozen/1.8/core/argf/rewind_spec.rb
  95. +68 −0 spec/frozen/1.8/core/argf/seek_spec.rb
  96. +25 −0 spec/frozen/1.8/core/argf/shared/each_line.rb
  97. +36 −0 spec/frozen/1.8/core/argf/shared/eof.rb
  98. +47 −0 spec/frozen/1.8/core/argf/shared/filename.rb
  99. +37 −0 spec/frozen/1.8/core/argf/shared/fileno.rb
  100. +38 −0 spec/frozen/1.8/core/argf/shared/pos.rb
  101. +32 −0 spec/frozen/1.8/core/argf/shared/readlines.rb
  102. +48 −0 spec/frozen/1.8/core/argf/skip_spec.rb
  103. +7 −0 spec/frozen/1.8/core/argf/tell_spec.rb
  104. +7 −0 spec/frozen/1.8/core/argf/to_a_spec.rb
  105. +7 −0 spec/frozen/1.8/core/argf/to_i_spec.rb
  106. +39 −0 spec/frozen/1.8/core/argf/to_io_spec.rb
  107. 0 spec/{ruby → frozen}/1.8/core/array/allocate_spec.rb
  108. +37 −0 spec/frozen/1.8/core/array/append_spec.rb
  109. 0 spec/{ruby → frozen}/1.8/core/array/array_spec.rb
  110. 0 spec/{ruby → frozen}/1.8/core/array/assoc_spec.rb
  111. +32 −0 spec/frozen/1.8/core/array/at_spec.rb
  112. +31 −0 spec/frozen/1.8/core/array/clear_spec.rb
  113. 0 spec/{ruby → frozen}/1.8/core/array/clone_spec.rb
  114. 0 spec/{ruby → frozen}/1.8/core/array/collect_spec.rb
  115. +43 −0 spec/frozen/1.8/core/array/compact_spec.rb
  116. +51 −0 spec/frozen/1.8/core/array/comparison_spec.rb
  117. +46 −0 spec/frozen/1.8/core/array/concat_spec.rb
  118. 0 spec/{ruby → frozen}/1.8/core/array/constructor_spec.rb
  119. +50 −0 spec/frozen/1.8/core/array/delete_at_spec.rb
  120. +16 −0 spec/frozen/1.8/core/array/delete_if_spec.rb
  121. 0 spec/{ruby → frozen}/1.8/core/array/delete_spec.rb
  122. +15 −0 spec/frozen/1.8/core/array/dup_spec.rb
  123. +30 −0 spec/frozen/1.8/core/array/each_index_spec.rb
  124. +44 −0 spec/frozen/1.8/core/array/each_spec.rb
  125. +30 −0 spec/frozen/1.8/core/array/element_reference_spec.rb
  126. +470 −0 spec/frozen/1.8/core/array/element_set_spec.rb
  127. 0 spec/{ruby → frozen}/1.8/core/array/empty_spec.rb
  128. +29 −0 spec/frozen/1.8/core/array/eql_spec.rb
  129. +46 −0 spec/frozen/1.8/core/array/equal_value_spec.rb
  130. +59 −0 spec/frozen/1.8/core/array/fetch_spec.rb
  131. +132 −0 spec/frozen/1.8/core/array/fill_spec.rb
  132. +59 −0 spec/frozen/1.8/core/array/first_spec.rb
  133. +40 −0 spec/frozen/1.8/core/array/fixtures/classes.rb
  134. +147 −0 spec/frozen/1.8/core/array/flatten_spec.rb
  135. 0 spec/{ruby → frozen}/1.8/core/array/frozen_spec.rb
  136. +60 −0 spec/frozen/1.8/core/array/hash_spec.rb
  137. 0 spec/{ruby → frozen}/1.8/core/array/include_spec.rb
  138. 0 spec/{ruby → frozen}/1.8/core/array/index_spec.rb
  139. +7 −0 spec/frozen/1.8/core/array/indexes_spec.rb
  140. +7 −0 spec/frozen/1.8/core/array/indices_spec.rb
  141. 0 spec/{ruby → frozen}/1.8/core/array/initialize_copy_spec.rb
  142. +75 −0 spec/frozen/1.8/core/array/initialize_spec.rb
  143. +80 −0 spec/frozen/1.8/core/array/insert_spec.rb
  144. 0 spec/{ruby → frozen}/1.8/core/array/inspect_spec.rb
  145. +69 −0 spec/frozen/1.8/core/array/intersection_spec.rb
  146. +81 −0 spec/frozen/1.8/core/array/join_spec.rb
  147. 0 spec/{ruby → frozen}/1.8/core/array/last_spec.rb
  148. 0 spec/{ruby → frozen}/1.8/core/array/length_spec.rb
  149. 0 spec/{ruby → frozen}/1.8/core/array/map_spec.rb
  150. +58 −0 spec/frozen/1.8/core/array/minus_spec.rb
  151. +76 −0 spec/frozen/1.8/core/array/multiply_spec.rb
  152. +87 −0 spec/frozen/1.8/core/array/new_spec.rb
  153. 0 spec/{ruby → frozen}/1.8/core/array/nitems_spec.rb
  154. +869 −0 spec/frozen/1.8/core/array/pack_spec.rb
  155. 0 spec/{ruby → frozen}/1.8/core/array/partition_spec.rb
  156. +34 −0 spec/frozen/1.8/core/array/plus_spec.rb
  157. 0 spec/{ruby → frozen}/1.8/core/array/pop_spec.rb
  158. +29 −0 spec/frozen/1.8/core/array/push_spec.rb
  159. 0 spec/{ruby → frozen}/1.8/core/array/rassoc_spec.rb
  160. +61 −0 spec/frozen/1.8/core/array/reject_spec.rb
  161. 0 spec/{ruby → frozen}/1.8/core/array/replace_spec.rb
  162. 0 spec/{ruby → frozen}/1.8/core/array/reverse_each_spec.rb
  163. +28 −0 spec/frozen/1.8/core/array/reverse_spec.rb
  164. 0 spec/{ruby → frozen}/1.8/core/array/rindex_spec.rb
  165. 0 spec/{ruby → frozen}/1.8/core/array/select_spec.rb
  166. +31 −0 spec/frozen/1.8/core/array/shared/clone.rb
  167. +25 −0 spec/frozen/1.8/core/array/shared/collect.rb
  168. +44 −0 spec/frozen/1.8/core/array/shared/equal.rb
  169. +31 −0 spec/frozen/1.8/core/array/shared/indexes.rb
  170. +6 −0 spec/frozen/1.8/core/array/shared/length.rb
  171. +42 −0 spec/frozen/1.8/core/array/shared/replace.rb
  172. +431 −0 spec/frozen/1.8/core/array/shared/slice.rb
  173. 0 spec/{ruby → frozen}/1.8/core/array/shift_spec.rb
  174. 0 spec/{ruby → frozen}/1.8/core/array/size_spec.rb
  175. +155 −0 spec/frozen/1.8/core/array/slice_spec.rb
  176. +120 −0 spec/frozen/1.8/core/array/sort_spec.rb
  177. +17 −0 spec/frozen/1.8/core/array/to_a_spec.rb
  178. +11 −0 spec/frozen/1.8/core/array/to_ary_spec.rb
  179. 0 spec/{ruby → frozen}/1.8/core/array/to_s_spec.rb
  180. +47 −0 spec/frozen/1.8/core/array/transpose_spec.rb
  181. +63 −0 spec/frozen/1.8/core/array/union_spec.rb
  182. +105 −0 spec/frozen/1.8/core/array/uniq_spec.rb
  183. +42 −0 spec/frozen/1.8/core/array/unshift_spec.rb
  184. +62 −0 spec/frozen/1.8/core/array/values_at_spec.rb
  185. +56 −0 spec/frozen/1.8/core/array/zip_spec.rb
  186. 0 spec/{ruby → frozen}/1.8/core/bignum/abs_spec.rb
  187. +35 −0 spec/frozen/1.8/core/bignum/bit_and_spec.rb
  188. 0 spec/{ruby → frozen}/1.8/core/bignum/bit_or_spec.rb
  189. 0 spec/{ruby → frozen}/1.8/core/bignum/bit_xor_spec.rb
  190. +27 −0 spec/frozen/1.8/core/bignum/coerce_spec.rb
  191. 0 spec/{ruby → frozen}/1.8/core/bignum/comparison_spec.rb
  192. 0 spec/{ruby → frozen}/1.8/core/bignum/complement_spec.rb
  193. +20 −0 spec/frozen/1.8/core/bignum/div_spec.rb
  194. +15 −0 spec/frozen/1.8/core/bignum/divide_spec.rb
  195. +45 −0 spec/frozen/1.8/core/bignum/divmod_spec.rb
  196. 0 spec/{ruby → frozen}/1.8/core/bignum/element_reference_spec.rb
  197. +22 −0 spec/frozen/1.8/core/bignum/eql_spec.rb
  198. +33 −0 spec/frozen/1.8/core/bignum/equal_value_spec.rb
  199. +18 −0 spec/frozen/1.8/core/bignum/exponent_spec.rb
  200. 0 spec/{ruby → frozen}/1.8/core/bignum/gt_spec.rb
  201. 0 spec/{ruby → frozen}/1.8/core/bignum/gte_spec.rb
  202. +12 −0 spec/frozen/1.8/core/bignum/hash_spec.rb
  203. +42 −0 spec/frozen/1.8/core/bignum/left_shift_spec.rb
  204. 0 spec/{ruby → frozen}/1.8/core/bignum/lt_spec.rb
  205. 0 spec/{ruby → frozen}/1.8/core/bignum/lte_spec.rb
  206. +19 −0 spec/frozen/1.8/core/bignum/minus_spec.rb
  207. 0 spec/{ruby → frozen}/1.8/core/bignum/modulo_spec.rb
  208. +19 −0 spec/frozen/1.8/core/bignum/multiply_spec.rb
  209. +19 −0 spec/frozen/1.8/core/bignum/plus_spec.rb
  210. +36 −0 spec/frozen/1.8/core/bignum/quo_spec.rb
  211. 0 spec/{ruby → frozen}/1.8/core/bignum/remainder_spec.rb
  212. +48 −0 spec/frozen/1.8/core/bignum/right_shift_spec.rb
  213. +27 −0 spec/frozen/1.8/core/bignum/shared/divide.rb
  214. +29 −0 spec/frozen/1.8/core/bignum/shared/modulo.rb
  215. +29 −0 spec/frozen/1.8/core/bignum/size_spec.rb
  216. +9 −0 spec/frozen/1.8/core/bignum/to_f_spec.rb
  217. +26 −0 spec/frozen/1.8/core/bignum/to_s_spec.rb
  218. 0 spec/{ruby → frozen}/1.8/core/bignum/uminus_spec.rb
  219. 0 spec/{ruby → frozen}/1.8/core/binding/clone_spec.rb
  220. 0 spec/{ruby → frozen}/1.8/core/binding/dup_spec.rb
  221. 0 spec/{ruby → frozen}/1.8/core/binding/fixtures/classes.rb
  222. +20 −0 spec/frozen/1.8/core/binding/shared/clone.rb
  223. 0 spec/{ruby → frozen}/1.8/core/class/allocate_spec.rb
  224. 0 spec/{ruby → frozen}/1.8/core/class/fixtures/classes.rb
  225. 0 spec/{ruby → frozen}/1.8/core/class/inherited_spec.rb
  226. 0 spec/{ruby/1.8/library/openstruct → frozen/1.8/core/class}/initialize_copy_spec.rb
  227. 0 spec/{ruby → frozen}/1.8/core/class/initialize_spec.rb
  228. +82 −0 spec/frozen/1.8/core/class/new_spec.rb
  229. 0 spec/{ruby → frozen}/1.8/core/class/superclass_spec.rb
  230. 0 spec/{ruby → frozen}/1.8/core/comparable/between_spec.rb
  231. +63 −0 spec/frozen/1.8/core/comparable/equal_value_spec.rb
  232. 0 spec/{ruby → frozen}/1.8/core/comparable/fixtures/classes.rb
  233. 0 spec/{ruby → frozen}/1.8/core/comparable/gt_spec.rb
  234. 0 spec/{ruby → frozen}/1.8/core/comparable/gte_spec.rb
  235. 0 spec/{ruby → frozen}/1.8/core/comparable/lt_spec.rb
  236. 0 spec/{ruby → frozen}/1.8/core/comparable/lte_spec.rb
  237. 0 spec/{ruby/1.8/library/zlib/zlib_version_spec.rb → frozen/1.8/core/continuation/call_spec.rb}
  238. 0 spec/{ruby → frozen}/1.8/core/continuation/continuation_spec.rb
  239. 0 ...{ruby/1.8/library/rational/to_s_spec.rb → frozen/1.8/core/continuation/element_reference_spec.rb}
  240. 0 spec/{ruby → frozen}/1.8/core/dir/chdir_spec.rb
  241. 0 spec/{ruby → frozen}/1.8/core/dir/chroot_spec.rb
  242. 0 spec/{ruby → frozen}/1.8/core/dir/close_spec.rb
  243. 0 spec/{ruby → frozen}/1.8/core/dir/delete_spec.rb
  244. 0 spec/{ruby → frozen}/1.8/core/dir/dir_spec.rb
  245. 0 spec/{ruby → frozen}/1.8/core/dir/each_spec.rb
  246. +11 −0 spec/frozen/1.8/core/dir/element_reference_spec.rb
  247. 0 spec/{ruby → frozen}/1.8/core/dir/entries_spec.rb
  248. +108 −0 spec/frozen/1.8/core/dir/fixtures/common.rb
  249. +22 −0 spec/frozen/1.8/core/dir/foreach_spec.rb
  250. 0 spec/{ruby → frozen}/1.8/core/dir/getwd_spec.rb
  251. +70 −0 spec/frozen/1.8/core/dir/glob_spec.rb
  252. 0 spec/{ruby → frozen}/1.8/core/dir/initialize_spec.rb
  253. 0 spec/{ruby → frozen}/1.8/core/dir/mkdir_spec.rb
  254. 0 spec/{ruby → frozen}/1.8/core/dir/new_spec.rb
  255. 0 spec/{ruby → frozen}/1.8/core/dir/open_spec.rb
  256. +31 −0 spec/frozen/1.8/core/dir/path_spec.rb
  257. 0 spec/{ruby → frozen}/1.8/core/dir/pos_spec.rb
  258. +21 −0 spec/frozen/1.8/core/dir/pwd_spec.rb
  259. 0 spec/{ruby → frozen}/1.8/core/dir/read_spec.rb
  260. 0 spec/{ruby → frozen}/1.8/core/dir/rewind_spec.rb
  261. 0 spec/{ruby → frozen}/1.8/core/dir/rmdir_spec.rb
  262. +11 −0 spec/frozen/1.8/core/dir/seek_spec.rb
  263. +9 −0 spec/frozen/1.8/core/dir/shared/closed.rb
  264. +21 −0 spec/frozen/1.8/core/dir/shared/delete.rb
  265. +254 −0 spec/frozen/1.8/core/dir/shared/glob.rb
  266. +33 −0 spec/frozen/1.8/core/dir/shared/open.rb
  267. +51 −0 spec/frozen/1.8/core/dir/shared/pos.rb
  268. +10 −0 spec/frozen/1.8/core/dir/shared/pwd.rb
  269. 0 spec/{ruby → frozen}/1.8/core/dir/tell_spec.rb
  270. 0 spec/{ruby → frozen}/1.8/core/dir/unlink_spec.rb
  271. +115 −0 spec/frozen/1.8/core/enumerable/all_spec.rb
  272. +128 −0 spec/frozen/1.8/core/enumerable/any_spec.rb
  273. 0 spec/{ruby → frozen}/1.8/core/enumerable/collect_spec.rb
  274. 0 spec/{ruby → frozen}/1.8/core/enumerable/detect_spec.rb
  275. 0 spec/{ruby → frozen}/1.8/core/enumerable/each_spec.rb
  276. +37 −0 spec/frozen/1.8/core/enumerable/each_with_index_spec.rb
  277. 0 spec/{ruby → frozen}/1.8/core/enumerable/entries_spec.rb
  278. 0 spec/{ruby → frozen}/1.8/core/enumerable/find_all_spec.rb
  279. 0 spec/{ruby → frozen}/1.8/core/enumerable/find_spec.rb
  280. +116 −0 spec/frozen/1.8/core/enumerable/fixtures/classes.rb
  281. 0 spec/{ruby → frozen}/1.8/core/enumerable/grep_spec.rb
  282. 0 spec/{ruby → frozen}/1.8/core/enumerable/include_spec.rb
  283. 0 spec/{ruby → frozen}/1.8/core/enumerable/inject_spec.rb
  284. 0 spec/{ruby → frozen}/1.8/core/enumerable/map_spec.rb
  285. 0 spec/{ruby → frozen}/1.8/core/enumerable/max_spec.rb
  286. 0 spec/{ruby → frozen}/1.8/core/enumerable/member_spec.rb
  287. 0 spec/{ruby → frozen}/1.8/core/enumerable/min_spec.rb
  288. +20 −0 spec/frozen/1.8/core/enumerable/partition_spec.rb
  289. +26 −0 spec/frozen/1.8/core/enumerable/reject_spec.rb
  290. 0 spec/{ruby → frozen}/1.8/core/enumerable/select_spec.rb
  291. +8 −0 spec/frozen/1.8/core/enumerable/shared/collect.rb
  292. +15 −0 spec/frozen/1.8/core/enumerable/shared/entries.rb
  293. +42 −0 spec/frozen/1.8/core/enumerable/shared/find.rb
  294. +9 −0 spec/frozen/1.8/core/enumerable/shared/find_all.rb
  295. +17 −0 spec/frozen/1.8/core/enumerable/shared/include.rb
  296. 0 spec/{ruby → frozen}/1.8/core/enumerable/sort_by_spec.rb
  297. 0 spec/{ruby → frozen}/1.8/core/enumerable/sort_spec.rb
  298. 0 spec/{ruby → frozen}/1.8/core/enumerable/to_a_spec.rb
  299. 0 spec/{ruby → frozen}/1.8/core/enumerable/zip_spec.rb
  300. +16 −0 spec/frozen/1.8/core/env/clear_spec.rb
Sorry, we could not display the entire diff because too many files (5,468) changed.
View
18 spec/compiler/array_spec.rb
@@ -8,29 +8,29 @@
]
gen x do |g|
- g.push 1
- g.push 2
- g.make_array 2
g.push :self
g.send :foo, 0, true
g.cast_array
+ g.push 1
+ g.push 2
+ g.make_array 2
g.send :+, 1
end
end
-
+
it "coerces the array reference and concatenates it to the first array" do
x = [:argscat,
- [:array, [:lit, 1], [:lit, 2]],
+ [:array, [:lit, 1], [:lit, 2]],
[:lvar, :x, 0]]
-
+
gen x do |g|
+ g.push_local 0
+ g.cast_array
g.push 1
g.push 2
g.make_array 2
- g.push_local 0
- g.cast_array
g.send :+, 1
end
end
-
+
end
View
341 spec/compiler/call_spec.rb
@@ -1,105 +1,110 @@
require File.dirname(__FILE__) + "/spec_helper"
describe Compiler do
-
+
it "compiles 'blah'" do
gen [:vcall, :blah] do |g|
g.push :self
g.send :blah, 0, true
end
end
-
+
it "compiles 'blah()'" do
gen [:fcall, :blah] do |g|
g.push :self
g.send :blah, 0, true
end
end
-
+
it "compiles 'blah(1,2)'" do
gen [:fcall, :blah, [:array, [:fixnum, 1], [:fixnum, 2]]] do |g|
- g.push :self
- g.push 1
g.push 2
- g.send :blah, 2, true
+ g.push 1
+ g.push :self
+ g.send :blah, 2, true
end
end
-
+
it "compiles 'blah(*a)'" do
gen [:fcall, :blah, [:splat, [:vcall, :a]]] do |g|
g.push :self
- g.push :self
g.send :a, 0, true
- g.cast_array
+ g.cast_array_for_args 0
+ g.push_array
+ g.get_args
g.push :nil
- g.send_with_splat :blah, 0, true, false
+ g.swap
+ g.push :self
+ g.swap
+ g.set_args
+ g.send_with_register :blah, true
end
end
-
+
it "compiles 'block_given?'" do
gen [:fcall, :block_given?] do |g|
g.push_block
end
end
-
+
it "compiles 'iterator?'" do
- gen [:fcall, :iterator?] do |g|
+ gen [:fcall, :block_given?] do |g|
g.push_block
end
end
-
-
+
+
it "compiles 'self.blah(1)'" do
x = [:call, [:self], :blah, [:array, [:fixnum, 1]]]
-
+
gen x do |g|
- g.push :self
g.push 1
+ g.push :self
g.send :blah, 1, false
end
end
-
+
it "compiles '1.go(2)'" do
x = [:call, [:fixnum, 1], :go, [:array, [:fixnum, 2]]]
-
+
gen x do |g|
- g.push 1
g.push 2
- g.send :go, 1, false
+ g.push 1
+ g.send :go, 1, false
end
end
-
+
it "compiles '10.times(2) { 12 }'" do
- x = [:iter,
- [:call, [:lit, 10], :times, [:array, [:fixnum, 2]]],
- nil,
+ x = [:iter,
+ [:call, [:lit, 10], :times, [:array, [:fixnum, 2]]],
+ nil,
[:lit, 12]
]
-
+
gen x do |g|
desc = description do |d|
d.pop
d.push_modifiers
d.new_label.set! # redo
d.push 12
d.pop_modifiers
- d.ret
+ d.soft_return
end
-
- g.push 10
+
g.push 2
g.push_literal desc
- g.create_block
+ g.create_block2
+ g.push 10
g.passed_block do
g.send_with_block :times, 1, false
end
end
end
-
+
it "compiles 'a.b(*c) { 12 }'" do
- x = [:iter,
- [:call, [:vcall, :a], :b, [:splat, [:vcall, :c]]],
- nil,
+ x = [:iter,
+ [:call, [:vcall, :a], :b, [:splat, [:vcall, :c]]],
+ nil,
[:lit, 12]
]
@@ -110,119 +115,144 @@
d.new_label.set! # redo
d.push 12
d.pop_modifiers
- d.ret
+ d.soft_return
end
g.push :self
- g.send :a, 0, true
-
- g.push :self
g.send :c, 0, true
- g.cast_array
+ g.cast_array_for_args 0
+ g.push_array
+ g.get_args
g.push_literal desc
- g.create_block
-
+ g.create_block2
+ g.swap
+ g.push :self
+ g.send :a, 0, true
+
g.passed_block do
- g.send_with_splat :b, 0, false, false
+ g.swap
+ g.set_args
+ g.send_with_register :b, false
end
end
end
-
+
it "compiles 'h[:blah] = 8'" do
x = [:attrasgn, [:vcall, :h], :[]=, [:array, [:lit, :blah], [:fixnum, 8]]]
-
+
gen x do |g|
+ g.push 8
+ g.dup
+ g.push_unique_literal :blah
g.push :self
g.send :h, 0, true
- g.push_unique_literal :blah
- g.push 8
g.send :[]=, 2, false
+ g.pop
end
end
-
+
it "compiles 'a.b = 8'" do
x = [:attrasgn, [:vcall, :a], :b, [:array, [:fixnum, 8]]]
-
+
gen x do |g|
+ g.push 8
+ g.dup
g.push :self
g.send :a, 0, true
- g.push 8
g.send :b=, 1, false
+ g.pop
end
end
-
+
it "compiles 'self[index, 0] = other_string'" do
- x = [:attrasgn, nil, :[]=,
- [:array, [:vcall, :index], [:fixnum, 0],
+ x = [:attrasgn, nil, :[]=,
+ [:array, [:vcall, :index], [:fixnum, 0],
[:vcall, :other_string]
]
]
-
+
gen x do |g|
g.push :self
+ g.send :other_string, 0, true
+ g.dup
+ g.push 0
g.push :self
g.send :index, 0, true
- g.push 0
g.push :self
- g.send :other_string, 0, true
g.send :[]=, 3, false
+ g.pop
end
end
-
+
# Dynamic argument count specs
it "compiles 'h(1, 2, *a)'" do
x = [:fcall, :h, [:argscat, [:array, [:fixnum, 1], [:fixnum, 2]],
[:vcall, :a]]]
gen x do |g|
g.push :self
- g.push 1
- g.push 2
-
- g.push :self
g.send :a, 0, true
- g.cast_array
-
+ g.cast_array_for_args 2
+ g.push_array
+ g.get_args
+ g.push 2
+ g.swap
+ g.push 1
+ g.swap
+
g.push :nil
- g.send_with_splat :h, 2, true, false
+ g.swap
+ g.push :self
+ g.swap
+ g.set_args
+ g.send_with_register :h, true
end
end
-
+
it "compiles 'f[*x] = 3'" do
- x = [:attrasgn, [:vcall, :f], :[]=,
+ x = [:attrasgn, [:vcall, :f], :[]=,
[:argspush, [:splat, [:vcall, :x]], [:fixnum, 3]]]
-
+
gen x do |g|
- g.push :self
- g.send :f, 0, true
+ g.push 3
+ g.dup
g.push :self
g.send :x, 0, true
- g.cast_array
- g.push 3
- g.swap
+ g.cast_array_for_args 1
+ g.push_array
+ g.get_args
g.push :nil
- g.send_with_splat :[]=, 1, false, true
+ g.swap
+ g.push :self
+ g.send :f, 0, true
+ g.swap
+ g.set_args
+ g.send_with_register :[]=, false
+ g.pop
end
end
-
+
it "compiles 'undef :blah'" do
gen [:undef, :blah] do |g|
+ g.push_literal :blah
g.push :self
g.send :metaclass, 0
- g.push_literal :blah
g.send :undef_method, 1
end
end
it "compiles 'class B; undef :blah; end'" do
x = [:class, [:colon2, :A], nil, [:scope, [:undef, :blah], []]]
-
+
gen x do |g|
desc = description do |d|
d.push :self
+ d.push_self_or_class
+ d.set_encloser
d.push_literal :blah
+ d.push :self
d.send :undef_method, 1
- d.ret
+ d.sret
end
-
+
g.push :nil
g.open_class :A
g.dup
@@ -231,165 +261,182 @@
g.attach_method :__class_init__
g.pop
g.send :__class_init__, 0
-
+ g.push_encloser
+
end
end
-
+
it "compiles 'yield'" do
x = [:yield, nil, false]
-
+
gen x do |g|
g.push_block
g.meta_send_call 0
end
end
-
+
it "compiles 'yield 1'" do
x = [:yield, [:fixnum, 1], false]
-
+
gen x do |g|
- g.push_block
g.push 1
+ g.push_block
g.meta_send_call 1
end
end
-
+
it "compiles 'yield 1, 2'" do
x = [:yield, [:array, [:fixnum, 1], [:fixnum, 2]], true]
-
+
gen x do |g|
- g.push_block
- g.push 1
g.push 2
+ g.push 1
+ g.push_block
g.meta_send_call 2
end
end
-
+
it "compiles 'yield [1, 2]'" do
x = [:yield, [:array, [:fixnum, 1], [:fixnum, 2]], false]
-
+
gen x do |g|
- g.push_block
g.push 1
g.push 2
g.make_array 2
+ g.push_block
g.meta_send_call 1
end
end
-
+
it "compiles 'yield *a'" do
x = [:yield, [:splat, [:vcall, :a]], false]
-
+
gen x do |g|
- g.push_block
g.push :self
g.send :a, 0, true
- g.cast_array
-
+ g.cast_array_for_args 0
+ g.push_array
+ g.get_args
+
+ g.set_args
g.push :nil
- g.send_with_splat :call, 0, false, false
+ g.push_block
+ g.send_with_register :call, false
end
end
-
- it "compiles 'super(1,2)'" do
+
+
+ it "compiles 'super(1)'" do
x = [:defn, :a, [:scope, [:block, [:args],
- [:super, [:array, [:fixnum, 1], [:fixnum, 2]]]], []]]
-
+ [:super, [:array, [:fixnum, 1]]]], []]]
+
gen x do |g|
desc = description do |d|
+ d.check_argcount 0, 0
d.push 1
- d.push 2
- d.push :nil
- d.send_super :a, 2
- d.ret
+ d.push_block
+ d.send_super :a, 1
+ d.sret
end
-
- g.push :self
- g.push_literal :a
+
g.push_literal desc
- g.send :__add_method__, 2
+ g.add_method :a
end
end
-
+
it "compiles 'super(*blah)'" do
x = [:defn, :a, [:scope, [:block, [:args],
[:super, [:splat, [:vcall, :blah]]]], []]]
-
+
gen x do |g|
desc = description do |d|
+ d.check_argcount 0, 0
d.push :self
d.send :blah, 0, true
- d.cast_array
- d.push :nil
- d.send_super_with_splat :a, 0
- d.ret
+ d.cast_array_for_args 0
+ d.push_array
+ d.get_args
+ d.push_block
+ d.swap
+ d.set_args
+ d.send_super :a
+ d.sret
end
-
- g.push :self
- g.push_literal :a
+
g.push_literal desc
- g.send :__add_method__, 2
+ g.add_method :a
end
end
-
+
+
it "compiles 'super'" do
x = [:defn, :a, [:scope, [:block, [:args, [:a, :b], [], nil, nil],
[:zsuper]], []]]
-
+
gen x do |g|
desc = description do |d|
- d.push_local 0
+ d.check_argcount 2, 2
+ d.set_local_from_fp 0, 0
+ d.set_local_from_fp 1, 1
d.push_local 1
- d.push :nil
+ d.push_local 0
+ d.push_block
d.send_super :a, 2
- d.ret
+ d.sret
end
-
- g.push :self
- g.push_literal :a
+
g.push_literal desc
- g.send :__add_method__, 2
+ g.add_method :a
+
end
-
+
end
-
+
it "compiles 'super' with a splat in the arg list" do
x = [:defn, :a, [:scope, [:block, [:args, [:name], [], [:rest, 1], nil],
[:zsuper]], []]]
-
+
gen x do |g|
desc = description do |d|
- d.push_local 0
+ d.check_argcount 1, -1
+ d.set_local_from_fp 0, 0
+ d.make_rest_fp 1
+ d.set_local 1
+ d.pop
d.push_local 1
- d.cast_array
- d.push :nil
- d.send_super_with_splat :a, 1
- d.ret
+ d.cast_array_for_args 1
+ d.push_array
+ d.get_args
+ d.push_local 0
+ d.swap
+ d.push_block
+ d.swap
+ d.set_args
+ d.send_super :a
+ d.sret
end
-
- g.push :self
- g.push_literal :a
+
g.push_literal desc
- g.send :__add_method__, 2
+ g.add_method :a
+
end
-
+
end
-
+
it "compiles 'foo(&blah)'" do
gen [:block_pass, [:vcall, :blah], [:fcall, :foo]] do |g|
g.push :self
- g.push :self
g.send :blah, 0, true
g.dup
g.is_nil
lbl = g.new_label
g.git lbl
g.push_cpath_top
g.find_const :Proc
- g.swap
g.send :__from_block__, 1
lbl.set!
- g.send_with_block :foo, 0, true
+ g.push :self
+ g.send_with_block :foo, 0, true
end
end
@@ -402,14 +449,14 @@
redo_label.set!
d.push 666
d.pop_modifiers
- d.ret
+ d.soft_return
end
desc.name = :__block__
desc.required = -1
- g.push :self
g.push_literal desc
- g.create_block
+ g.create_block2
+ g.push :self
g.passed_block do
g.send_with_block :at_exit, 0, true
end
View
75 spec/compiler/conditional_compilation_spec.rb
@@ -0,0 +1,75 @@
+require File.dirname(__FILE__) + "/spec_helper"
+
+# This is just:
+# Rubinius.compile_if($CompilerSpecsConditional) { $stderr.puts "Conditional" }
+
+
+describe Compiler, "conditional compilation with Rubinius.compile_if given an argument evaluating to false at compile time" do
+ it "completely omits the call block and its contained code from the bytecode output as if the block did not exist" do
+ full_sexp = [ :newline, 1, "../some/file",
+ [:iter,
+ [:call, [:const, :Rubinius], :compile_if,
+ [:array, [:gvar, :$CompilerSpecsConditional]]
+ ], nil,
+ [:newline, 1, "../some/file",
+ [:call, [:gvar, :$stderr], :puts,
+ [:array, [:str, "Conditional"]]
+ ]
+ ]
+ ]
+ ]
+
+ omitted_sexp = [:nil]
+
+ $CompilerSpecsConditional = false
+
+ c = Compiler.new Compiler::Generator
+ c.activate :conditional_compilation
+
+ a = c.into_script full_sexp
+ b = c.into_script omitted_sexp
+
+ a.class.should == Compiler::Node::Script
+ b.class.should == Compiler::Node::Script
+ a.body.class.should == Compiler::Node::Nil
+ b.body.class.should == Compiler::Node::Nil
+ end
+end
+
+describe Compiler, "conditional compilation with Rubinius.compile_if given an argument evaluating to true at compile time" do
+ it "omits the Rubinius.compile_if block artifacts from the produced bytecode" do
+ full_sexp = [ :newline, 1, "../some/file",
+ [:iter,
+ [:call, [:const, :Rubinius], :compile_if,
+ [:array, [:gvar, :$CompilerSpecsConditional]]
+ ], nil,
+ [:newline, 1, "../some/file",
+ [:call, [:gvar, :$stderr], :puts,
+ [:array, [:str, "Conditional"]]
+ ]
+ ]
+ ]
+ ]
+
+ included_sexp = [:newline, 1, "../some/file",
+ [:call, [:gvar, :$stderr], :puts,
+ [:array, [:str, "Conditional"]]
+ ]
+ ]
+
+ $CompilerSpecsConditional = true
+
+ c = Compiler.new Compiler::Generator
+ c.activate :conditional_compilation
+
+ a = c.into_script full_sexp
+ b = c.into_script included_sexp
+
+ a.class.should == b.class
+ a.body.class.should == b.body.class
+ a.body.file.should == b.body.file
+ a.body.child.method.should == b.body.child.method
+ a.body.child.object.name.should == b.body.child.object.name
+ end
+end
+
View
411 spec/compiler/control_spec.rb
@@ -143,21 +143,23 @@
g.push :true
g.git fin
g.goto top
-
+
fin.set!
g.push :nil
-
+
# Break
g.new_label.set!
-
+
g.pop_modifiers
end
end
-
+
it "compiles an each call" do
- sexp = [:iter, [:call,
- [:dot2, [:lit, 1], [:lit, 2]], :each],
- [:lasgn, :x]]
+ sexp = [:newline, 1, "(eval)",
+ [:iter,
+ [:call,
+ [:newline, 1, "(eval)", [:dot2, [:lit, 1], [:lit, 2]]], :each],
+ [:lasgn, :x] ] ]
gen(sexp) do |g|
iter = description do |d|
@@ -168,58 +170,59 @@
d.new_label.set!
d.push :nil
d.pop_modifiers
- d.ret
+ d.soft_return
end
+ g.push_literal iter
+ g.create_block2
+ g.push 2
+ g.push 1
g.push_cpath_top
g.find_const :Range
- g.push 1
- g.push 2
g.send :new, 2
- g.push_literal iter
- g.create_block
g.passed_block do
g.send_with_block :each, 0, false
end
end
end
it "compiles an each call with multiple block arguments" do
- sexp = [:iter, [:call, [:vcall, :x], :each], [:masgn,
- [:array, [:lasgn, :a], [:lasgn, :b]], nil, nil],
- [:block,
- [:dasgn_curr, :b, [:dasgn_curr, :a]],
- [:lit, 5]] ]
+ sexp = [:newline, 1, "(eval)",
+ [:iter, [:call, [:vcall, :x], :each], [:masgn,
+ [:array, [:lasgn, :a], [:lasgn, :b]], nil, nil],
+ [:block,
+ [:dasgn_curr, :b, [:dasgn_curr, :a]],
+ [:newline, 1, "(eval)", [:lit, 5]] ] ] ]
gen(sexp) do |g|
iter = description do |d|
d.cast_for_multi_block_arg
- d.shift_tuple
+ d.unshift_tuple
d.set_local_depth 0, 0
d.pop
- d.shift_tuple
+ d.unshift_tuple
d.set_local_depth 0, 1
d.pop
d.pop
d.push_modifiers
d.new_label.set!
d.push 5
d.pop_modifiers
- d.ret
+ d.soft_return
end
+ g.push_literal iter
+ g.create_block2
g.push :self
g.send :x, 0, true
- g.push_literal iter
- g.create_block
g.passed_block do
g.send_with_block :each, 0, false
end
end
end
it "compiles a for loop" do
- sexp = [:newline, 1, "(eval)",
- [:for,
- [:newline, 1, "(eval)", [:dot2, [:lit, 1], [:lit, 2]]],
+ sexp = [:newline, 1, "(eval)",
+ [:for,
+ [:newline, 1, "(eval)", [:dot2, [:lit, 1], [:lit, 2]]],
[:lasgn, :x] ] ]
gen(sexp) do |g|
@@ -231,24 +234,24 @@
d.new_label.set!
d.push :nil
d.pop_modifiers
- d.ret
+ d.soft_return
end
+ g.push_literal iter
+ g.create_block2
+ g.push 2
+ g.push 1
g.push_cpath_top
g.find_const :Range
- g.push 1
- g.push 2
g.send :new, 2
- g.push_literal iter
- g.create_block
g.passed_block(1) do
g.send_with_block :each, 0, false
end
end
end
it "compiles a for loop with an ivar assignment" do
- sexp = [:newline, 1, "(eval)",
- [:for, [:dot2, [:lit, 1], [:lit, 2]],
+ sexp = [:newline, 1, "(eval)",
+ [:for, [:dot2, [:lit, 1], [:lit, 2]],
[:iasgn, :@xyzzy] ] ]
gen(sexp) do |g|
@@ -260,67 +263,67 @@
d.new_label.set!
d.push :nil
d.pop_modifiers
- d.ret
+ d.soft_return
end
+ g.push_literal iter
+ g.create_block2
+ g.push 2
+ g.push 1
g.push_cpath_top
g.find_const :Range
- g.push 1
- g.push 2
g.send :new, 2
- g.push_literal iter
- g.create_block
g.passed_block do
g.send_with_block :each, 0, false
end
end
end
it "compiles a for loop with multiple arguments" do
- sexp = [:newline, 1, "(eval)",
- [:for, [:vcall, :x],
- [:masgn,
- [:array, [:lasgn, :a], [:lasgn, :b]], nil, nil],
+ sexp = [:newline, 1, "(eval)",
+ [:for, [:vcall, :x],
+ [:masgn,
+ [:array, [:lasgn, :a], [:lasgn, :b]], nil, nil],
[:newline, 2, "(eval)", [:lit, 5]] ] ]
gen(sexp) do |g|
iter = description do |d|
d.cast_for_multi_block_arg
- d.shift_tuple
+ d.unshift_tuple
d.set_local 0
d.pop
- d.shift_tuple
+ d.unshift_tuple
d.set_local 1
d.pop
d.pop
d.push_modifiers
d.new_label.set!
d.push 5
d.pop_modifiers
- d.ret
+ d.soft_return
end
+ g.push_literal iter
+ g.create_block2
g.push :self
g.send :x, 0, true
- g.push_literal iter
- g.create_block
g.passed_block(2) do
g.send_with_block :each, 0, false
end
end
end
it "compiles a for loop with multiple arguments and an inner lasgn" do
- sexp = [:newline, 1, "(eval)",
- [:for, [:vcall, :x],
- [:masgn, [:array, [:lasgn, :a], [:lasgn, :b]], nil, nil],
+ sexp = [:newline, 1, "(eval)",
+ [:for, [:vcall, :x],
+ [:masgn, [:array, [:lasgn, :a], [:lasgn, :b]], nil, nil],
[:newline, 2, "(eval)", [:lasgn, :z, [:lit, 5]]] ] ]
gen(sexp) do |g|
iter = description do |d|
d.cast_for_multi_block_arg
- d.shift_tuple
+ d.unshift_tuple
d.set_local 0
d.pop
- d.shift_tuple
+ d.unshift_tuple
d.set_local 1
d.pop
d.pop
@@ -329,12 +332,12 @@
d.push 5
d.set_local_depth 0,0
d.pop_modifiers
- d.ret
+ d.soft_return
end
+ g.push_literal iter
+ g.create_block2
g.push :self
g.send :x, 0, true
- g.push_literal iter
- g.create_block
g.passed_block(2) do
g.send_with_block :each, 0, false
end
@@ -357,7 +360,7 @@
end
end
- it "compiles loop {} directly" do
+ it "compiles loop directly" do
gen [:iter, [:fcall, :loop], nil, [:fixnum, 12]] do |g|
g.push_modifiers
@@ -371,7 +374,18 @@
g.pop_modifiers
end
end
-
+
+ it "compiles empty loop directly" do
+ gen [:iter, [:fcall, :loop], nil] do |g|
+ g.push_modifiers
+ top = g.new_label
+ top.set!
+ # No body, no stack manipulation
+ g.goto top
+ g.new_label.set! # break takes here
+ g.pop_modifiers
+ end
+ end
it "compiles break in a control" do
gen [:while, [:true], [:block, [:fixnum, 12], [:break]], true] do |g|
@@ -381,7 +395,7 @@
fin = g.new_label
g.redo = g.new_label
g.break = g.new_label
-
+
top.set!
g.push :true
g.gif fin
@@ -392,16 +406,16 @@
g.goto g.break
g.pop
g.goto top
-
+
fin.set!
g.push :nil
-
+
g.break.set!
-
+
g.pop_modifiers
end
end
-
+
it "compiles break in a block" do
gen [:iter, [:fcall, :go], nil, [:block, [:fixnum, 12], [:break]]] do |g|
iter = description do |d|
@@ -413,25 +427,24 @@
d.push :nil
d.push_local 0
- d.swap
d.send :break_value=, 1
d.pop
d.push_local 0
d.raise_exc
-
+
d.pop_modifiers
- d.ret
+ d.soft_return
end
-
- g.push :self
+
g.push_literal iter
- g.create_block
+ g.create_block2
+ g.push :self
g.passed_block do
g.send_with_block :go, 0, true
end
end
end
-
+
it "compiles an unexpected break" do
gen [:break] do |g|
g.push :nil
@@ -440,15 +453,15 @@
g.send :__unexpected_break__, 0
end
end
-
+
it "compiles redo in a while" do
gen [:while, [:true], [:block, [:fixnum, 12], [:redo]], true] do |g|
g.push_modifiers
-
+
top = g.new_label
fin = g.new_label
g.redo = g.new_label
-
+
top.set!
g.push :true
g.gif fin
@@ -458,17 +471,17 @@
g.goto g.redo
g.pop
g.goto top
-
+
fin.set!
g.push :nil
-
+
# Break
g.new_label.set!
-
+
g.pop_modifiers
end
end
-
+
it "compiles redo in a block" do
gen [:iter, [:fcall, :go], nil, [:block, [:fixnum, 12], [:redo]]] do |g|
iter = description do |d|
@@ -480,75 +493,72 @@
d.pop
d.goto d.redo
d.pop_modifiers
- d.ret
+ d.soft_return
end
-
- g.push :self
+
g.push_literal iter
- g.create_block
+ g.create_block2
+ g.push :self
g.passed_block do
g.send_with_block :go, 0, true
end
end
end
-
+
it "compiles an invalid redo" do
gen [:redo] do |g|
- g.push :self
+ g.push_literal "redo used in invalid context"
g.push_const :LocalJumpError
- g.push_literal "redo used in invalid context"
+ g.push :self
g.send :raise, 2, true
end
end
-
+
it "compiles a simple case" do
x = [:case, [:true], [[:when, [:array, [:const, :Fixnum]], [:fixnum, 12]]]]
gen x do |g|
nxt = g.new_label
fin = g.new_label
-
+
g.push :true
g.dup
-
+
g.push_const :Fixnum
- g.swap
g.send :===, 1
-
+
g.gif nxt
-
+
g.pop
g.push 12
g.goto fin
-
+
nxt.set!
g.pop
g.push :nil
fin.set!
end
end
-
+
it "compiles a case with multiple conditions" do
x = [:case, [:true], [
[:when, [:array, [:const, :Fixnum], [:const, :String]],
[:fixnum, 12]],
]]
-
+
gen x do |g|
nxt = g.new_label
fin = g.new_label
body = g.new_label
-
+
g.push :true
-
+
g.dup
g.push_const :Fixnum
- g.swap
g.send :===, 1
g.git body
-
+
g.dup
g.push_const :String
- g.swap
g.send :===, 1
g.git body
g.goto nxt
@@ -557,90 +567,87 @@
g.pop
g.push 12
g.goto fin
-
+
nxt.set!
g.pop
g.push :nil
fin.set!
end
-
+
end
-
+
it "compiles a case with multiple whens" do
x = [:case, [:true], [
- [:when, [:array, [:const, :Fixnum]],
+ [:when, [:array, [:const, :Fixnum]],
[:fixnum, 12]],
[:when, [:array, [:const, :String]],
[:fixnum, 13]]
]]
-
+
gen x do |g|
nxt1 = g.new_label
nxt2 = g.new_label
fin = g.new_label
-
+
g.push :true
-
+
g.dup
g.push_const :Fixnum
- g.swap
g.send :===, 1
-
+
g.gif nxt1
-
+
g.pop
g.push 12
g.goto fin
-
+
nxt1.set!
g.dup
g.push_const :String
- g.swap
g.send :===, 1
-
+
g.gif nxt2
-
+
g.pop
g.push 13
g.goto fin
-
+
nxt2.set!
g.pop
g.push :nil
fin.set!
end
-
+
end
-
+
it "compiles a case with an else" do
x = [:case, [:true], [
- [:when, [:array, [:const, :Fixnum]],
+ [:when, [:array, [:const, :Fixnum]],
[:fixnum, 12]],
], [:fixnum, 14]]
-
+
gen x do |g|
nxt = g.new_label
fin = g.new_label
-
+
g.push :true
g.dup
-
+
g.push_const :Fixnum
- g.swap
g.send :===, 1
-
+
g.gif nxt
-
+
g.pop
g.push 12
g.goto fin
-
+
nxt.set!
g.pop
g.push 14
fin.set!
end
-
+
end
it "compiles a case without an argument" do
@@ -653,7 +660,7 @@
[:str, "baz"]
]
- gen x do |g|
+ gen x do |g|
fin = g.new_label
cond2 = g.new_label
cond3 = g.new_label
@@ -672,26 +679,26 @@
g.push_literal "foo"
g.string_dup
g.goto fin
-
+
cond3.set!
-
- g.push 1
+
g.push 2
+ g.push 1
g.meta_send_op_equal
- g.gif cond4
+ g.gif cond4
g.push_literal "bar"
g.string_dup
g.goto fin
-
+
cond4.set!
g.push_literal "baz"
g.string_dup
-
+
fin.set!
end
end
-
+
it "compiles a case without an argument, branch with multiple conds" do
x = [:many_if,
[
@@ -721,100 +728,98 @@
g.push_literal "foo"
g.string_dup
g.goto fin
-
+
cond3.set!
-
- body = g.new_label
- g.push 1
+
+ body = g.new_label
g.push 2
+ g.push 1
g.meta_send_op_equal
g.git body
g.push 13
g.git body
g.goto cond4
-
+
body.set!
g.push_literal "bar"
g.string_dup
g.goto fin
-
+
cond4.set!
-
+
g.push :nil
-
+
fin.set!
end
end
-
+
+
it "compiles a case with a splat" do
x = [:case, [:true], [
- [:when, [:array, [:when, [:vcall, :things], nil]],
+ [:when, [:array, [:when, [:vcall, :things], nil]],
[:fixnum, 12]],
]]
-
+
gen x do |g|
body = g.new_label
nxt = g.new_label
fin = g.new_label
-
+
g.push :true
-
+
g.dup
g.push :self
g.send :things, 0, true
g.cast_array
- g.swap
g.send :__matches_when__, 1
g.git body
-
+
g.goto nxt
-
+
body.set!
g.pop
g.push 12
g.goto fin
-
+
nxt.set!
g.pop
g.push :nil
fin.set!
end
end
-
+
it "compiles a case with normal conditions and a splat" do
x = [:case, [:true], [
- [:when, [:array, [:const, :String], [:when, [:vcall, :things], nil]],
+ [:when, [:array, [:const, :String], [:when, [:vcall, :things], nil]],
[:fixnum, 12]],
]]
-
+
gen x do |g|
body = g.new_label
nxt = g.new_label
fin = g.new_label
-
+
g.push :true
-
+
g.dup
g.push_const :String
- g.swap
g.send :===, 1
g.git body
-
+
g.dup
g.push :self
g.send :things, 0, true
g.cast_array
- g.swap
g.send :__matches_when__, 1
g.git body
-
+
g.goto nxt
-
+
body.set!
g.pop
g.push 12
g.goto fin
-
+
nxt.set!
g.pop
g.push :nil
@@ -827,120 +832,116 @@
[:when, [:array, [:const, :String], [:when, [:array, [:str, "foo"],[:str, "bar"],[:str, "baz"]], nil]],
[:fixnum, 12]],
]]
-
+
gen x do |g|
body = g.new_label
nxt = g.new_label
fin = g.new_label
-
+
g.push :true
-
+
g.dup
g.push_const :String
- g.swap
g.send :===, 1
g.git body
-
+
g.dup
g.push_literal "foo"
g.string_dup
- g.swap
g.send :===, 1
g.git body
-
+
g.dup
g.push_literal "bar"
g.string_dup
- g.swap
g.send :===, 1
g.git body
-
+
g.dup
g.push_literal "baz"
g.string_dup
- g.swap
g.send :===, 1
g.git body
-
+
g.goto nxt
-
+
body.set!
g.pop
g.push 12
g.goto fin
-
+
nxt.set!
g.pop
g.push :nil
fin.set!
end
end
-
+
it "compiles 'return'" do
gen [:return] do |g|
g.push :nil
- g.ret
+ g.sret
end
end
-
+
it "compiles 'return 12'" do
gen [:return, [:fixnum, 12]] do |g|
g.push 12
- g.ret
+ g.sret
end
end
-
- it "compiles 'begin; 12; rescue; return 13; end'" do
- x = [:rescue, [:fixnum, 12],
+
+ it "compiles 'begin; 12; rescue; return 13; end'" do
+ x = [:rescue, [:fixnum, 12],
[:resbody, [:array, [:const, :String]],
[:return, [:fixnum, 13]], nil
]
]
-
+
gen x do |g|
g.push_modifiers
-
+
exc_start = g.new_label
exc_handle = g.new_label
-
+
fin = g.new_label
rr = g.new_label
last = g.new_label
-
+
exc_start.set!
exc_start.set!
g.push 12
g.goto fin
-
+
exc_handle.set!
- g.push_const :String
g.push_exception
+ g.push_const :String
g.send :===, 1
body = g.new_label
-
+
g.git body
g.goto rr
body.set!
g.clear_exception
g.push 13
- g.ret
+ g.sret
g.clear_exception
-
+
g.goto last
-
+
rr.set!
-
+
g.push_exception
g.raise_exc
-
+
fin.set!
-
+
last.set!
-
+
g.pop_modifiers
end
end
-
+
it "compiles return in a block" do
gen [:iter, [:fcall, :go], nil, [:block, [:return, [:fixnum, 12]]]] do |g|
iter = description do |d|
@@ -949,39 +950,37 @@
d.new_label.set! # redo
d.push 12
d.push_local 0
- d.swap
d.send :return_value=, 1
d.pop
d.push_local 0
d.raise_exc
d.pop_modifiers
- d.ret
+ d.soft_return
end
-
- g.push :self
+
g.push_literal iter
- g.create_block
+ g.create_block2
+ g.push :self
g.passed_block do
g.send_with_block :go, 0, true
end
end
end
-
+
it "compiles 'return 1, 2, *c'" do
- x = [:return, [:argscat,
+ x = [:return, [:argscat,
[:array, [:fixnum, 1], [:fixnum, 2]],
[:vcall, :c]]]
gen x do |g|
- g.push 1
- g.push 2
- g.make_array 2
-
g.push :self
g.send :c, 0, true
g.cast_array
-
+
+ g.push 1
+ g.push 2
+ g.make_array 2
g.send :+, 1
- g.ret
+ g.sret
end
end
end
View
26 spec/compiler/defined_spec.rb
@@ -3,16 +3,34 @@
describe Compiler do
it "compiles defined? instance_exec" do
gen [:defined, [:vcall, :instance_exec]] do |g|
- g.push :self
+ responded = g.new_label
+ done = g.new_label
+ g.push :true
g.push_literal :instance_exec
- g.send :"respond_to?", 1
+ g.push :self
+ g.send :__respond_to_eh__, 2
+ g.git responded
+ g.push_nil
+ g.goto done
+ responded.set!
+ g.push_literal "method"
+ done.set!
end
end
it "compiles defined? instance_exec()" do
gen [:defined, [:fcall, :instance_exec]] do |g|
- g.push :self
+ responded = g.new_label
+ done = g.new_label
+ g.push :true