opal 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (796) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +8 -0
  5. data/CONTRIBUTING.md +46 -2
  6. data/Gemfile +17 -0
  7. data/README.md +13 -4
  8. data/Rakefile +22 -119
  9. data/bin/opal +11 -2
  10. data/bin/opal-repl +71 -0
  11. data/corelib/array.rb +554 -356
  12. data/corelib/basic_object.rb +22 -18
  13. data/corelib/boolean.rb +15 -6
  14. data/corelib/class.rb +12 -6
  15. data/corelib/comparable.rb +40 -9
  16. data/corelib/encoding.rb +164 -0
  17. data/corelib/enumerable.rb +532 -300
  18. data/corelib/enumerator.rb +31 -6
  19. data/corelib/error.rb +14 -3
  20. data/corelib/hash.rb +108 -97
  21. data/corelib/io.rb +30 -0
  22. data/corelib/kernel.rb +151 -82
  23. data/corelib/main.rb +7 -0
  24. data/corelib/match_data.rb +118 -0
  25. data/corelib/method.rb +58 -0
  26. data/corelib/module.rb +145 -77
  27. data/corelib/native.rb +144 -22
  28. data/corelib/nil_class.rb +2 -0
  29. data/corelib/numeric.rb +259 -61
  30. data/corelib/opal.rb +43 -28
  31. data/corelib/proc.rb +21 -9
  32. data/corelib/range.rb +42 -23
  33. data/corelib/regexp.rb +51 -9
  34. data/corelib/runtime.js +470 -129
  35. data/corelib/string.rb +170 -246
  36. data/corelib/struct.rb +13 -1
  37. data/corelib/time.rb +414 -43
  38. data/doc/compiler.md +42 -0
  39. data/doc/compiler_options.md +5 -0
  40. data/doc/examples/node_http_server.rb +49 -0
  41. data/doc/external_libraries.md +9 -0
  42. data/doc/generated_javascript.md +272 -0
  43. data/doc/home.md +17 -0
  44. data/doc/method_missing.md +58 -0
  45. data/doc/static_applications.md +60 -0
  46. data/doc/using_ruby_from_javascript.md +18 -0
  47. data/doc/using_sprockets.md +65 -0
  48. data/lib/opal.rb +18 -15
  49. data/lib/opal/builder.rb +26 -9
  50. data/lib/opal/cli.rb +143 -90
  51. data/lib/opal/cli_options.rb +19 -13
  52. data/lib/opal/compiler.rb +307 -0
  53. data/lib/opal/erb.rb +3 -3
  54. data/lib/opal/fragment.rb +34 -0
  55. data/lib/opal/nodes.rb +25 -0
  56. data/lib/opal/nodes/arglist.rb +56 -0
  57. data/lib/opal/nodes/array.rb +54 -0
  58. data/lib/opal/nodes/base.rb +150 -0
  59. data/lib/opal/nodes/base_scope.rb +11 -0
  60. data/lib/opal/nodes/call.rb +195 -0
  61. data/lib/opal/nodes/call_special.rb +153 -0
  62. data/lib/opal/nodes/case.rb +96 -0
  63. data/lib/opal/nodes/class.rb +43 -0
  64. data/lib/opal/nodes/constants.rb +91 -0
  65. data/lib/opal/nodes/def.rb +157 -0
  66. data/lib/opal/nodes/defined.rb +113 -0
  67. data/lib/opal/nodes/definitions.rb +182 -0
  68. data/lib/opal/nodes/hash.rb +67 -0
  69. data/lib/opal/nodes/helpers.rb +105 -0
  70. data/lib/opal/nodes/if.rb +60 -0
  71. data/lib/opal/nodes/iter.rb +118 -0
  72. data/lib/opal/nodes/literal.rb +193 -0
  73. data/lib/opal/nodes/logic.rb +211 -0
  74. data/lib/opal/nodes/masgn.rb +62 -0
  75. data/lib/opal/nodes/module.rb +46 -0
  76. data/lib/opal/nodes/rescue.rb +134 -0
  77. data/lib/opal/nodes/singleton_class.rb +26 -0
  78. data/lib/opal/nodes/super.rb +97 -0
  79. data/lib/opal/nodes/top.rb +63 -0
  80. data/lib/opal/nodes/variables.rb +155 -0
  81. data/lib/opal/nodes/while.rb +65 -0
  82. data/lib/opal/nodes/yield.rb +84 -0
  83. data/lib/opal/parser.rb +294 -2169
  84. data/lib/opal/parser/grammar.rb +5326 -0
  85. data/lib/opal/{grammar.y → parser/grammar.y} +180 -113
  86. data/lib/opal/parser/keywords.rb +64 -0
  87. data/lib/opal/{lexer.rb → parser/lexer.rb} +278 -327
  88. data/lib/opal/{lexer_scope.rb → parser/parser_scope.rb} +2 -5
  89. data/lib/opal/parser/sexp.rb +63 -0
  90. data/lib/opal/source_map.rb +6 -5
  91. data/lib/opal/target_scope.rb +15 -17
  92. data/lib/opal/version.rb +1 -1
  93. data/mri_spec/cli_spec.rb +67 -6
  94. data/opal.gemspec +4 -4
  95. data/spec/config.ru +2 -1
  96. data/spec/corelib/enumerable/all_break_spec.rb +5 -0
  97. data/spec/corelib/enumerable/any_break_spec.rb +5 -0
  98. data/spec/corelib/enumerable/collect_break_spec.rb +13 -0
  99. data/spec/corelib/enumerable/count_break_spec.rb +5 -0
  100. data/spec/corelib/enumerable/detect_break_spec.rb +5 -0
  101. data/spec/corelib/enumerable/drop_while_break_spec.rb +5 -0
  102. data/spec/corelib/enumerable/each_slice_break.rb +6 -0
  103. data/spec/corelib/enumerable/each_with_index_break_spec.rb +5 -0
  104. data/spec/corelib/enumerable/each_with_object_break_spec.rb +5 -0
  105. data/spec/corelib/enumerable/find_all_break_spec.rb +5 -0
  106. data/spec/corelib/enumerable/find_index_break_spec.rb +5 -0
  107. data/spec/corelib/enumerable/grep_break_spec.rb +5 -0
  108. data/spec/corelib/enumerable/max_break_spec.rb +5 -0
  109. data/spec/corelib/enumerable/max_by_break_spec.rb +5 -0
  110. data/spec/corelib/enumerable/min_break_spec.rb +5 -0
  111. data/spec/corelib/enumerable/min_by_break_spec.rb +5 -0
  112. data/spec/corelib/enumerable/none_break_spec.rb +5 -0
  113. data/spec/corelib/enumerable/one_break_spec.rb +5 -0
  114. data/spec/corelib/enumerable/reduce_break_spec.rb +5 -0
  115. data/spec/corelib/enumerable/take_while_break_spec.rb +5 -0
  116. data/spec/{rubyspec → corelib}/fixtures/class.rb +0 -0
  117. data/spec/{rubyspec → corelib}/fixtures/class_variables.rb +0 -0
  118. data/spec/{rubyspec → corelib}/fixtures/constants.rb +0 -0
  119. data/spec/{rubyspec/core → corelib}/kernel/Array_spec.rb +0 -0
  120. data/spec/{opal → corelib}/kernel/block_given_spec.rb +0 -0
  121. data/spec/{opal → corelib}/kernel/class_spec.rb +0 -0
  122. data/spec/{rubyspec/core → corelib}/kernel/define_singleton_method_spec.rb +0 -0
  123. data/spec/{rubyspec/core → corelib}/kernel/equal_value_spec.rb +0 -0
  124. data/spec/{opal → corelib}/kernel/extend_spec.rb +0 -0
  125. data/spec/{opal → corelib}/kernel/format_spec.rb +0 -0
  126. data/spec/{opal → corelib}/kernel/freeze_spec.rb +0 -0
  127. data/spec/{rubyspec/core → corelib}/kernel/instance_eval_spec.rb +0 -0
  128. data/spec/{opal → corelib}/kernel/instance_variable_defined_spec.rb +0 -0
  129. data/spec/{rubyspec/core → corelib}/kernel/instance_variable_get_spec.rb +0 -0
  130. data/spec/{rubyspec/core → corelib}/kernel/instance_variable_set_spec.rb +0 -0
  131. data/spec/{rubyspec/core → corelib}/kernel/loop_spec.rb +0 -0
  132. data/spec/{opal → corelib}/kernel/match_spec.rb +0 -0
  133. data/spec/{opal → corelib}/kernel/method_spec.rb +0 -0
  134. data/spec/{opal → corelib}/kernel/methods_spec.rb +0 -0
  135. data/spec/{opal → corelib}/kernel/nil_spec.rb +0 -0
  136. data/spec/{opal → corelib}/kernel/p_spec.rb +8 -6
  137. data/spec/{opal → corelib}/kernel/printf_spec.rb +4 -2
  138. data/spec/{opal → corelib}/kernel/proc_spec.rb +0 -0
  139. data/spec/{opal → corelib}/kernel/rand_spec.rb +0 -0
  140. data/spec/{opal → corelib}/kernel/respond_to_spec.rb +0 -0
  141. data/spec/{rubyspec/core → corelib}/kernel/send_spec.rb +0 -0
  142. data/spec/{opal → corelib}/kernel/sprintf_spec.rb +0 -0
  143. data/spec/corelib/kernel/warn_spec.rb +83 -0
  144. data/spec/{rubyspec → corelib}/language/block_spec.rb +17 -18
  145. data/spec/{rubyspec → corelib}/language/fixtures/array.rb +0 -0
  146. data/spec/{rubyspec → corelib}/language/fixtures/block.rb +0 -0
  147. data/spec/{rubyspec → corelib}/language/fixtures/break.rb +0 -0
  148. data/spec/{rubyspec → corelib}/language/fixtures/ensure.rb +0 -0
  149. data/spec/{rubyspec → corelib}/language/fixtures/literal_lambda.rb +0 -0
  150. data/spec/{rubyspec → corelib}/language/fixtures/metaclass.rb +0 -0
  151. data/spec/{rubyspec → corelib}/language/fixtures/module.rb +0 -0
  152. data/spec/{rubyspec → corelib}/language/fixtures/next.rb +0 -0
  153. data/spec/{rubyspec → corelib}/language/fixtures/return.rb +0 -0
  154. data/spec/{rubyspec → corelib}/language/fixtures/send.rb +1 -1
  155. data/spec/{rubyspec → corelib}/language/fixtures/send_1.9.rb +0 -0
  156. data/spec/{rubyspec → corelib}/language/fixtures/super.rb +0 -0
  157. data/spec/{rubyspec → corelib}/language/fixtures/variables.rb +0 -0
  158. data/spec/{rubyspec → corelib}/language/fixtures/yield.rb +0 -0
  159. data/spec/{rubyspec → corelib}/language/numbers_spec.rb +0 -2
  160. data/spec/{rubyspec → corelib}/language/predefined_spec.rb +0 -0
  161. data/spec/{rubyspec → corelib}/language/proc_spec.rb +0 -2
  162. data/spec/{rubyspec → corelib}/language/regexp_spec.rb +0 -0
  163. data/spec/{rubyspec → corelib}/language/send_spec.rb +6 -7
  164. data/spec/{rubyspec → corelib}/language/string_spec.rb +0 -0
  165. data/spec/{rubyspec → corelib}/language/symbol_spec.rb +0 -0
  166. data/spec/{rubyspec → corelib}/language/variables_spec.rb +1 -2
  167. data/spec/{rubyspec → corelib}/language/versions/array_1.9.rb +0 -0
  168. data/spec/{rubyspec → corelib}/language/versions/block_1.9.rb +0 -0
  169. data/spec/{rubyspec → corelib}/language/versions/break_1.9.rb +0 -0
  170. data/spec/{rubyspec → corelib}/language/versions/case_1.9.rb +0 -0
  171. data/spec/{rubyspec → corelib}/language/versions/hash_1.9.rb +0 -0
  172. data/spec/{rubyspec → corelib}/language/versions/literal_lambda_1.9.rb +0 -0
  173. data/spec/{rubyspec → corelib}/language/versions/not_1.9.rb +0 -0
  174. data/spec/{rubyspec → corelib}/language/versions/send_1.9.rb +0 -0
  175. data/spec/{rubyspec → corelib}/language/versions/symbol_1.9.rb +0 -0
  176. data/spec/{rubyspec → corelib}/language/versions/variables_1.9.rb +1 -1
  177. data/spec/corelib/module/alias_method_spec.rb +28 -0
  178. data/spec/{opal → corelib}/module/ancestors_spec.rb +0 -0
  179. data/spec/{opal → corelib}/module/append_features_spec.rb +0 -0
  180. data/spec/corelib/module/attr_accessor_spec.rb +26 -0
  181. data/spec/{rubyspec/core → corelib}/module/const_defined_spec.rb +1 -2
  182. data/spec/{rubyspec/core → corelib}/module/const_get_spec.rb +1 -2
  183. data/spec/{rubyspec/core → corelib}/module/const_missing_spec.rb +1 -2
  184. data/spec/{rubyspec/core → corelib}/module/const_set_spec.rb +1 -2
  185. data/spec/{opal → corelib}/module/constants_spec.rb +0 -0
  186. data/spec/{rubyspec/core → corelib}/module/fixtures/classes.rb +0 -0
  187. data/spec/{rubyspec/core → corelib}/module/method_defined_spec.rb +0 -1
  188. data/spec/{opal → corelib}/module/module_function_spec.rb +0 -2
  189. data/spec/corelib/module/name_spec.rb +52 -0
  190. data/spec/{rubyspec/core → corelib}/module/public_method_defined_spec.rb +0 -1
  191. data/spec/{rubyspec/core → corelib}/module/remove_const_spec.rb +0 -1
  192. data/spec/{rubyspec/core → corelib}/module/undef_method_spec.rb +0 -1
  193. data/spec/{opal → corelib}/native/alias_native_spec.rb +7 -0
  194. data/spec/{opal → corelib}/native/each_spec.rb +2 -5
  195. data/spec/{opal → corelib}/native/element_reference_spec.rb +0 -0
  196. data/spec/{rubyspec/core/hash/to_native_spec.rb → corelib/native/ext_spec.rb} +0 -0
  197. data/spec/corelib/native/initialize_spec.rb +17 -0
  198. data/spec/{opal → corelib}/native/method_missing_spec.rb +0 -0
  199. data/spec/corelib/native/new_spec.rb +6 -0
  200. data/spec/{rubyspec/core → corelib}/numeric/abs_spec.rb +0 -0
  201. data/spec/{rubyspec/core → corelib}/numeric/bit_and_spec.rb +0 -0
  202. data/spec/{rubyspec/core → corelib}/numeric/bit_or_spec.rb +0 -0
  203. data/spec/{rubyspec/core → corelib}/numeric/bit_xor_spec.rb +0 -0
  204. data/spec/{rubyspec/core → corelib}/numeric/ceil_spec.rb +0 -0
  205. data/spec/{rubyspec/core → corelib}/numeric/chr_spec.rb +0 -0
  206. data/spec/{rubyspec/core → corelib}/numeric/comparison_spec.rb +0 -0
  207. data/spec/{rubyspec/core → corelib}/numeric/complement_spec.rb +0 -0
  208. data/spec/{rubyspec/core → corelib}/numeric/divide_spec.rb +0 -0
  209. data/spec/{rubyspec/core → corelib}/numeric/downto_spec.rb +0 -0
  210. data/spec/{rubyspec/core → corelib}/numeric/eql_spec.rb +0 -0
  211. data/spec/{rubyspec/core → corelib}/numeric/equal_value_spec.rb +0 -0
  212. data/spec/{rubyspec/core → corelib}/numeric/even_spec.rb +0 -0
  213. data/spec/{rubyspec/core → corelib}/numeric/exponent_spec.rb +0 -0
  214. data/spec/{rubyspec/core → corelib}/numeric/floor_spec.rb +0 -0
  215. data/spec/{rubyspec/core → corelib}/numeric/gt_spec.rb +0 -0
  216. data/spec/{rubyspec/core → corelib}/numeric/gte_spec.rb +0 -0
  217. data/spec/{rubyspec/core → corelib}/numeric/integer_spec.rb +0 -0
  218. data/spec/{rubyspec/core → corelib}/numeric/left_shift_spec.rb +0 -0
  219. data/spec/{rubyspec/core → corelib}/numeric/lt_spec.rb +0 -0
  220. data/spec/{rubyspec/core → corelib}/numeric/lte_spec.rb +0 -0
  221. data/spec/{rubyspec/core → corelib}/numeric/magnitude_spec.rb +0 -0
  222. data/spec/{rubyspec/core → corelib}/numeric/minus_spec.rb +0 -0
  223. data/spec/{rubyspec/core → corelib}/numeric/modulo_spec.rb +0 -0
  224. data/spec/{rubyspec/core → corelib}/numeric/multiply_spec.rb +0 -0
  225. data/spec/{rubyspec/core → corelib}/numeric/next_spec.rb +0 -0
  226. data/spec/{rubyspec/core → corelib}/numeric/odd_spec.rb +0 -0
  227. data/spec/{rubyspec/core → corelib}/numeric/ord_spec.rb +0 -0
  228. data/spec/{rubyspec/core → corelib}/numeric/plus_spec.rb +0 -0
  229. data/spec/{rubyspec/core → corelib}/numeric/pred_spec.rb +0 -0
  230. data/spec/{rubyspec/core → corelib}/numeric/right_shift_spec.rb +0 -0
  231. data/spec/{rubyspec/core → corelib}/numeric/step_spec.rb +0 -3
  232. data/spec/{rubyspec/core → corelib}/numeric/succ_spec.rb +0 -0
  233. data/spec/{rubyspec/core → corelib}/numeric/times_spec.rb +0 -0
  234. data/spec/{rubyspec/core → corelib}/numeric/to_f_spec.rb +0 -0
  235. data/spec/{rubyspec/core → corelib}/numeric/to_i_spec.rb +0 -0
  236. data/spec/{rubyspec/core → corelib}/numeric/to_json_spec.rb +0 -0
  237. data/spec/corelib/numeric/to_s_spec.rb +26 -0
  238. data/spec/{rubyspec/core → corelib}/numeric/uminus_spec.rb +0 -0
  239. data/spec/{rubyspec/core → corelib}/numeric/upto_spec.rb +0 -0
  240. data/spec/{rubyspec/core → corelib}/numeric/zero_spec.rb +0 -0
  241. data/spec/{rubyspec/core → corelib}/proc/call_spec.rb +0 -0
  242. data/spec/{rubyspec/core → corelib}/proc/element_reference_spec.rb +0 -0
  243. data/spec/{opal → corelib}/proc/proc_tricks_spec.rb +0 -0
  244. data/spec/corelib/runtime/begin_spec.rb +39 -0
  245. data/spec/{opal → corelib}/runtime/block_send_spec.rb +0 -0
  246. data/spec/{opal/language → corelib/runtime}/block_spec.rb +10 -0
  247. data/spec/corelib/runtime/bridged_classes_spec.rb +64 -0
  248. data/spec/{opal → corelib/runtime}/constants_spec.rb +0 -0
  249. data/spec/{opal → corelib}/runtime/eval_spec.rb +0 -0
  250. data/spec/{opal → corelib}/runtime/main_methods_spec.rb +0 -0
  251. data/spec/{opal → corelib/runtime}/method_missing_spec.rb +0 -0
  252. data/spec/corelib/runtime/method_spec.rb +31 -0
  253. data/spec/corelib/runtime/paren_spec.rb +14 -0
  254. data/spec/{opal/language → corelib/runtime}/rescue_spec.rb +11 -0
  255. data/spec/{opal/language → corelib/runtime}/return_spec.rb +0 -0
  256. data/spec/{opal → corelib}/runtime/send_spec.rb +0 -0
  257. data/spec/{opal/language → corelib/runtime}/singleton_class_spec.rb +0 -0
  258. data/spec/{opal/language → corelib/runtime}/super_spec.rb +113 -0
  259. data/spec/{opal/language → corelib/runtime}/variables_spec.rb +0 -0
  260. data/spec/{opal → corelib}/source_map_spec.rb +3 -3
  261. data/spec/{rubyspec/core → corelib}/string/chop_spec.rb +0 -0
  262. data/spec/{rubyspec/core → corelib}/string/chr_spec.rb +0 -0
  263. data/spec/{rubyspec/core → corelib}/string/clone_spec.rb +0 -0
  264. data/spec/{rubyspec/core → corelib}/string/comparison_spec.rb +0 -0
  265. data/spec/{rubyspec/core → corelib}/string/dup_spec.rb +0 -0
  266. data/spec/{rubyspec/core → corelib}/string/element_reference_spec.rb +0 -1
  267. data/spec/{rubyspec/core → corelib}/string/fixtures/classes.rb +0 -0
  268. data/spec/{rubyspec/core → corelib}/string/format_spec.rb +0 -0
  269. data/spec/{opal → corelib}/string/freeze_spec.rb +0 -0
  270. data/spec/{rubyspec/core → corelib}/string/gsub_spec.rb +0 -0
  271. data/spec/{rubyspec/core → corelib}/string/lines_spec.rb +0 -0
  272. data/spec/{rubyspec/core → corelib}/string/ljust_spec.rb +0 -1
  273. data/spec/{rubyspec/core → corelib}/string/lstrip_spec.rb +0 -0
  274. data/spec/{rubyspec/core → corelib}/string/match_spec.rb +0 -0
  275. data/spec/{rubyspec/core → corelib}/string/next_spec.rb +0 -0
  276. data/spec/{rubyspec/core → corelib}/string/ord_spec.rb +0 -0
  277. data/spec/{rubyspec/core → corelib}/string/partition_spec.rb +0 -0
  278. data/spec/{rubyspec/core → corelib}/string/rindex_spec.rb +0 -0
  279. data/spec/{rubyspec/core → corelib}/string/rjust_spec.rb +0 -1
  280. data/spec/{rubyspec/core → corelib}/string/rstrip_spec.rb +0 -0
  281. data/spec/{rubyspec/core → corelib}/string/scan_spec.rb +0 -0
  282. data/spec/{rubyspec/core → corelib}/string/slice_spec.rb +1 -2
  283. data/spec/{rubyspec/core → corelib}/string/split_spec.rb +0 -0
  284. data/spec/{rubyspec/core → corelib}/string/strip_spec.rb +0 -0
  285. data/spec/{rubyspec/core → corelib}/string/sub_spec.rb +0 -0
  286. data/spec/{rubyspec/core → corelib}/string/succ_spec.rb +0 -0
  287. data/spec/{rubyspec/core → corelib}/string/sum_spec.rb +0 -0
  288. data/spec/{rubyspec/core → corelib}/string/to_f_spec.rb +0 -0
  289. data/spec/{rubyspec/core → corelib}/string/to_i_spec.rb +0 -0
  290. data/spec/{rubyspec/core → corelib}/string/tr_s_spec.rb +0 -0
  291. data/spec/{rubyspec/core → corelib}/string/tr_spec.rb +0 -0
  292. data/spec/filters/bugs/array.rb +236 -4
  293. data/spec/filters/bugs/basic_object.rb +4 -0
  294. data/spec/filters/bugs/class.rb +4 -0
  295. data/spec/filters/bugs/enumerable.rb +58 -0
  296. data/spec/filters/bugs/enumerator.rb +6 -0
  297. data/spec/filters/bugs/hash.rb +146 -0
  298. data/spec/filters/bugs/kernel.rb +10 -0
  299. data/spec/filters/bugs/language.rb +366 -0
  300. data/spec/filters/bugs/module.rb +14 -0
  301. data/spec/filters/bugs/regexp.rb +7 -0
  302. data/spec/filters/bugs/set.rb +7 -0
  303. data/spec/filters/bugs/{singleton/instance.rb → singleton.rb} +3 -1
  304. data/spec/filters/bugs/string.rb +37 -0
  305. data/spec/filters/bugs/stringscanner.rb +18 -0
  306. data/spec/filters/bugs/struct.rb +11 -0
  307. data/spec/filters/bugs/symbol.rb +5 -0
  308. data/spec/filters/bugs/time.rb +28 -0
  309. data/spec/filters/bugs/unknown.rb +11 -0
  310. data/spec/filters/unsupported/array_subclasses.rb +32 -0
  311. data/spec/filters/unsupported/encoding.rb +14 -0
  312. data/spec/filters/unsupported/float.rb +4 -0
  313. data/spec/filters/unsupported/frozen.rb +57 -0
  314. data/spec/filters/unsupported/hash_compare_by_identity.rb +16 -0
  315. data/spec/filters/unsupported/immutable_strings.rb +6 -0
  316. data/spec/filters/unsupported/mutable_strings.rb +49 -0
  317. data/spec/filters/unsupported/private_methods.rb +26 -0
  318. data/spec/filters/{mspec → unsupported}/ruby_exe.rb +0 -0
  319. data/spec/filters/unsupported/string_subclasses.rb +8 -0
  320. data/spec/filters/unsupported/tainted.rb +46 -0
  321. data/spec/filters/unsupported/time.rb +21 -0
  322. data/spec/filters/unsupported/trusted.rb +26 -0
  323. data/spec/opal/{parser → compiler}/irb_spec.rb +9 -9
  324. data/spec/{parser → opal/parser}/alias_spec.rb +0 -0
  325. data/spec/{parser → opal/parser}/and_spec.rb +0 -0
  326. data/spec/{parser → opal/parser}/array_spec.rb +0 -0
  327. data/spec/{parser → opal/parser}/attrasgn_spec.rb +0 -0
  328. data/spec/{parser → opal/parser}/begin_spec.rb +0 -0
  329. data/spec/{parser → opal/parser}/block_spec.rb +0 -0
  330. data/spec/{parser → opal/parser}/break_spec.rb +0 -0
  331. data/spec/{parser → opal/parser}/call_spec.rb +33 -8
  332. data/spec/{parser → opal/parser}/class_spec.rb +0 -0
  333. data/spec/{parser → opal/parser}/const_spec.rb +0 -0
  334. data/spec/{parser → opal/parser}/cvar_spec.rb +0 -0
  335. data/spec/{parser → opal/parser}/def_spec.rb +17 -17
  336. data/spec/{parser → opal/parser}/false_spec.rb +0 -0
  337. data/spec/{parser → opal/parser}/file_spec.rb +0 -0
  338. data/spec/{parser → opal/parser}/gvar_spec.rb +0 -0
  339. data/spec/{parser → opal/parser}/hash_spec.rb +0 -0
  340. data/spec/opal/parser/heredoc_spec.rb +30 -0
  341. data/spec/{parser → opal/parser}/iasgn_spec.rb +0 -0
  342. data/spec/{parser → opal/parser}/if_spec.rb +0 -0
  343. data/spec/{parser → opal/parser}/int_spec.rb +0 -0
  344. data/spec/opal/parser/iter_spec.rb +59 -0
  345. data/spec/{parser → opal/parser}/ivar_spec.rb +0 -0
  346. data/spec/opal/parser/lambda_spec.rb +64 -0
  347. data/spec/{parser → opal/parser}/lasgn_spec.rb +0 -0
  348. data/spec/{parser → opal/parser}/line_spec.rb +0 -0
  349. data/spec/{parser → opal/parser}/lvar_spec.rb +6 -6
  350. data/spec/{parser → opal/parser}/masgn_spec.rb +0 -0
  351. data/spec/{parser → opal/parser}/module_spec.rb +0 -0
  352. data/spec/{parser → opal/parser}/nil_spec.rb +0 -0
  353. data/spec/{parser → opal/parser}/not_spec.rb +0 -0
  354. data/spec/{parser → opal/parser}/nth_ref_spec.rb +0 -0
  355. data/spec/{parser → opal/parser}/op_asgn1_spec.rb +0 -0
  356. data/spec/{parser → opal/parser}/op_asgn2_spec.rb +0 -0
  357. data/spec/{parser → opal/parser}/or_spec.rb +0 -0
  358. data/spec/{parser → opal/parser}/parse_spec.rb +17 -17
  359. data/spec/{parser → opal/parser}/regexp_spec.rb +0 -0
  360. data/spec/{parser → opal/parser}/return_spec.rb +0 -0
  361. data/spec/{parser → opal/parser}/sclass_spec.rb +0 -0
  362. data/spec/{parser → opal/parser}/self_spec.rb +0 -0
  363. data/spec/{parser → opal/parser}/str_spec.rb +1 -12
  364. data/spec/{parser → opal/parser}/string_spec.rb +0 -0
  365. data/spec/opal/parser/super_spec.rb +20 -0
  366. data/spec/{parser → opal/parser}/true_spec.rb +0 -0
  367. data/spec/{parser → opal/parser}/undef_spec.rb +0 -0
  368. data/spec/{parser → opal/parser}/unless_spec.rb +0 -0
  369. data/spec/{parser → opal/parser}/while_spec.rb +0 -0
  370. data/spec/{parser → opal/parser}/xstr_spec.rb +2 -2
  371. data/spec/{parser → opal/parser}/yield_spec.rb +0 -0
  372. data/spec/ospec/main.rb.erb +1 -13
  373. data/spec/ospec/mspec_fixes.rb +87 -0
  374. data/spec/ospec/runner.rb +188 -0
  375. data/spec/rubyspecs +351 -0
  376. data/spec/spec_helper.rb +8 -198
  377. data/spec/{opal → stdlib}/erb/erb_spec.rb +3 -3
  378. data/spec/{opal → stdlib}/erb/inline_block.opalerb +0 -0
  379. data/spec/{opal → stdlib}/erb/quoted.opalerb +0 -0
  380. data/spec/{opal → stdlib}/erb/simple.opalerb +0 -0
  381. data/spec/stdlib/json/ext_spec.rb +48 -0
  382. data/spec/{opal → stdlib}/json/parse_spec.rb +0 -0
  383. data/spec/stdlib/template/paths_spec.rb +10 -0
  384. data/stdlib/delegate.rb +29 -0
  385. data/stdlib/dir.rb +5 -0
  386. data/stdlib/file.rb +7 -0
  387. data/stdlib/json.rb +82 -27
  388. data/stdlib/opal-parser.rb +46 -0
  389. data/stdlib/opal-source-maps.js.erb +1 -1
  390. data/stdlib/pathname.rb +31 -0
  391. data/stdlib/{racc.rb → racc/parser.rb} +0 -0
  392. data/stdlib/securerandom.rb +12 -0
  393. data/stdlib/set.rb +89 -0
  394. data/stdlib/stringio.rb +12 -4
  395. data/stdlib/strscan.rb +19 -0
  396. data/stdlib/template.rb +4 -0
  397. data/stdlib/thread.rb +20 -0
  398. data/tasks/mspec.rake +147 -0
  399. metadata +650 -1266
  400. data/lib/opal/core_ext.rb +0 -5
  401. data/lib/opal/grammar.rb +0 -5137
  402. data/lib/opal/grammar_helpers.rb +0 -364
  403. data/lib/opal/require_parser.rb +0 -77
  404. data/spec/filters/bugs/alias.rb +0 -6
  405. data/spec/filters/bugs/ancestors.rb +0 -4
  406. data/spec/filters/bugs/array/combination.rb +0 -11
  407. data/spec/filters/bugs/array/count.rb +0 -3
  408. data/spec/filters/bugs/array/delete_if.rb +0 -3
  409. data/spec/filters/bugs/array/drop.rb +0 -3
  410. data/spec/filters/bugs/array/drop_while.rb +0 -5
  411. data/spec/filters/bugs/array/eql.rb +0 -3
  412. data/spec/filters/bugs/array/flatten.rb +0 -9
  413. data/spec/filters/bugs/array/minus.rb +0 -5
  414. data/spec/filters/bugs/array/multipliy.rb +0 -9
  415. data/spec/filters/bugs/array/new.rb +0 -3
  416. data/spec/filters/bugs/array/pop.rb +0 -6
  417. data/spec/filters/bugs/array/rassoc.rb +0 -4
  418. data/spec/filters/bugs/array/rindex.rb +0 -6
  419. data/spec/filters/bugs/array/select.rb +0 -3
  420. data/spec/filters/bugs/array/shift.rb +0 -7
  421. data/spec/filters/bugs/array/shuffle.rb +0 -11
  422. data/spec/filters/bugs/array/slice.rb +0 -7
  423. data/spec/filters/bugs/array/take.rb +0 -3
  424. data/spec/filters/bugs/array/to_a.rb +0 -3
  425. data/spec/filters/bugs/array/try_convert.rb +0 -7
  426. data/spec/filters/bugs/array/uniq.rb +0 -10
  427. data/spec/filters/bugs/array/zip.rb +0 -4
  428. data/spec/filters/bugs/array_delete.rb +0 -4
  429. data/spec/filters/bugs/array_fetch.rb +0 -3
  430. data/spec/filters/bugs/array_first.rb +0 -3
  431. data/spec/filters/bugs/array_flatten.rb +0 -14
  432. data/spec/filters/bugs/array_intersection.rb +0 -5
  433. data/spec/filters/bugs/array_join.rb +0 -6
  434. data/spec/filters/bugs/break.rb +0 -10
  435. data/spec/filters/bugs/case.rb +0 -4
  436. data/spec/filters/bugs/coerce_integer.rb +0 -9
  437. data/spec/filters/bugs/enumerable_sort_by.rb +0 -3
  438. data/spec/filters/bugs/kernel/instance_variables.rb +0 -3
  439. data/spec/filters/bugs/kernel/rand.rb +0 -4
  440. data/spec/filters/bugs/language/array.rb +0 -3
  441. data/spec/filters/bugs/language/block.rb +0 -6
  442. data/spec/filters/bugs/language/break.rb +0 -3
  443. data/spec/filters/bugs/language/class.rb +0 -12
  444. data/spec/filters/bugs/language/class_variables.rb +0 -12
  445. data/spec/filters/bugs/language/def.rb +0 -27
  446. data/spec/filters/bugs/language/defined.rb +0 -3
  447. data/spec/filters/bugs/language/ensure.rb +0 -4
  448. data/spec/filters/bugs/language/execution.rb +0 -4
  449. data/spec/filters/bugs/language/for.rb +0 -18
  450. data/spec/filters/bugs/language/if.rb +0 -13
  451. data/spec/filters/bugs/language/loop.rb +0 -4
  452. data/spec/filters/bugs/language/metaclass.rb +0 -14
  453. data/spec/filters/bugs/language/module.rb +0 -6
  454. data/spec/filters/bugs/language/next.rb +0 -3
  455. data/spec/filters/bugs/language/or.rb +0 -3
  456. data/spec/filters/bugs/language/order.rb +0 -4
  457. data/spec/filters/bugs/language/precedence.rb +0 -10
  458. data/spec/filters/bugs/language/proc.rb +0 -24
  459. data/spec/filters/bugs/language/redo.rb +0 -5
  460. data/spec/filters/bugs/language/rescue.rb +0 -9
  461. data/spec/filters/bugs/language/retry.rb +0 -5
  462. data/spec/filters/bugs/language/send.rb +0 -10
  463. data/spec/filters/bugs/language/super.rb +0 -9
  464. data/spec/filters/bugs/language/until.rb +0 -8
  465. data/spec/filters/bugs/language/variables.rb +0 -37
  466. data/spec/filters/bugs/language/while.rb +0 -6
  467. data/spec/filters/bugs/language/yield.rb +0 -5
  468. data/spec/filters/bugs/module/class_variables.rb +0 -6
  469. data/spec/filters/bugs/module/method_defined.rb +0 -6
  470. data/spec/filters/bugs/public_methods.rb +0 -4
  471. data/spec/filters/bugs/return.rb +0 -7
  472. data/spec/filters/bugs/source_map.rb +0 -3
  473. data/spec/filters/bugs/string/center.rb +0 -4
  474. data/spec/filters/bugs/string/lines.rb +0 -3
  475. data/spec/filters/mspec/mocks.rb +0 -3
  476. data/spec/filters/mspec/should_receive.rb +0 -5
  477. data/spec/filters/parser/block_args.rb +0 -51
  478. data/spec/mspec/guards/block_device.rb +0 -0
  479. data/spec/mspec/guards/endian.rb +0 -0
  480. data/spec/mspec/helpers/environment.rb +0 -0
  481. data/spec/mspec/helpers/language_version.rb +0 -0
  482. data/spec/mspec/helpers/tmp.rb +0 -0
  483. data/spec/opal/array/element_reference_spec.rb +0 -206
  484. data/spec/opal/array/equal_value_spec.rb +0 -19
  485. data/spec/opal/array/fill_spec.rb +0 -26
  486. data/spec/opal/array/reduce_spec.rb +0 -31
  487. data/spec/opal/array/to_json_spec.rb +0 -9
  488. data/spec/opal/basic_object/send_spec.rb +0 -28
  489. data/spec/opal/boolean/singleton_class_spec.rb +0 -9
  490. data/spec/opal/boolean/to_json_spec.rb +0 -11
  491. data/spec/opal/browser/local_storage_spec.rb +0 -55
  492. data/spec/opal/class/constants_spec.rb +0 -7
  493. data/spec/opal/class/extend_spec.rb +0 -47
  494. data/spec/opal/class/instance_methods_spec.rb +0 -13
  495. data/spec/opal/class/last_value_spec.rb +0 -67
  496. data/spec/opal/class/proc_methods_spec.rb +0 -23
  497. data/spec/opal/class/singleton_methods_spec.rb +0 -41
  498. data/spec/opal/hash/allocate_spec.rb +0 -16
  499. data/spec/opal/hash/new_spec.rb +0 -10
  500. data/spec/opal/hash/to_s_spec.rb +0 -9
  501. data/spec/opal/kernel/to_json_spec.rb +0 -7
  502. data/spec/opal/module/alias_method_spec.rb +0 -10
  503. data/spec/opal/module/attr_accessor_spec.rb +0 -8
  504. data/spec/opal/native/new_spec.rb +0 -19
  505. data/spec/opal/native/nil_spec.rb +0 -14
  506. data/spec/opal/nil/to_json_spec.rb +0 -7
  507. data/spec/opal/numeric/equal_spec.rb +0 -9
  508. data/spec/opal/runtime2/call_spec.rb +0 -16
  509. data/spec/opal/runtime2/class_hierarchy_spec.rb +0 -21
  510. data/spec/opal/runtime2/defined_spec.rb +0 -11
  511. data/spec/opal/runtime2/super_spec.rb +0 -16
  512. data/spec/opal/string/to_json_spec.rb +0 -8
  513. data/spec/parser/iter_spec.rb +0 -59
  514. data/spec/parser/lambda_spec.rb +0 -64
  515. data/spec/parser/parser_spec.rb +0 -41
  516. data/spec/parser/strscan/check_spec.rb +0 -13
  517. data/spec/parser/strscan/get_byte_spec.rb +0 -29
  518. data/spec/parser/strscan/scan_spec.rb +0 -33
  519. data/spec/parser/strscan/skip_spec.rb +0 -40
  520. data/spec/parser/super_spec.rb +0 -20
  521. data/spec/rubyspec/core/array/allocate_spec.rb +0 -19
  522. data/spec/rubyspec/core/array/append_spec.rb +0 -43
  523. data/spec/rubyspec/core/array/array_spec.rb +0 -7
  524. data/spec/rubyspec/core/array/assoc_spec.rb +0 -40
  525. data/spec/rubyspec/core/array/at_spec.rb +0 -56
  526. data/spec/rubyspec/core/array/choice_spec.rb +0 -20
  527. data/spec/rubyspec/core/array/clear_spec.rb +0 -61
  528. data/spec/rubyspec/core/array/clone_spec.rb +0 -15
  529. data/spec/rubyspec/core/array/collect_spec.rb +0 -53
  530. data/spec/rubyspec/core/array/combination_spec.rb +0 -55
  531. data/spec/rubyspec/core/array/compact_spec.rb +0 -111
  532. data/spec/rubyspec/core/array/comparison_spec.rb +0 -16
  533. data/spec/rubyspec/core/array/concat_spec.rb +0 -19
  534. data/spec/rubyspec/core/array/constructor_spec.rb +0 -24
  535. data/spec/rubyspec/core/array/count_spec.rb +0 -17
  536. data/spec/rubyspec/core/array/delete_at_spec.rb +0 -71
  537. data/spec/rubyspec/core/array/delete_if_spec.rb +0 -71
  538. data/spec/rubyspec/core/array/delete_spec.rb +0 -104
  539. data/spec/rubyspec/core/array/drop_spec.rb +0 -29
  540. data/spec/rubyspec/core/array/drop_while_spec.rb +0 -17
  541. data/spec/rubyspec/core/array/dup_spec.rb +0 -15
  542. data/spec/rubyspec/core/array/each_index_spec.rb +0 -40
  543. data/spec/rubyspec/core/array/each_spec.rb +0 -30
  544. data/spec/rubyspec/core/array/empty_spec.rb +0 -10
  545. data/spec/rubyspec/core/array/eql_spec.rb +0 -14
  546. data/spec/rubyspec/core/array/fetch_spec.rb +0 -52
  547. data/spec/rubyspec/core/array/find_index_spec.rb +0 -8
  548. data/spec/rubyspec/core/array/first_spec.rb +0 -89
  549. data/spec/rubyspec/core/array/fixtures/classes.rb +0 -538
  550. data/spec/rubyspec/core/array/flatten_spec.rb +0 -232
  551. data/spec/rubyspec/core/array/frozen_spec.rb +0 -32
  552. data/spec/rubyspec/core/array/include_spec.rb +0 -33
  553. data/spec/rubyspec/core/array/index_spec.rb +0 -6
  554. data/spec/rubyspec/core/array/insert_spec.rb +0 -90
  555. data/spec/rubyspec/core/array/inspect_spec.rb +0 -7
  556. data/spec/rubyspec/core/array/intersection_spec.rb +0 -78
  557. data/spec/rubyspec/core/array/join_spec.rb +0 -34
  558. data/spec/rubyspec/core/array/keep_if_spec.rb +0 -12
  559. data/spec/rubyspec/core/array/last_spec.rb +0 -88
  560. data/spec/rubyspec/core/array/length_spec.rb +0 -7
  561. data/spec/rubyspec/core/array/map_spec.rb +0 -11
  562. data/spec/rubyspec/core/array/max_spec.rb +0 -32
  563. data/spec/rubyspec/core/array/min_spec.rb +0 -32
  564. data/spec/rubyspec/core/array/minus_spec.rb +0 -89
  565. data/spec/rubyspec/core/array/multiply_spec.rb +0 -143
  566. data/spec/rubyspec/core/array/new_spec.rb +0 -137
  567. data/spec/rubyspec/core/array/ntimes_spec.rb +0 -26
  568. data/spec/rubyspec/core/array/plus_spec.rb +0 -64
  569. data/spec/rubyspec/core/array/pop_spec.rb +0 -196
  570. data/spec/rubyspec/core/array/push_spec.rb +0 -44
  571. data/spec/rubyspec/core/array/rassoc_spec.rb +0 -38
  572. data/spec/rubyspec/core/array/reject_spec.rb +0 -134
  573. data/spec/rubyspec/core/array/replace_spec.rb +0 -7
  574. data/spec/rubyspec/core/array/reverse_each_spec.rb +0 -37
  575. data/spec/rubyspec/core/array/reverse_spec.rb +0 -58
  576. data/spec/rubyspec/core/array/rindex_spec.rb +0 -71
  577. data/spec/rubyspec/core/array/select_spec.rb +0 -36
  578. data/spec/rubyspec/core/array/shared/collect.rb +0 -7
  579. data/spec/rubyspec/core/array/shared/enumeratorize.rb +0 -12
  580. data/spec/rubyspec/core/array/shared/eql.rb +0 -95
  581. data/spec/rubyspec/core/array/shared/index.rb +0 -37
  582. data/spec/rubyspec/core/array/shared/inspect.rb +0 -3
  583. data/spec/rubyspec/core/array/shared/join.rb +0 -7
  584. data/spec/rubyspec/core/array/shared/keep_if.rb +0 -3
  585. data/spec/rubyspec/core/array/shared/length.rb +0 -3
  586. data/spec/rubyspec/core/array/shared/replace.rb +0 -3
  587. data/spec/rubyspec/core/array/shared/slice.rb +0 -3
  588. data/spec/rubyspec/core/array/shift_spec.rb +0 -160
  589. data/spec/rubyspec/core/array/shuffle_spec.rb +0 -87
  590. data/spec/rubyspec/core/array/size_spec.rb +0 -7
  591. data/spec/rubyspec/core/array/slice_spec.rb +0 -166
  592. data/spec/rubyspec/core/array/sort_spec.rb +0 -271
  593. data/spec/rubyspec/core/array/take_spec.rb +0 -29
  594. data/spec/rubyspec/core/array/take_while_spec.rb +0 -17
  595. data/spec/rubyspec/core/array/to_a_spec.rb +0 -24
  596. data/spec/rubyspec/core/array/to_ary_spec.rb +0 -20
  597. data/spec/rubyspec/core/array/try_convert_spec.rb +0 -52
  598. data/spec/rubyspec/core/array/uniq_spec.rb +0 -167
  599. data/spec/rubyspec/core/array/unshift_spec.rb +0 -64
  600. data/spec/rubyspec/core/array/zip_spec.rb +0 -55
  601. data/spec/rubyspec/core/class/fixtures/classes.rb +0 -9
  602. data/spec/rubyspec/core/class/new_spec.rb +0 -113
  603. data/spec/rubyspec/core/enumerable/all_spec.rb +0 -130
  604. data/spec/rubyspec/core/enumerable/any_spec.rb +0 -150
  605. data/spec/rubyspec/core/enumerable/collect_spec.rb +0 -39
  606. data/spec/rubyspec/core/enumerable/count_spec.rb +0 -45
  607. data/spec/rubyspec/core/enumerable/detect_spec.rb +0 -48
  608. data/spec/rubyspec/core/enumerable/drop_spec.rb +0 -20
  609. data/spec/rubyspec/core/enumerable/drop_while_spec.rb +0 -18
  610. data/spec/rubyspec/core/enumerable/each_slice_spec.rb +0 -25
  611. data/spec/rubyspec/core/enumerable/each_with_index_spec.rb +0 -14
  612. data/spec/rubyspec/core/enumerable/each_with_object_spec.rb +0 -20
  613. data/spec/rubyspec/core/enumerable/entries_spec.rb +0 -9
  614. data/spec/rubyspec/core/enumerable/find_all_spec.rb +0 -16
  615. data/spec/rubyspec/core/enumerable/find_index_spec.rb +0 -44
  616. data/spec/rubyspec/core/enumerable/find_spec.rb +0 -56
  617. data/spec/rubyspec/core/enumerable/first_spec.rb +0 -43
  618. data/spec/rubyspec/core/enumerable/fixtures/classes.rb +0 -240
  619. data/spec/rubyspec/core/enumerable/grep_spec.rb +0 -24
  620. data/spec/rubyspec/core/enumerable/group_by_spec.rb +0 -16
  621. data/spec/rubyspec/core/enumerable/none_spec.rb +0 -68
  622. data/spec/rubyspec/core/enumerable/select_spec.rb +0 -16
  623. data/spec/rubyspec/core/enumerable/sort_by_spec.rb +0 -31
  624. data/spec/rubyspec/core/enumerable/take_spec.rb +0 -43
  625. data/spec/rubyspec/core/enumerable/to_a_spec.rb +0 -9
  626. data/spec/rubyspec/core/enumerator/each_spec.rb +0 -11
  627. data/spec/rubyspec/core/enumerator/new_spec.rb +0 -17
  628. data/spec/rubyspec/core/enumerator/next_spec.rb +0 -25
  629. data/spec/rubyspec/core/enumerator/rewind_spec.rb +0 -28
  630. data/spec/rubyspec/core/false/and_spec.rb +0 -11
  631. data/spec/rubyspec/core/false/inspect_spec.rb +0 -7
  632. data/spec/rubyspec/core/false/or_spec.rb +0 -11
  633. data/spec/rubyspec/core/false/to_s_spec.rb +0 -7
  634. data/spec/rubyspec/core/false/xor_spec.rb +0 -11
  635. data/spec/rubyspec/core/hash/allocate_spec.rb +0 -13
  636. data/spec/rubyspec/core/hash/assoc_spec.rb +0 -25
  637. data/spec/rubyspec/core/hash/clear_spec.rb +0 -19
  638. data/spec/rubyspec/core/hash/clone_spec.rb +0 -10
  639. data/spec/rubyspec/core/hash/constructor_spec.rb +0 -13
  640. data/spec/rubyspec/core/hash/default_proc_spec.rb +0 -20
  641. data/spec/rubyspec/core/hash/default_spec.rb +0 -17
  642. data/spec/rubyspec/core/hash/delete_if_spec.rb +0 -13
  643. data/spec/rubyspec/core/hash/delete_spec.rb +0 -11
  644. data/spec/rubyspec/core/hash/dup_spec.rb +0 -10
  645. data/spec/rubyspec/core/hash/each_key_spec.rb +0 -15
  646. data/spec/rubyspec/core/hash/each_pair_spec.rb +0 -30
  647. data/spec/rubyspec/core/hash/each_spec.rb +0 -36
  648. data/spec/rubyspec/core/hash/each_value_spec.rb +0 -15
  649. data/spec/rubyspec/core/hash/element_reference_spec.rb +0 -41
  650. data/spec/rubyspec/core/hash/element_set_spec.rb +0 -7
  651. data/spec/rubyspec/core/hash/empty_spec.rb +0 -10
  652. data/spec/rubyspec/core/hash/fetch_spec.rb +0 -24
  653. data/spec/rubyspec/core/hash/flatten_spec.rb +0 -46
  654. data/spec/rubyspec/core/hash/has_key_spec.rb +0 -24
  655. data/spec/rubyspec/core/hash/has_value_spec.rb +0 -12
  656. data/spec/rubyspec/core/hash/include_spec.rb +0 -24
  657. data/spec/rubyspec/core/hash/index_spec.rb +0 -13
  658. data/spec/rubyspec/core/hash/indexes_spec.rb +0 -9
  659. data/spec/rubyspec/core/hash/indices_spec.rb +0 -9
  660. data/spec/rubyspec/core/hash/invert_spec.rb +0 -12
  661. data/spec/rubyspec/core/hash/keep_if_spec.rb +0 -18
  662. data/spec/rubyspec/core/hash/key_spec.rb +0 -24
  663. data/spec/rubyspec/core/hash/keys_spec.rb +0 -10
  664. data/spec/rubyspec/core/hash/length_spec.rb +0 -10
  665. data/spec/rubyspec/core/hash/member_spec.rb +0 -24
  666. data/spec/rubyspec/core/hash/merge_spec.rb +0 -37
  667. data/spec/rubyspec/core/hash/new_spec.rb +0 -19
  668. data/spec/rubyspec/core/hash/rassoc_spec.rb +0 -34
  669. data/spec/rubyspec/core/hash/reject_spec.rb +0 -18
  670. data/spec/rubyspec/core/hash/replace_spec.rb +0 -7
  671. data/spec/rubyspec/core/hash/select_spec.rb +0 -52
  672. data/spec/rubyspec/core/hash/shift_spec.rb +0 -19
  673. data/spec/rubyspec/core/hash/size_spec.rb +0 -10
  674. data/spec/rubyspec/core/hash/to_a_spec.rb +0 -13
  675. data/spec/rubyspec/core/hash/to_json_spec.rb +0 -11
  676. data/spec/rubyspec/core/hash/update_spec.rb +0 -17
  677. data/spec/rubyspec/core/hash/value_spec.rb +0 -12
  678. data/spec/rubyspec/core/hash/values_at_spec.rb +0 -9
  679. data/spec/rubyspec/core/hash/values_spec.rb +0 -7
  680. data/spec/rubyspec/core/kernel/eql_spec.rb +0 -15
  681. data/spec/rubyspec/core/kernel/equal_spec.rb +0 -12
  682. data/spec/rubyspec/core/kernel/tap_spec.rb +0 -10
  683. data/spec/rubyspec/core/kernel/to_s_spec.rb +0 -5
  684. data/spec/rubyspec/core/matchdata/to_a_spec.rb +0 -5
  685. data/spec/rubyspec/core/nil/and_spec.rb +0 -11
  686. data/spec/rubyspec/core/nil/dup_spec.rb +0 -7
  687. data/spec/rubyspec/core/nil/inspect_spec.rb +0 -7
  688. data/spec/rubyspec/core/nil/nil_spec.rb +0 -7
  689. data/spec/rubyspec/core/nil/or_spec.rb +0 -11
  690. data/spec/rubyspec/core/nil/to_a_spec.rb +0 -7
  691. data/spec/rubyspec/core/nil/to_f_spec.rb +0 -11
  692. data/spec/rubyspec/core/nil/to_h_spec.rb +0 -10
  693. data/spec/rubyspec/core/nil/to_i_spec.rb +0 -11
  694. data/spec/rubyspec/core/nil/to_s_spec.rb +0 -7
  695. data/spec/rubyspec/core/nil/xor_spec.rb +0 -11
  696. data/spec/rubyspec/core/numeric/to_s_spec.rb +0 -8
  697. data/spec/rubyspec/core/range/begin_spec.rb +0 -9
  698. data/spec/rubyspec/core/range/case_compare_spec.rb +0 -15
  699. data/spec/rubyspec/core/range/end_spec.rb +0 -9
  700. data/spec/rubyspec/core/regexp/match_spec.rb +0 -95
  701. data/spec/rubyspec/core/string/capitalize_spec.rb +0 -10
  702. data/spec/rubyspec/core/string/casecmp_spec.rb +0 -16
  703. data/spec/rubyspec/core/string/center_spec.rb +0 -49
  704. data/spec/rubyspec/core/string/chomp_spec.rb +0 -48
  705. data/spec/rubyspec/core/string/downcase_spec.rb +0 -6
  706. data/spec/rubyspec/core/string/empty_spec.rb +0 -7
  707. data/spec/rubyspec/core/string/end_with_spec.rb +0 -16
  708. data/spec/rubyspec/core/string/include_spec.rb +0 -6
  709. data/spec/rubyspec/core/string/index_spec.rb +0 -405
  710. data/spec/rubyspec/core/string/intern_spec.rb +0 -9
  711. data/spec/rubyspec/core/string/length_spec.rb +0 -9
  712. data/spec/rubyspec/core/string/reverse_spec.rb +0 -7
  713. data/spec/rubyspec/core/string/size_spec.rb +0 -9
  714. data/spec/rubyspec/core/string/start_with_spec.rb +0 -12
  715. data/spec/rubyspec/core/string/swapcase_spec.rb +0 -13
  716. data/spec/rubyspec/core/string/to_a_spec.rb +0 -9
  717. data/spec/rubyspec/core/string/to_s_spec.rb +0 -6
  718. data/spec/rubyspec/core/string/to_str_spec.rb +0 -6
  719. data/spec/rubyspec/core/string/to_sym_spec.rb +0 -9
  720. data/spec/rubyspec/core/string/upcase_spec.rb +0 -6
  721. data/spec/rubyspec/core/struct/fixtures/classes.rb +0 -26
  722. data/spec/rubyspec/core/struct/initialize_spec.rb +0 -11
  723. data/spec/rubyspec/core/struct/new_spec.rb +0 -24
  724. data/spec/rubyspec/core/symbol/to_proc_spec.rb +0 -12
  725. data/spec/rubyspec/core/time/at_spec.rb +0 -7
  726. data/spec/rubyspec/core/time/day_spec.rb +0 -5
  727. data/spec/rubyspec/core/time/friday_spec.rb +0 -9
  728. data/spec/rubyspec/core/time/hour_spec.rb +0 -5
  729. data/spec/rubyspec/core/time/min_spec.rb +0 -5
  730. data/spec/rubyspec/core/time/monday_spec.rb +0 -9
  731. data/spec/rubyspec/core/time/month_spec.rb +0 -5
  732. data/spec/rubyspec/core/time/now_spec.rb +0 -5
  733. data/spec/rubyspec/core/time/saturday_spec.rb +0 -9
  734. data/spec/rubyspec/core/true/and_spec.rb +0 -11
  735. data/spec/rubyspec/core/true/inspect_spec.rb +0 -7
  736. data/spec/rubyspec/core/true/or_spec.rb +0 -11
  737. data/spec/rubyspec/core/true/to_s_spec.rb +0 -7
  738. data/spec/rubyspec/core/true/xor_spec.rb +0 -11
  739. data/spec/rubyspec/language/alias_spec.rb +0 -160
  740. data/spec/rubyspec/language/and_spec.rb +0 -66
  741. data/spec/rubyspec/language/array_spec.rb +0 -117
  742. data/spec/rubyspec/language/break_spec.rb +0 -332
  743. data/spec/rubyspec/language/case_spec.rb +0 -310
  744. data/spec/rubyspec/language/class_spec.rb +0 -190
  745. data/spec/rubyspec/language/class_variable_spec.rb +0 -56
  746. data/spec/rubyspec/language/def_spec.rb +0 -551
  747. data/spec/rubyspec/language/defined_spec.rb +0 -107
  748. data/spec/rubyspec/language/ensure_spec.rb +0 -104
  749. data/spec/rubyspec/language/execution_spec.rb +0 -15
  750. data/spec/rubyspec/language/for_spec.rb +0 -192
  751. data/spec/rubyspec/language/hash_spec.rb +0 -65
  752. data/spec/rubyspec/language/if_spec.rb +0 -356
  753. data/spec/rubyspec/language/literal_lambda_spec.rb +0 -1
  754. data/spec/rubyspec/language/loop_spec.rb +0 -67
  755. data/spec/rubyspec/language/metaclass_spec.rb +0 -159
  756. data/spec/rubyspec/language/module_spec.rb +0 -56
  757. data/spec/rubyspec/language/next_spec.rb +0 -469
  758. data/spec/rubyspec/language/not_spec.rb +0 -55
  759. data/spec/rubyspec/language/or_spec.rb +0 -90
  760. data/spec/rubyspec/language/order_spec.rb +0 -77
  761. data/spec/rubyspec/language/precedence_spec.rb +0 -483
  762. data/spec/rubyspec/language/redo_spec.rb +0 -65
  763. data/spec/rubyspec/language/rescue_spec.rb +0 -121
  764. data/spec/rubyspec/language/retry_spec.rb +0 -56
  765. data/spec/rubyspec/language/return_spec.rb +0 -281
  766. data/spec/rubyspec/language/singleton_class_spec.rb +0 -32
  767. data/spec/rubyspec/language/super_spec.rb +0 -284
  768. data/spec/rubyspec/language/undef_spec.rb +0 -16
  769. data/spec/rubyspec/language/unless_spec.rb +0 -45
  770. data/spec/rubyspec/language/until_spec.rb +0 -234
  771. data/spec/rubyspec/language/while_spec.rb +0 -238
  772. data/spec/rubyspec/language/yield_spec.rb +0 -128
  773. data/spec/rubyspec/library/date/new_spec.rb +0 -10
  774. data/spec/rubyspec/library/date/to_s_spec.rb +0 -7
  775. data/spec/rubyspec/library/date/today_spec.rb +0 -7
  776. data/spec/rubyspec/library/erb/util/html_escape_spec.rb +0 -10
  777. data/spec/rubyspec/library/observer/add_observer_spec.rb +0 -31
  778. data/spec/rubyspec/library/observer/count_observers_spec.rb +0 -33
  779. data/spec/rubyspec/library/observer/delete_observer_spec.rb +0 -19
  780. data/spec/rubyspec/library/observer/delete_observers_spec.rb +0 -19
  781. data/spec/rubyspec/library/observer/fixtures/classes.rb +0 -25
  782. data/spec/rubyspec/library/observer/notify_observers_spec.rb +0 -31
  783. data/spec/rubyspec/library/rbconfig/config_spec.rb +0 -47
  784. data/spec/rubyspec/library/singleton/clone_spec.rb +0 -8
  785. data/spec/rubyspec/library/singleton/dup_spec.rb +0 -8
  786. data/spec/rubyspec/library/singleton/fixtures/classes.rb +0 -18
  787. data/spec/rubyspec/library/singleton/instance_spec.rb +0 -30
  788. data/spec/rubyspec/library/stringscanner/element_reference_spec.rb +0 -29
  789. data/spec/rubyspec/library/stringscanner/pos_spec.rb +0 -20
  790. data/spec/rubyspec/spec_helper.rb +0 -96
  791. data/stdlib/fileutils.rb +0 -0
  792. data/stdlib/iconv.rb +0 -0
  793. data/stdlib/opal-browser/local_storage.rb +0 -27
  794. data/stdlib/opal-browser/script_loader.rb +0 -35
  795. data/stdlib/opal-parser.js.erb +0 -13
  796. data/stdlib/yaml.rb +0 -0
@@ -1,7 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "NilClass#nil?" do
4
- it "returns true" do
5
- nil.nil?.should == true
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "NilClass#|" do
4
- it "returns false if other is nil or false, otherwise true" do
5
- (nil | nil).should == false
6
- (nil | true).should == true
7
- (nil | false).should == false
8
- (nil | "").should == true
9
- (nil | mock('x')).should == true
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "NilClass#to_a" do
4
- it "returns an empty array" do
5
- nil.to_a.should == []
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "NilClass#to_f" do
4
- it "returns 0.0" do
5
- nil.to_f.should == 0.0
6
- end
7
-
8
- it "does not cause NilClass to be coerced to Float" do
9
- (0.0 == nil).should == false
10
- end
11
- end
@@ -1,10 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- ruby_version_is "2.0" do
4
- describe "NilClass#to_h" do
5
- it "returns an empty hash" do
6
- nil.to_h.should == {}
7
- nil.to_h.default.should == nil
8
- end
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "NilClass#to_i" do
4
- it "returns 0" do
5
- nil.to_i.should == 0
6
- end
7
-
8
- it "does not cause NilClass to be coerced to Fixnum" do
9
- (0 == nil).should == false
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "NilClass#to_s" do
4
- it "returns the string ''" do
5
- nil.to_s.should == ""
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
-
3
- describe "NilClass#^" do
4
- it "returns false if other is nil or false, otherwise true" do
5
- (nil ^ nil).should == false
6
- (nil ^ true).should == true
7
- (nil ^ false).should == false
8
- (nil ^ "").should == true
9
- (nil ^ mock('x')).should == true
10
- end
11
- end
@@ -1,8 +0,0 @@
1
- describe "Numeric#to_s when no base given" do
2
- it "returns self converted to a String using base 10" do
3
- 255.to_s.should == '255'
4
- 3.to_s.should == '3'
5
- 0.to_s.should == '0'
6
- (-9002).to_s.should == '-9002'
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- describe "Range#begin" do
2
- it "returns the first element of self" do
3
- (-1..1).begin.should == -1
4
- (0..1).begin.should == 0
5
- ('Q'..'T').begin.should == 'Q'
6
- ('Q'...'T').begin.should == 'Q'
7
- (0.5..2.4).begin.should == 0.5
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- describe "Range#===" do
2
- it "returns true if other is an element of self" do
3
- ((0..5) === 2).should == true
4
- ((-5..5) === 0).should == true
5
- ((-1...1) === 10.5).should == false
6
- ((-10..-2) === -2.5).should == true
7
- (('C'..'X') === 'M').should == true
8
- (('C'..'X') === 'A').should == false
9
- (('B'...'W') === 'W').should == false
10
- (('B'...'W') === 'Q').should == true
11
- ((0.5..2.4) === 2).should == true
12
- ((0.5..2.4) === 2.5).should == false
13
- ((0.5...2.4) === 2.4).should == false
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- describe "Range#end" do
2
- it "end returns the last element of self" do
3
- (-1..1).end.should == 1
4
- (0..1).end.should == 1
5
- ("A".."Q").end.should == "Q"
6
- ("A"..."Q").end.should == "Q"
7
- (0.5..2.4).end.should == 2.4
8
- end
9
- end
@@ -1,95 +0,0 @@
1
- describe "Regexp#=~ on a successful match" do
2
- it "returns the index of the first character of the matching region" do
3
- (/(.)(.)(.)/ =~ "abc").should == 0
4
- end
5
- end
6
-
7
- describe "Regexp#match on a successful match" do
8
- it "returns a MatchData object" do
9
- /(.)(.)(.)/.match("abc").should be_kind_of(MatchData)
10
- end
11
-
12
- it "resets $~ if passed nil" do
13
- # set $~
14
- /./.match("a")
15
- $~.should be_kind_of(MatchData)
16
-
17
- /1/.match(nil)
18
- $~.should be_nil
19
- end
20
-
21
- it "returns a MatchData object that exposes pre_match and post_match strings for inline regexp" do
22
- re = /note: /i
23
- result = re.match('preamble NOTE: This is just a test.')
24
- result.pre_match.should == 'preamble '
25
- result.post_match.should == 'This is just a test.'
26
- end
27
-
28
- it "returns a MatchData object that exposes pre_match and post_match strings for constructed regexp" do
29
- re = Regexp.new(/note: /i)
30
- result = re.match('preamble NOTE: This is just a test.')
31
- result.pre_match.should == 'preamble '
32
- result.post_match.should == 'This is just a test.'
33
- end
34
-
35
- it "sets $` and $' variables on match" do
36
- re = /note: /i
37
- re.match('preamble NOTE: This is just a test.')
38
- $`.should == 'preamble '
39
- $'.should == 'This is just a test.'
40
- end
41
-
42
- it "resets $` and $' when no match" do
43
- re = /note: /i
44
- re.match('preamble NOTE: This is just a test.')
45
- $`.should_not be_nil
46
- $'.should_not be_nil
47
- re.match(nil)
48
- $`.should be_nil
49
- $'.should be_nil
50
- end
51
-
52
- it "returns a MatchData object that exposes match array" do
53
- re = /(note): (.*)/i
54
- result = re.match('preamble NOTE: This is just a test.')
55
- result.length.should == 3
56
- result.size.should == 3
57
- result.captures.should == ['NOTE', 'This is just a test.']
58
- result.to_a.should == ['NOTE: This is just a test.', 'NOTE', 'This is just a test.']
59
- result[1].should == ['NOTE']
60
- result.values_at(1, -1).should == ['NOTE', 'This is just a test.']
61
- result.values_at(-3, 0).should == [nil, 'NOTE: This is just a test.']
62
- end
63
-
64
- it "replaces undefined with nil in match array" do
65
- re = /(a(b)c)?(def)/
66
- result = re.match("def")
67
- result.to_a.size.should == 4
68
- result.to_a.should == ["def", nil, nil, "def"]
69
- end
70
-
71
- it "returns a MatchData object that exposes regexp and string" do
72
- re = /(note): (.*)/i
73
- result = re.match('preamble NOTE: This is just a test.')
74
- result.string.should == 'preamble NOTE: This is just a test.'
75
- result.regexp.to_s.should == re.to_s
76
- end
77
-
78
- it "returns a MatchData object that provides access to offset of 0th element only" do
79
- re = /(note): (.*)/i
80
- result = re.match('preamble NOTE: This is just a test.')
81
- result.begin(0).should == 9
82
- result.begin(1).should == 9
83
- lambda { result.begin(2) }.should raise_error(ArgumentError)
84
- end
85
- end
86
-
87
- describe :regexp_match do
88
- it "returns nil if there is no match" do
89
- /xyz/.match("abxyc").should be_nil
90
- end
91
-
92
- it "returns nil if the object is nil" do
93
- /xyz/.match(nil).should be_nil
94
- end
95
- end
@@ -1,10 +0,0 @@
1
- describe "String#capitalize" do
2
- it "returns a copy of self with the first character converted to uppercase and the remainder to lowercase" do
3
- "".capitalize.should == ""
4
- "h".capitalize.should == "H"
5
- "H".capitalize.should == "H"
6
- "hello".capitalize.should == "Hello"
7
- "HELLO".capitalize.should == "Hello"
8
- "123ABC".capitalize.should == "123abc"
9
- end
10
- end
@@ -1,16 +0,0 @@
1
- describe "String#casecmp" do
2
- it "returns -1 when less than other" do
3
- "a".casecmp("b").should == -1
4
- "A".casecmp("b").should == -1
5
- end
6
-
7
- it "returns 0 when equal to other" do
8
- "a".casecmp("a").should == 0
9
- "A".casecmp("a").should == 0
10
- end
11
-
12
- it "returns 1 when greater than other" do
13
- "b".casecmp("a").should == 1
14
- "B".casecmp("a").should == 1
15
- end
16
- end
@@ -1,49 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../../../spec_helper', __FILE__)
3
- require File.expand_path('../fixtures/classes.rb', __FILE__)
4
-
5
- describe "String#center with length, padding" do
6
- it "returns a new string of specified length with self centered and padded with padstr" do
7
- "one".center(9, '.').should == "...one..."
8
- "hello".center(20, '123').should == "1231231hello12312312"
9
- "middle".center(13, '-').should == "---middle----"
10
-
11
- "".center(1, "abcd").should == "a"
12
- "".center(2, "abcd").should == "aa"
13
- "".center(3, "abcd").should == "aab"
14
- "".center(4, "abcd").should == "abab"
15
- "".center(6, "xy").should == "xyxxyx"
16
- "".center(11, "12345").should == "12345123451"
17
-
18
- "|".center(2, "abcd").should == "|a"
19
- "|".center(3, "abcd").should == "a|a"
20
- "|".center(4, "abcd").should == "a|ab"
21
- "|".center(5, "abcd").should == "ab|ab"
22
- "|".center(6, "xy").should == "xy|xyx"
23
- "|".center(7, "xy").should == "xyx|xyx"
24
- "|".center(11, "12345").should == "12345|12345"
25
- "|".center(12, "12345").should == "12345|123451"
26
-
27
- "||".center(3, "abcd").should == "||a"
28
- "||".center(4, "abcd").should == "a||a"
29
- "||".center(5, "abcd").should == "a||ab"
30
- "||".center(6, "abcd").should == "ab||ab"
31
- "||".center(8, "xy").should == "xyx||xyx"
32
- "||".center(12, "12345").should == "12345||12345"
33
- "||".center(13, "12345").should == "12345||123451"
34
- end
35
-
36
- it "pads with whitespace if no padstr is given" do
37
- "two".center(5).should == " two "
38
- "hello".center(20).should == " hello "
39
- end
40
-
41
- it "returns self if it's longer than or as long as the specified length" do
42
- "".center(0).should == ""
43
- "".center(-1).should == ""
44
- "hello".center(4).should == "hello"
45
- "hello".center(-1).should == "hello"
46
- "this".center(3).should == "this"
47
- "radiology".center(8, '-').should == "radiology"
48
- end
49
- end
@@ -1,48 +0,0 @@
1
- describe "String#chomp with separator" do
2
- it "returns a new string with the given record separator removed" do
3
- "hello".chomp("llo").should == "he"
4
- "hellollo".chomp("llo").should == "hello"
5
- end
6
-
7
- it "removes carriage return (except \\r) chars multiple times when separator is an empty string" do
8
- "".chomp("").should == ""
9
- "hello".chomp("").should == "hello"
10
- "hello\n".chomp("").should == "hello"
11
- "hello\nx".chomp("").should == "hello\nx"
12
- "hello\r\n".chomp("").should == "hello"
13
- "hello\r\n\r\n\n\n\r\n".chomp("").should == "hello"
14
-
15
- "hello\r".chomp("").should == "hello\r"
16
- "hello\n\r".chomp("").should == "hello\n\r"
17
- "hello\r\r\r\n".chomp("").should == "hello\r\r"
18
- end
19
-
20
- it "removes carriage return chars(\\n, \\r, \\r\\n) when separator is \\n" do
21
- "hello".chomp("\n").should == "hello"
22
- "hello\n".chomp("\n").should == "hello"
23
- "hello\r\n".chomp("\n").should == "hello"
24
- "hello\n\r".chomp("\n").should == "hello\n"
25
- "hello\r".chomp("\n").should == "hello"
26
- "hello \n there".chomp("\n").should == "hello \n there"
27
- "hello\r\n\r\n\n\n\r\n".chomp("\n").should == "hello\r\n\r\n\n\n"
28
-
29
- "hello\n\r".chomp("\r").should == "hello\n"
30
- "hello\n\r\n".chomp("\r\n").should == "hello\n"
31
- end
32
-
33
- it "removes separator character" do
34
- "hello)".chomp(")").should == "hello"
35
- "hello*)".chomp("*)").should == "hello"
36
- end
37
-
38
- it "returns self if the separator is nil" do
39
- "hello\n\n".chomp(nil).should == "hello\n\n"
40
- end
41
-
42
- it "returns an empty string when called on an empty string" do
43
- "".chomp("\n").should == ""
44
- "".chomp("\r").should == ""
45
- "".chomp("").should == ""
46
- "".chomp(nil).should == ""
47
- end
48
- end
@@ -1,6 +0,0 @@
1
- describe "String#downcase" do
2
- it "returns a copy of self with all uppercase letters downcased" do
3
- "hELLO".downcase.should == "hello"
4
- "hello".downcase.should == "hello"
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- describe "String#empty?" do
2
- it "returns true if the string has a length of zero" do
3
- "hello".empty?.should == false
4
- " ".empty?.should == false
5
- "".empty?.should == true
6
- end
7
- end
@@ -1,16 +0,0 @@
1
- describe "String#end_with?" do
2
- it "returns true only if ends with match" do
3
- s = "hello"
4
- s.end_with?('o').should be_true
5
- s.end_with?('llo').should be_true
6
- s.end_with?('ll').should be_false
7
- end
8
-
9
- it "returns true only if any ending match" do
10
- "hello".end_with?('x', 'y', 'llo', 'z').should be_true
11
- end
12
-
13
- it "should not return true if suffix length is 1 greater than string length" do
14
- "-".end_with?(' +').should be_false
15
- end
16
- end
@@ -1,6 +0,0 @@
1
- describe "String#include?" do
2
- it "returns true if self contains other_str" do
3
- "hello".include?("lo").should == true
4
- "hello".include?("ol").should == false
5
- end
6
- end
@@ -1,405 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../../../spec_helper', __FILE__)
3
- require File.expand_path('../fixtures/classes.rb', __FILE__)
4
-
5
- describe "String#index" do
6
- it "raises a TypeError if passed nil" do
7
- lambda { "abc".index nil }.should raise_error(TypeError)
8
- end
9
-
10
- it "raises a TypeError if passed a boolean" do
11
- lambda { "abc".index true }.should raise_error(TypeError)
12
- end
13
-
14
- not_compliant_on :opal do
15
- it "raises a TypeError if passed a Symbol" do
16
- lambda { "abc".index :a }.should raise_error(TypeError)
17
- end
18
-
19
- it "calls #to_str to convert the first argument" do
20
- char = mock("string index char")
21
- char.should_receive(:to_str).and_return("b")
22
- "abc".index(char).should == 1
23
- end
24
-
25
- it "calls #to_int to convert the second argument" do
26
- offset = mock("string index offset")
27
- offset.should_receive(:to_int).and_return(1)
28
- "abc".index("c", offset).should == 2
29
- end
30
- end
31
-
32
- ruby_version_is ""..."1.9" do
33
- it "does not call #to_int to convert the first argument" do
34
- char = mock("string index char")
35
- char.should_not_receive(:to_int)
36
- lambda { "abc".index char }.should raise_error(TypeError)
37
- end
38
- end
39
-
40
- ruby_version_is "1.9" do
41
- it "raises a TypeError if passed a Fixnum" do
42
- lambda { "abc".index 97 }.should raise_error(TypeError)
43
- end
44
- end
45
- end
46
-
47
- ruby_version_is ""..."1.9" do
48
- describe "String#index with Fixnum" do
49
- it "returns the index of the first occurrence of the given character" do
50
- "hello".index(?e).should == 1
51
- "hello".index(?l).should == 2
52
- end
53
-
54
- it "character values over 255 (256th ASCII character) always result in nil" do
55
- # A naive implementation could try to use % 256
56
- "hello".index(?e + 256 * 3).should == nil
57
- end
58
-
59
- it "negative character values always result in nil" do
60
- # A naive implementation could try to use % 256
61
- "hello".index(-(256 - ?e)).should == nil
62
- end
63
-
64
- it "starts the search at the given offset" do
65
- "blablabla".index(?b, 0).should == 0
66
- "blablabla".index(?b, 1).should == 3
67
- "blablabla".index(?b, 2).should == 3
68
- "blablabla".index(?b, 3).should == 3
69
- "blablabla".index(?b, 4).should == 6
70
- "blablabla".index(?b, 5).should == 6
71
- "blablabla".index(?b, 6).should == 6
72
-
73
- "blablabla".index(?a, 0).should == 2
74
- "blablabla".index(?a, 2).should == 2
75
- "blablabla".index(?a, 3).should == 5
76
- "blablabla".index(?a, 4).should == 5
77
- "blablabla".index(?a, 5).should == 5
78
- "blablabla".index(?a, 6).should == 8
79
- "blablabla".index(?a, 7).should == 8
80
- "blablabla".index(?a, 8).should == 8
81
- end
82
-
83
- it "starts the search at offset + self.length if offset is negative" do
84
- str = "blablabla"
85
-
86
- [?a, ?b].each do |needle|
87
- (-str.length .. -1).each do |offset|
88
- p offset
89
- str.index(needle, offset).should ==
90
- str.index(needle, offset + str.length)
91
- end
92
- end
93
-
94
- "blablabla".index(?b, -9).should == 0
95
- end
96
-
97
- it "returns nil if offset + self.length is < 0 for negative offsets" do
98
- "blablabla".index(?b, -10).should == nil
99
- "blablabla".index(?b, -20).should == nil
100
- end
101
-
102
- it "returns nil if the character isn't found" do
103
- "hello".index(0).should == nil
104
-
105
- "hello".index(?H).should == nil
106
- "hello".index(?z).should == nil
107
- "hello".index(?e, 2).should == nil
108
-
109
- "blablabla".index(?b, 7).should == nil
110
- "blablabla".index(?b, 10).should == nil
111
-
112
- "blablabla".index(?a, 9).should == nil
113
- "blablabla".index(?a, 20).should == nil
114
- end
115
- end
116
- end
117
-
118
- describe "String#index with String" do
119
- it "behaves the same as String#index(char) for one-character strings" do
120
- ["blablabla", "hello cruel world...!"].each do |str|
121
- str.split("").uniq.each do |str|
122
- chr = str[0]
123
- str.index(str).should == str.index(chr)
124
-
125
- 0.upto(str.size + 1) do |start|
126
- str.index(str, start).should == str.index(chr, start)
127
- end
128
-
129
- (-str.size - 1).upto(-1) do |start|
130
- str.index(str, start).should == str.index(chr, start)
131
- end
132
- end
133
- end
134
- end
135
-
136
- it "returns the index of the first occurrence of the given substring" do
137
- "blablabla".index("").should == 0
138
- "blablabla".index("b").should == 0
139
- "blablabla".index("bla").should == 0
140
- "blablabla".index("blabla").should == 0
141
- "blablabla".index("blablabla").should == 0
142
-
143
- "blablabla".index("l").should == 1
144
- "blablabla".index("la").should == 1
145
- "blablabla".index("labla").should == 1
146
- "blablabla".index("lablabla").should == 1
147
-
148
- "blablabla".index("a").should == 2
149
- "blablabla".index("abla").should == 2
150
- "blablabla".index("ablabla").should == 2
151
- end
152
-
153
- it "doesn't set $~" do
154
- $~ = nil
155
-
156
- 'hello.'.index('ll')
157
- $~.should == nil
158
- end
159
-
160
- it "ignores string subclasses" do
161
- "blablabla".index(StringSpecs::MyString.new("bla")).should == 0
162
- StringSpecs::MyString.new("blablabla").index("bla").should == 0
163
- StringSpecs::MyString.new("blablabla").index(StringSpecs::MyString.new("bla")).should == 0
164
- end
165
-
166
- it "starts the search at the given offset" do
167
- "blablabla".index("bl", 0).should == 0
168
- "blablabla".index("bl", 1).should == 3
169
- "blablabla".index("bl", 2).should == 3
170
- "blablabla".index("bl", 3).should == 3
171
-
172
- "blablabla".index("bla", 0).should == 0
173
- "blablabla".index("bla", 1).should == 3
174
- "blablabla".index("bla", 2).should == 3
175
- "blablabla".index("bla", 3).should == 3
176
-
177
- "blablabla".index("blab", 0).should == 0
178
- "blablabla".index("blab", 1).should == 3
179
- "blablabla".index("blab", 2).should == 3
180
- "blablabla".index("blab", 3).should == 3
181
-
182
- "blablabla".index("la", 1).should == 1
183
- "blablabla".index("la", 2).should == 4
184
- "blablabla".index("la", 3).should == 4
185
- "blablabla".index("la", 4).should == 4
186
-
187
- "blablabla".index("lab", 1).should == 1
188
- "blablabla".index("lab", 2).should == 4
189
- "blablabla".index("lab", 3).should == 4
190
- "blablabla".index("lab", 4).should == 4
191
-
192
- "blablabla".index("ab", 2).should == 2
193
- "blablabla".index("ab", 3).should == 5
194
- "blablabla".index("ab", 4).should == 5
195
- "blablabla".index("ab", 5).should == 5
196
-
197
- "blablabla".index("", 0).should == 0
198
- "blablabla".index("", 1).should == 1
199
- "blablabla".index("", 2).should == 2
200
- "blablabla".index("", 7).should == 7
201
- "blablabla".index("", 8).should == 8
202
- "blablabla".index("", 9).should == 9
203
- end
204
-
205
- it "starts the search at offset + self.length if offset is negative" do
206
- str = "blablabla"
207
-
208
- ["bl", "bla", "blab", "la", "lab", "ab", ""].each do |needle|
209
- (-str.length .. -1).each do |offset|
210
- str.index(needle, offset).should ==
211
- str.index(needle, offset + str.length)
212
- end
213
- end
214
- end
215
-
216
- it "returns nil if the substring isn't found" do
217
- "blablabla".index("B").should == nil
218
- "blablabla".index("z").should == nil
219
- "blablabla".index("BLA").should == nil
220
- "blablabla".index("blablablabla").should == nil
221
- "blablabla".index("", 10).should == nil
222
- "blablabla".index("", 10).should == nil
223
-
224
- "12345".index("", 6).should == nil
225
- "hello".index("he", 1).should == nil
226
- "hello".index("he", 2).should == nil
227
- end
228
-
229
- with_feature :encoding do
230
- it "returns the character index of a multibyte character" do
231
- "ありがとう".index("が").should == 2
232
- end
233
-
234
- it "returns the character index after offset" do
235
- "われわれ".index("わ", 1).should == 2
236
- end
237
-
238
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
239
- char = "れ".encode Encoding::EUC_JP
240
- lambda do
241
- "あれ".index char
242
- end.should raise_error(Encoding::CompatibilityError)
243
- end
244
- end
245
- end
246
-
247
- describe "String#index with Regexp" do
248
- it "behaves the same as String#index(string) for escaped string regexps" do
249
- ["blablabla", "hello cruel world...!"].each do |str|
250
- ["", "b", "bla", "lab", "o c", "d."].each do |needle|
251
- regexp = Regexp.new(Regexp.escape(needle))
252
- str.index(regexp).should == str.index(needle)
253
-
254
- 0.upto(str.size + 1) do |start|
255
- str.index(regexp, start).should == str.index(needle, start)
256
- end
257
-
258
- (-str.size - 1).upto(-1) do |start|
259
- str.index(regexp, start).should == str.index(needle, start)
260
- end
261
- end
262
- end
263
- end
264
-
265
- it "returns the index of the first match of regexp" do
266
- "blablabla".index(/bla/).should == 0
267
- "blablabla".index(/BLA/i).should == 0
268
-
269
- "blablabla".index(/.{0}/).should == 0
270
- "blablabla".index(/.{6}/).should == 0
271
- "blablabla".index(/.{9}/).should == 0
272
-
273
- "blablabla".index(/.*/).should == 0
274
- "blablabla".index(/.+/).should == 0
275
-
276
- "blablabla".index(/lab|b/).should == 0
277
-
278
- not_compliant_on :opal do
279
- "blablabla".index(/\A/).should == 0
280
- "blablabla".index(/\Z/).should == 9
281
- "blablabla".index(/\z/).should == 9
282
- "blablabla\n".index(/\Z/).should == 9
283
- "blablabla\n".index(/\z/).should == 10
284
- end
285
-
286
- "blablabla".index(/^/).should == 0
287
- "\nblablabla".index(/^/).should == 0
288
-
289
- not_compliant_on :opal do
290
- "b\nablabla".index(/$/).should == 1
291
- "bl\nablabla".index(/$/).should == 2
292
- end
293
-
294
- "blablabla".index(/.l./).should == 0
295
- end
296
-
297
- it "sets $~ to MatchData of match and nil when there's none" do
298
- 'hello.'.index(/.(.)/)
299
- $~[0].should == 'he'
300
-
301
- 'hello.'.index(/not/)
302
- $~.should == nil
303
- end
304
-
305
- it "starts the search at the given offset" do
306
- "blablabla".index(/.{0}/, 5).should == 5
307
- "blablabla".index(/.{1}/, 5).should == 5
308
- "blablabla".index(/.{2}/, 5).should == 5
309
- "blablabla".index(/.{3}/, 5).should == 5
310
- "blablabla".index(/.{4}/, 5).should == 5
311
-
312
- "blablabla".index(/.{0}/, 3).should == 3
313
- "blablabla".index(/.{1}/, 3).should == 3
314
- "blablabla".index(/.{2}/, 3).should == 3
315
- "blablabla".index(/.{5}/, 3).should == 3
316
- "blablabla".index(/.{6}/, 3).should == 3
317
-
318
- "blablabla".index(/.l./, 0).should == 0
319
- "blablabla".index(/.l./, 1).should == 3
320
- "blablabla".index(/.l./, 2).should == 3
321
- "blablabla".index(/.l./, 3).should == 3
322
-
323
- "xblaxbla".index(/x./, 0).should == 0
324
- "xblaxbla".index(/x./, 1).should == 4
325
- "xblaxbla".index(/x./, 2).should == 4
326
-
327
- not_compliant_on :opal do
328
- "blablabla\n".index(/\Z/, 9).should == 9
329
- end
330
- end
331
-
332
- it "starts the search at offset + self.length if offset is negative" do
333
- str = "blablabla"
334
-
335
- ["bl", "bla", "blab", "la", "lab", "ab", ""].each do |needle|
336
- (-str.length .. -1).each do |offset|
337
- str.index(needle, offset).should ==
338
- str.index(needle, offset + str.length)
339
- end
340
- end
341
- end
342
-
343
- it "returns nil if the substring isn't found" do
344
- "blablabla".index(/BLA/).should == nil
345
-
346
- "blablabla".index(/.{10}/).should == nil
347
- "blaxbla".index(/.x/, 3).should == nil
348
- "blaxbla".index(/..x/, 2).should == nil
349
- end
350
-
351
- it "returns nil if the Regexp matches the empty string and the offset is out of range" do
352
- "ruby".index(//,12).should be_nil
353
- end
354
-
355
- not_compliant_on :opal do
356
- it "supports \\G which matches at the given start offset" do
357
- "helloYOU.".index(/\GYOU/, 5).should == 5
358
- "helloYOU.".index(/\GYOU/).should == nil
359
-
360
- re = /\G.+YOU/
361
- # The # marks where \G will match.
362
- [
363
- ["#hi!YOUall.", 0],
364
- ["h#i!YOUall.", 1],
365
- ["hi#!YOUall.", 2],
366
- ["hi!#YOUall.", nil]
367
- ].each do |spec|
368
-
369
- start = spec[0].index("#")
370
- str = spec[0].delete("#")
371
-
372
- str.index(re, start).should == spec[1]
373
- end
374
- end
375
- end
376
-
377
- not_compliant_on :opal do
378
- it "converts start_offset to an integer via to_int" do
379
- obj = mock('1')
380
- obj.should_receive(:to_int).and_return(1)
381
- "RWOARW".index(/R./, obj).should == 4
382
- end
383
- end
384
-
385
- with_feature :encoding do
386
- it "returns the character index of a multibyte character" do
387
- "ありがとう".index(/が/).should == 2
388
- end
389
-
390
- it "returns the character index after offset" do
391
- "われわれ".index(/わ/, 1).should == 2
392
- end
393
-
394
- it "treats the offset as a character index" do
395
- "われわわれ".index(/わ/, 3).should == 3
396
- end
397
-
398
- it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
399
- re = Regexp.new "れ".encode(Encoding::EUC_JP)
400
- lambda do
401
- "あれ".index re
402
- end.should raise_error(Encoding::CompatibilityError)
403
- end
404
- end
405
- end