opal 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. data/.rspec +3 -0
  2. data/.travis.yml +0 -4
  3. data/README.md +6 -0
  4. data/Rakefile +30 -6
  5. data/bin/opal +6 -82
  6. data/corelib/{opal/array.rb → array.rb} +40 -56
  7. data/corelib/{opal/basic_object.rb → basic_object.rb} +2 -2
  8. data/corelib/{opal/boolean.rb → boolean.rb} +0 -8
  9. data/corelib/class.rb +47 -0
  10. data/corelib/{opal/comparable.rb → comparable.rb} +0 -0
  11. data/corelib/{opal/enumerable.rb → enumerable.rb} +208 -141
  12. data/corelib/{opal/enumerator.rb → enumerator.rb} +3 -3
  13. data/corelib/{opal/error.rb → error.rb} +1 -0
  14. data/corelib/{opal/hash.rb → hash.rb} +67 -56
  15. data/corelib/io.rb +39 -0
  16. data/corelib/{opal/kernel.rb → kernel.rb} +35 -31
  17. data/corelib/{opal/class.rb → module.rb} +29 -57
  18. data/corelib/native.rb +148 -0
  19. data/corelib/{opal/nil_class.rb → nil_class.rb} +2 -10
  20. data/corelib/{opal/numeric.rb → numeric.rb} +39 -14
  21. data/corelib/opal.rb +42 -25
  22. data/corelib/{opal/proc.rb → proc.rb} +3 -3
  23. data/corelib/{opal/range.rb → range.rb} +5 -1
  24. data/corelib/{opal/regexp.rb → regexp.rb} +0 -0
  25. data/corelib/{opal/runtime.js → runtime.js} +96 -188
  26. data/corelib/{opal/string.rb → string.rb} +20 -15
  27. data/corelib/struct.rb +139 -0
  28. data/corelib/{opal/time.rb → time.rb} +0 -0
  29. data/lib/opal.rb +4 -0
  30. data/lib/opal/cli.rb +79 -32
  31. data/lib/opal/cli_options.rb +91 -0
  32. data/lib/opal/erb.rb +41 -8
  33. data/lib/opal/grammar.rb +24 -10
  34. data/lib/opal/grammar.y +15 -4
  35. data/lib/opal/grammar_helpers.rb +4 -0
  36. data/lib/opal/lexer.rb +214 -143
  37. data/lib/opal/parser.rb +596 -562
  38. data/lib/opal/require_parser.rb +1 -1
  39. data/lib/opal/source_map.rb +15 -30
  40. data/lib/opal/target_scope.rb +24 -5
  41. data/lib/opal/version.rb +1 -1
  42. data/mri_spec/cli_spec.rb +18 -0
  43. data/mri_spec/fixtures/opal_file.rb +2 -0
  44. data/mri_spec/spec_helper.rb +17 -0
  45. data/opal.gemspec +5 -2
  46. data/spec/{rubyspec/filters → filters}/bugs/alias.rb +0 -0
  47. data/spec/{rubyspec/filters → filters}/bugs/ancestors.rb +0 -0
  48. data/spec/{rubyspec/filters → filters}/bugs/array.rb +0 -0
  49. data/spec/filters/bugs/array/combination.rb +11 -0
  50. data/spec/filters/bugs/array/count.rb +3 -0
  51. data/spec/filters/bugs/array/delete_if.rb +3 -0
  52. data/spec/filters/bugs/array/drop.rb +3 -0
  53. data/spec/filters/bugs/array/drop_while.rb +5 -0
  54. data/spec/filters/bugs/array/eql.rb +3 -0
  55. data/spec/filters/bugs/array/flatten.rb +9 -0
  56. data/spec/filters/bugs/array/minus.rb +5 -0
  57. data/spec/filters/bugs/array/multipliy.rb +9 -0
  58. data/spec/filters/bugs/array/new.rb +3 -0
  59. data/spec/filters/bugs/array/pop.rb +6 -0
  60. data/spec/filters/bugs/array/rassoc.rb +4 -0
  61. data/spec/filters/bugs/array/rindex.rb +6 -0
  62. data/spec/filters/bugs/array/select.rb +3 -0
  63. data/spec/filters/bugs/array/shift.rb +7 -0
  64. data/spec/filters/bugs/array/shuffle.rb +11 -0
  65. data/spec/filters/bugs/array/slice.rb +7 -0
  66. data/spec/filters/bugs/array/take.rb +3 -0
  67. data/spec/filters/bugs/array/to_a.rb +3 -0
  68. data/spec/filters/bugs/array/try_convert.rb +7 -0
  69. data/spec/filters/bugs/array/uniq.rb +10 -0
  70. data/spec/filters/bugs/array/zip.rb +4 -0
  71. data/spec/{rubyspec/filters → filters}/bugs/array_delete.rb +1 -0
  72. data/spec/{rubyspec/filters → filters}/bugs/array_fetch.rb +0 -0
  73. data/spec/{rubyspec/filters → filters}/bugs/array_first.rb +0 -0
  74. data/spec/{rubyspec/filters → filters}/bugs/array_flatten.rb +0 -0
  75. data/spec/{rubyspec/filters → filters}/bugs/array_intersection.rb +0 -0
  76. data/spec/{rubyspec/filters → filters}/bugs/array_join.rb +0 -0
  77. data/spec/{rubyspec/filters → filters}/bugs/break.rb +0 -0
  78. data/spec/filters/bugs/case.rb +4 -0
  79. data/spec/{rubyspec/filters → filters}/bugs/coerce_integer.rb +0 -0
  80. data/spec/filters/bugs/enumerable_sort_by.rb +3 -0
  81. data/spec/{rubyspec/filters → filters}/bugs/kernel/instance_variables.rb +0 -0
  82. data/spec/filters/bugs/kernel/rand.rb +4 -0
  83. data/spec/filters/bugs/language/array.rb +3 -0
  84. data/spec/filters/bugs/language/block.rb +6 -0
  85. data/spec/filters/bugs/language/break.rb +3 -0
  86. data/spec/{rubyspec/filters → filters}/bugs/language/class.rb +3 -0
  87. data/spec/{rubyspec/filters → filters}/bugs/language/class_variables.rb +0 -0
  88. data/spec/filters/bugs/language/def.rb +27 -0
  89. data/spec/filters/bugs/language/defined.rb +3 -0
  90. data/spec/filters/bugs/language/ensure.rb +4 -0
  91. data/spec/filters/bugs/language/execution.rb +4 -0
  92. data/spec/filters/bugs/language/for.rb +18 -0
  93. data/spec/filters/bugs/language/if.rb +13 -0
  94. data/spec/filters/bugs/language/loop.rb +4 -0
  95. data/spec/filters/bugs/language/metaclass.rb +14 -0
  96. data/spec/filters/bugs/language/module.rb +6 -0
  97. data/spec/filters/bugs/language/next.rb +3 -0
  98. data/spec/filters/bugs/language/or.rb +3 -0
  99. data/spec/filters/bugs/language/order.rb +4 -0
  100. data/spec/filters/bugs/language/precedence.rb +10 -0
  101. data/spec/filters/bugs/language/proc.rb +24 -0
  102. data/spec/filters/bugs/language/redo.rb +5 -0
  103. data/spec/filters/bugs/language/rescue.rb +9 -0
  104. data/spec/filters/bugs/language/retry.rb +5 -0
  105. data/spec/filters/bugs/language/send.rb +10 -0
  106. data/spec/filters/bugs/language/super.rb +9 -0
  107. data/spec/filters/bugs/language/until.rb +8 -0
  108. data/spec/filters/bugs/language/variables.rb +37 -0
  109. data/spec/filters/bugs/language/while.rb +6 -0
  110. data/spec/filters/bugs/language/yield.rb +5 -0
  111. data/spec/{rubyspec/filters → filters}/bugs/module/class_variables.rb +0 -0
  112. data/spec/filters/bugs/module/method_defined.rb +6 -0
  113. data/spec/filters/bugs/parser.rb +10 -0
  114. data/spec/{rubyspec/filters → filters}/bugs/public_methods.rb +1 -0
  115. data/spec/filters/bugs/return.rb +7 -0
  116. data/spec/filters/bugs/singleton/instance.rb +4 -0
  117. data/spec/filters/bugs/source_map.rb +3 -0
  118. data/spec/filters/bugs/string/center.rb +4 -0
  119. data/spec/filters/bugs/string/lines.rb +3 -0
  120. data/spec/{rubyspec/filters → filters}/mspec/mocks.rb +0 -0
  121. data/spec/{rubyspec/filters → filters}/mspec/ruby_exe.rb +0 -0
  122. data/spec/{rubyspec/filters → filters}/mspec/should_receive.rb +0 -0
  123. data/spec/{rubyspec/filters → filters}/parser/block_args.rb +0 -0
  124. data/spec/{rubyspec/filters → filters}/unsupported/array_subclasses.rb +1 -0
  125. data/spec/filters/unsupported/frozen.rb +32 -0
  126. data/spec/filters/unsupported/immutable_strings.rb +3 -0
  127. data/spec/filters/unsupported/tainted.rb +17 -0
  128. data/spec/filters/unsupported/trusted.rb +15 -0
  129. data/spec/opal/class/constants_spec.rb +7 -0
  130. data/spec/opal/erb/erb_spec.rb +7 -1
  131. data/spec/opal/erb/inline_block.opalerb +3 -0
  132. data/spec/opal/hash/allocate_spec.rb +16 -0
  133. data/spec/opal/hash/new_spec.rb +10 -0
  134. data/spec/opal/hash/to_s_spec.rb +9 -0
  135. data/spec/opal/kernel/instance_variable_defined_spec.rb +15 -0
  136. data/spec/opal/kernel/rand_spec.rb +5 -5
  137. data/spec/opal/kernel/respond_to_spec.rb +14 -1
  138. data/spec/opal/language/block_spec.rb +13 -0
  139. data/spec/opal/language/rescue_spec.rb +27 -0
  140. data/spec/opal/language/return_spec.rb +38 -0
  141. data/spec/opal/language/singleton_class_spec.rb +13 -0
  142. data/spec/opal/language/super_spec.rb +99 -0
  143. data/spec/opal/language/variables_spec.rb +20 -0
  144. data/spec/opal/module/attr_accessor_spec.rb +8 -0
  145. data/spec/opal/module/constants_spec.rb +2 -2
  146. data/spec/opal/native/alias_native_spec.rb +18 -0
  147. data/spec/opal/native/each_spec.rb +14 -0
  148. data/spec/opal/native/element_reference_spec.rb +14 -0
  149. data/spec/opal/native/method_missing_spec.rb +39 -0
  150. data/spec/opal/native/new_spec.rb +19 -0
  151. data/spec/opal/native/nil_spec.rb +14 -0
  152. data/spec/opal/runtime2/class_hierarchy_spec.rb +2 -2
  153. data/spec/opal/source_map_spec.rb +3 -7
  154. data/spec/ospec/main.rb.erb +2 -5
  155. data/spec/parser/alias_spec.rb +4 -4
  156. data/spec/parser/and_spec.rb +2 -2
  157. data/spec/parser/array_spec.rb +6 -6
  158. data/spec/parser/attrasgn_spec.rb +8 -8
  159. data/spec/parser/begin_spec.rb +11 -11
  160. data/spec/parser/block_spec.rb +3 -3
  161. data/spec/parser/break_spec.rb +4 -4
  162. data/spec/parser/call_spec.rb +50 -48
  163. data/spec/parser/class_spec.rb +2 -2
  164. data/spec/parser/const_spec.rb +1 -1
  165. data/spec/parser/cvar_spec.rb +1 -1
  166. data/spec/parser/def_spec.rb +5 -5
  167. data/spec/parser/gvar_spec.rb +2 -2
  168. data/spec/parser/hash_spec.rb +4 -4
  169. data/spec/parser/iasgn_spec.rb +3 -3
  170. data/spec/parser/if_spec.rb +6 -6
  171. data/spec/parser/iter_spec.rb +6 -6
  172. data/spec/parser/lambda_spec.rb +5 -5
  173. data/spec/parser/lasgn_spec.rb +2 -2
  174. data/spec/parser/line_spec.rb +2 -2
  175. data/spec/parser/lvar_spec.rb +5 -5
  176. data/spec/parser/masgn_spec.rb +1 -1
  177. data/spec/parser/module_spec.rb +2 -2
  178. data/spec/parser/not_spec.rb +4 -4
  179. data/spec/parser/op_asgn1_spec.rb +2 -2
  180. data/spec/parser/op_asgn2_spec.rb +2 -2
  181. data/spec/parser/or_spec.rb +2 -2
  182. data/spec/parser/parse_spec.rb +66 -0
  183. data/spec/parser/parser_spec.rb +32 -38
  184. data/spec/parser/regexp_spec.rb +4 -4
  185. data/spec/parser/return_spec.rb +4 -4
  186. data/spec/parser/sclass_spec.rb +4 -4
  187. data/spec/parser/str_spec.rb +3 -3
  188. data/spec/parser/super_spec.rb +6 -6
  189. data/spec/parser/undef_spec.rb +3 -3
  190. data/spec/parser/unless_spec.rb +4 -4
  191. data/spec/parser/while_spec.rb +3 -3
  192. data/spec/parser/xstr_spec.rb +3 -3
  193. data/spec/parser/yield_spec.rb +6 -6
  194. data/spec/rubyspec/core/array/drop_spec.rb +1 -1
  195. data/spec/rubyspec/core/array/keep_if_spec.rb +1 -3
  196. data/spec/rubyspec/core/array/length_spec.rb +1 -3
  197. data/spec/rubyspec/core/array/map_spec.rb +2 -6
  198. data/spec/rubyspec/core/array/minus_spec.rb +3 -3
  199. data/spec/rubyspec/core/array/multiply_spec.rb +14 -16
  200. data/spec/rubyspec/core/array/new_spec.rb +3 -5
  201. data/spec/rubyspec/core/array/plus_spec.rb +2 -2
  202. data/spec/rubyspec/core/array/pop_spec.rb +4 -4
  203. data/spec/rubyspec/core/array/rassoc_spec.rb +2 -2
  204. data/spec/rubyspec/core/array/reject_spec.rb +2 -6
  205. data/spec/rubyspec/core/array/replace_spec.rb +1 -3
  206. data/spec/rubyspec/core/array/reverse_each_spec.rb +1 -3
  207. data/spec/rubyspec/core/array/reverse_spec.rb +4 -4
  208. data/spec/rubyspec/core/array/rindex_spec.rb +1 -1
  209. data/spec/rubyspec/core/array/select_spec.rb +3 -7
  210. data/spec/rubyspec/core/array/shared/collect.rb +7 -0
  211. data/spec/rubyspec/core/array/shared/index.rb +1 -1
  212. data/spec/rubyspec/core/array/shared/keep_if.rb +3 -0
  213. data/spec/rubyspec/core/array/shared/length.rb +3 -0
  214. data/spec/rubyspec/core/array/shared/replace.rb +3 -0
  215. data/spec/rubyspec/core/array/shared/slice.rb +3 -0
  216. data/spec/rubyspec/core/array/shuffle_spec.rb +1 -1
  217. data/spec/rubyspec/core/array/size_spec.rb +1 -3
  218. data/spec/rubyspec/core/array/slice_spec.rb +4 -6
  219. data/spec/rubyspec/core/array/sort_spec.rb +2 -2
  220. data/spec/rubyspec/core/array/to_a_spec.rb +1 -1
  221. data/spec/rubyspec/core/array/try_convert_spec.rb +7 -7
  222. data/spec/rubyspec/core/array/uniq_spec.rb +7 -7
  223. data/spec/rubyspec/core/array/zip_spec.rb +1 -1
  224. data/spec/rubyspec/core/enumerable/collect_spec.rb +24 -0
  225. data/spec/rubyspec/core/enumerable/count_spec.rb +35 -19
  226. data/spec/rubyspec/core/enumerable/find_spec.rb +5 -0
  227. data/spec/rubyspec/core/hash/each_pair_spec.rb +7 -7
  228. data/spec/rubyspec/core/hash/each_spec.rb +13 -7
  229. data/spec/rubyspec/core/module/method_defined_spec.rb +4 -4
  230. data/spec/rubyspec/core/module/public_method_defined_spec.rb +19 -0
  231. data/spec/rubyspec/core/module/remove_const_spec.rb +23 -0
  232. data/spec/rubyspec/core/numeric/step_spec.rb +14 -0
  233. data/spec/rubyspec/core/string/center_spec.rb +43 -65
  234. data/spec/rubyspec/core/string/lines_spec.rb +1 -1
  235. data/spec/rubyspec/core/string/ljust_spec.rb +25 -9
  236. data/spec/rubyspec/core/string/rjust_spec.rb +26 -10
  237. data/spec/rubyspec/core/struct/fixtures/classes.rb +26 -0
  238. data/spec/rubyspec/core/struct/initialize_spec.rb +11 -0
  239. data/spec/rubyspec/core/struct/new_spec.rb +24 -0
  240. data/spec/rubyspec/fixtures/constants.rb +7 -0
  241. data/spec/rubyspec/language/break_spec.rb +1 -1
  242. data/spec/rubyspec/language/case_spec.rb +30 -30
  243. data/spec/rubyspec/language/def_spec.rb +34 -34
  244. data/spec/rubyspec/language/defined_spec.rb +2 -2
  245. data/spec/rubyspec/language/ensure_spec.rb +2 -2
  246. data/spec/rubyspec/language/execution_spec.rb +2 -2
  247. data/spec/rubyspec/language/for_spec.rb +17 -17
  248. data/spec/rubyspec/language/hash_spec.rb +3 -3
  249. data/spec/rubyspec/language/if_spec.rb +11 -11
  250. data/spec/rubyspec/language/loop_spec.rb +3 -3
  251. data/spec/rubyspec/language/metaclass_spec.rb +14 -14
  252. data/spec/rubyspec/language/module_spec.rb +6 -6
  253. data/spec/rubyspec/language/next_spec.rb +5 -5
  254. data/spec/rubyspec/language/not_spec.rb +1 -1
  255. data/spec/rubyspec/language/or_spec.rb +1 -1
  256. data/spec/rubyspec/language/order_spec.rb +3 -5
  257. data/spec/rubyspec/language/precedence_spec.rb +19 -19
  258. data/spec/rubyspec/language/proc_spec.rb +29 -29
  259. data/spec/rubyspec/language/redo_spec.rb +3 -5
  260. data/spec/rubyspec/language/rescue_spec.rb +7 -7
  261. data/spec/rubyspec/language/retry_spec.rb +2 -2
  262. data/spec/rubyspec/language/return_spec.rb +12 -12
  263. data/spec/rubyspec/language/send_spec.rb +9 -9
  264. data/spec/rubyspec/language/singleton_class_spec.rb +3 -4
  265. data/spec/rubyspec/language/super_spec.rb +7 -11
  266. data/spec/rubyspec/language/until_spec.rb +10 -10
  267. data/spec/rubyspec/language/variables_spec.rb +59 -67
  268. data/spec/rubyspec/language/versions/array_1.9.rb +1 -1
  269. data/spec/rubyspec/language/versions/block_1.9.rb +0 -0
  270. data/spec/rubyspec/language/versions/break_1.9.rb +0 -0
  271. data/spec/rubyspec/language/versions/literal_lambda_1.9.rb +12 -12
  272. data/spec/rubyspec/language/versions/send_1.9.rb +23 -23
  273. data/spec/rubyspec/language/versions/symbol_1.9.rb +2 -2
  274. data/spec/rubyspec/language/versions/variables_1.9.rb +1 -1
  275. data/spec/rubyspec/language/while_spec.rb +4 -4
  276. data/spec/rubyspec/language/yield_spec.rb +3 -3
  277. data/spec/rubyspec/library/erb/util/html_escape_spec.rb +10 -0
  278. data/spec/rubyspec/library/singleton/clone_spec.rb +8 -0
  279. data/spec/rubyspec/library/singleton/dup_spec.rb +8 -0
  280. data/spec/rubyspec/library/singleton/fixtures/classes.rb +18 -0
  281. data/spec/rubyspec/library/singleton/instance_spec.rb +30 -0
  282. data/spec/spec_helper.rb +214 -0
  283. data/stdlib/buffer.rb +40 -0
  284. data/stdlib/buffer/array.rb +66 -0
  285. data/stdlib/buffer/view.rb +70 -0
  286. data/stdlib/erb.rb +11 -20
  287. data/stdlib/forwardable.rb +71 -0
  288. data/stdlib/json.rb +78 -0
  289. data/stdlib/ostruct.rb +69 -0
  290. data/stdlib/rbconfig.rb +1 -0
  291. data/stdlib/singleton.rb +40 -0
  292. data/stdlib/stringio.rb +173 -0
  293. data/stdlib/template.rb +44 -0
  294. metadata +285 -79
  295. data/corelib/opal/native.rb +0 -31
  296. data/spec/opal/class/bridge_class_spec.rb +0 -39
  297. data/spec/opal/native_spec.rb +0 -209
  298. data/spec/ospec/runner.rb +0 -223
  299. data/spec/rubyspec/filters/bugs/block_args.rb +0 -3
  300. data/spec/rubyspec/filters/bugs/case.rb +0 -8
  301. data/spec/rubyspec/filters/bugs/language/module.rb +0 -3
  302. data/spec/rubyspec/filters/unsupported/frozen.rb +0 -4
  303. data/spec/rubyspec/filters/unsupported/tainted.rb +0 -7
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+ require File.expand_path('../fixtures/classes', __FILE__)
3
+
4
+ describe "Struct#initialize" do
5
+
6
+ it "does nothing when passed a set of fields equal to self" do
7
+ car = same_car = StructClasses::Car.new("Honda", "Accord", "1998")
8
+ car.instance_eval { initialize("Honda", "Accord", "1998") }
9
+ car.should == same_car
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+ require File.expand_path('../fixtures/classes', __FILE__)
3
+
4
+ describe "Struct.new" do
5
+ it "creates a constant in Struct namespace with string as first argument" do
6
+ struct = Struct.new('Animal', :name, :legs, :eyeballs)
7
+ struct.should == Struct::Animal
8
+ struct.name.should == "Struct::Animal"
9
+ end
10
+
11
+ it "creates an instance" do
12
+ StructClasses::Ruby.new.kind_of?(StructClasses::Ruby).should == true
13
+ end
14
+
15
+ it "creates reader methods" do
16
+ StructClasses::Ruby.new.should have_method(:version)
17
+ StructClasses::Ruby.new.should have_method(:platform)
18
+ end
19
+
20
+ it "creates writer methods" do
21
+ StructClasses::Ruby.new.should have_method(:version=)
22
+ StructClasses::Ruby.new.should have_method(:platform=)
23
+ end
24
+ end
@@ -5,6 +5,13 @@ CS_BLANK = ""
5
5
  CS_FALSE = false
6
6
 
7
7
  module ConstantSpecs
8
+
9
+ # Included in ModuleD
10
+ module ModuleM
11
+ CS_CONST10 = :const10_11
12
+ CS_CONST24 = :const24
13
+ end
14
+
8
15
  class ClassA
9
16
  CS_CONST10 = :const10_10
10
17
  CS_CONST16 = :const16
@@ -329,4 +329,4 @@ describe "Executing break from within a block" do
329
329
  end
330
330
  end
331
331
 
332
- # language_version __FILE__, "break"
332
+ language_version __FILE__, "break"
@@ -245,44 +245,44 @@ end
245
245
 
246
246
  describe "The 'case'-construct with no target expression" do
247
247
  it "evaluates the body of the first clause when at least one of its condition expressions is true" do
248
- # case
249
- # when true, false; 'foo'
250
- # end.should == 'foo'
248
+ case
249
+ when true, false; 'foo'
250
+ end.should == 'foo'
251
251
  end
252
252
 
253
253
  it "evaluates the body of the first when clause that is not false/nil" do
254
- # case
255
- # when false; 'foo'
256
- # when 2; 'bar'
257
- # when 1 == 1; 'baz'
258
- # end.should == 'bar'
259
-
260
- # case
261
- # when false; 'foo'
262
- # when nil; 'foo'
263
- # when 1 == 1; 'bar'
264
- # end.should == 'bar'
254
+ case
255
+ when false; 'foo'
256
+ when 2; 'bar'
257
+ when 1 == 1; 'baz'
258
+ end.should == 'bar'
259
+
260
+ case
261
+ when false; 'foo'
262
+ when nil; 'foo'
263
+ when 1 == 1; 'bar'
264
+ end.should == 'bar'
265
265
  end
266
266
 
267
267
  it "evaluates the body of the else clause if all when clauses are false/nil" do
268
- # case
269
- # when false; 'foo'
270
- # when nil; 'foo'
271
- # when 1 == 2; 'bar'
272
- # else 'baz'
273
- # end.should == 'baz'
268
+ case
269
+ when false; 'foo'
270
+ when nil; 'foo'
271
+ when 1 == 2; 'bar'
272
+ else 'baz'
273
+ end.should == 'baz'
274
274
  end
275
275
 
276
276
  it "evaluates multiple conditional expressions as a boolean disjunction" do
277
- # case
278
- # when true, false; 'foo'
279
- # else 'bar'
280
- # end.should == 'foo'
281
-
282
- # case
283
- # when false, true; 'foo'
284
- # else 'bar'
285
- # end.should == 'foo'
277
+ case
278
+ when true, false; 'foo'
279
+ else 'bar'
280
+ end.should == 'foo'
281
+
282
+ case
283
+ when false, true; 'foo'
284
+ else 'bar'
285
+ end.should == 'foo'
286
286
  end
287
287
 
288
288
  it "evaluates true as only 'true' when true is the first clause" do
@@ -307,4 +307,4 @@ describe "The 'case'-construct with no target expression" do
307
307
  end
308
308
  end
309
309
 
310
- # language_version __FILE__, "case"
310
+ language_version __FILE__, "case"
@@ -12,7 +12,7 @@ describe "Redefining a method" do
12
12
  end
13
13
 
14
14
  describe "Defining an 'initialize' method" do
15
- pending "sets the method's visibility to private" do
15
+ it "sets the method's visibility to private" do
16
16
  class DefInitializeSpec
17
17
  def initialize
18
18
  end
@@ -22,7 +22,7 @@ describe "Defining an 'initialize' method" do
22
22
  end
23
23
 
24
24
  describe "Defining an 'initialize_copy' method" do
25
- pending "sets the method's visibility to private" do
25
+ it "sets the method's visibility to private" do
26
26
  class DefInitializeCopySpec
27
27
  def initialize_copy
28
28
  end
@@ -120,10 +120,10 @@ end
120
120
 
121
121
  describe "A singleton method definition" do
122
122
  after :all do
123
- Object.remove_class_variable :@@a rescue nil
123
+ #Object.remove_class_variable :@@a rescue nil
124
124
  end
125
125
 
126
- pending "can be declared for a local variable" do
126
+ it "can be declared for a local variable" do
127
127
  a = "hi"
128
128
  def a.foo
129
129
  5
@@ -131,7 +131,7 @@ describe "A singleton method definition" do
131
131
  a.foo.should == 5
132
132
  end
133
133
 
134
- pending "can be declared for an instance variable" do
134
+ it "can be declared for an instance variable" do
135
135
  @a = "hi"
136
136
  def @a.foo
137
137
  6
@@ -139,7 +139,7 @@ describe "A singleton method definition" do
139
139
  @a.foo.should == 6
140
140
  end
141
141
 
142
- pending "can be declared for a global variable" do
142
+ it "can be declared for a global variable" do
143
143
  $__a__ = "hi"
144
144
  def $__a__.foo
145
145
  7
@@ -147,7 +147,7 @@ describe "A singleton method definition" do
147
147
  $__a__.foo.should == 7
148
148
  end
149
149
 
150
- pending "can be declared for a class variable" do
150
+ it "can be declared for a class variable" do
151
151
  @@a = "hi"
152
152
  def @@a.foo
153
153
  8
@@ -155,14 +155,14 @@ describe "A singleton method definition" do
155
155
  @@a.foo.should == 8
156
156
  end
157
157
 
158
- pending "can be declared with an empty method body" do
158
+ it "can be declared with an empty method body" do
159
159
  class DefSpec
160
160
  def self.foo;end
161
161
  end
162
162
  DefSpec.foo.should == nil
163
163
  end
164
164
 
165
- pending "can be redefined" do
165
+ it "can be redefined" do
166
166
  obj = Object.new
167
167
  def obj.==(other)
168
168
  1
@@ -183,7 +183,7 @@ describe "A singleton method definition" do
183
183
  end
184
184
 
185
185
  ruby_version_is "1.9" do
186
- pending "raises RuntimeError if frozen" do
186
+ it "raises RuntimeError if frozen" do
187
187
  obj = Object.new
188
188
  obj.freeze
189
189
  lambda { def obj.foo; end }.should raise_error(RuntimeError)
@@ -192,7 +192,7 @@ describe "A singleton method definition" do
192
192
  end
193
193
 
194
194
  describe "Redefining a singleton method" do
195
- pending "does not inherit a previously set visibility " do
195
+ it "does not inherit a previously set visibility " do
196
196
  o = Object.new
197
197
 
198
198
  class << o; private; def foo; end; end;
@@ -205,10 +205,10 @@ describe "Redefining a singleton method" do
205
205
  class << o; should have_instance_method(:foo); end
206
206
 
207
207
  end
208
- end
208
+ end if false
209
209
 
210
210
  describe "Redefining a singleton method" do
211
- pending "does not inherit a previously set visibility " do
211
+ it "does not inherit a previously set visibility " do
212
212
  o = Object.new
213
213
 
214
214
  class << o; private; def foo; end; end;
@@ -221,10 +221,10 @@ describe "Redefining a singleton method" do
221
221
  class << o; should have_instance_method(:foo); end
222
222
 
223
223
  end
224
- end
224
+ end if false
225
225
 
226
226
  describe "A method defined with extreme default arguments" do
227
- pending "can redefine itself when the default is evaluated" do
227
+ it "can redefine itself when the default is evaluated" do
228
228
  class DefSpecs
229
229
  def foo(x = (def foo; "hello"; end;1));x;end
230
230
  end
@@ -235,7 +235,7 @@ describe "A method defined with extreme default arguments" do
235
235
  d.foo.should == 'hello'
236
236
  end
237
237
 
238
- pending "may use an fcall as a default" do
238
+ it "may use an fcall as a default" do
239
239
  def foo(x = caller())
240
240
  x
241
241
  end
@@ -264,7 +264,7 @@ describe "A method defined with extreme default arguments" do
264
264
  end
265
265
 
266
266
  describe "A singleton method defined with extreme default arguments" do
267
- pending "may use a method definition as a default" do
267
+ it "may use a method definition as a default" do
268
268
  $__a = "hi"
269
269
  def $__a.foo(x = (def $__a.foo; "hello"; end;1));x;end
270
270
 
@@ -273,7 +273,7 @@ describe "A singleton method defined with extreme default arguments" do
273
273
  $__a.foo.should == 'hello'
274
274
  end
275
275
 
276
- pending "may use an fcall as a default" do
276
+ it "may use an fcall as a default" do
277
277
  a = "hi"
278
278
  def a.foo(x = caller())
279
279
  x
@@ -281,14 +281,14 @@ describe "A singleton method defined with extreme default arguments" do
281
281
  a.foo.shift.should be_kind_of(String)
282
282
  end
283
283
 
284
- pending "evaluates the defaults in the singleton scope" do
284
+ it "evaluates the defaults in the singleton scope" do
285
285
  a = "hi"
286
286
  def a.foo(x = ($foo_self = self; nil)); 5 ;end
287
287
  a.foo
288
288
  $foo_self.should == a
289
289
  end
290
290
 
291
- pending "may use preceding arguments as defaults" do
291
+ it "may use preceding arguments as defaults" do
292
292
  a = 'hi'
293
293
  def a.foo(obj, width=obj.length)
294
294
  width
@@ -296,7 +296,7 @@ describe "A singleton method defined with extreme default arguments" do
296
296
  a.foo('abcde').should == 5
297
297
  end
298
298
 
299
- pending "may use a lambda as a default" do
299
+ it "may use a lambda as a default" do
300
300
  a = 'hi'
301
301
  def a.foo(output = 'a', prc = lambda {|n| output * n})
302
302
  prc.call(5)
@@ -306,7 +306,7 @@ describe "A singleton method defined with extreme default arguments" do
306
306
  end
307
307
 
308
308
  describe "A method definition inside a metaclass scope" do
309
- pending "can create a class method" do
309
+ it "can create a class method" do
310
310
  class DefSpecSingleton
311
311
  class << self
312
312
  def a_class_method;self;end
@@ -339,7 +339,7 @@ describe "A method definition inside a metaclass scope" do
339
339
  end
340
340
 
341
341
  ruby_version_is "1.9" do
342
- pending "raises RuntimeError if frozen" do
342
+ it "raises RuntimeError if frozen" do
343
343
  obj = Object.new
344
344
  obj.freeze
345
345
 
@@ -351,7 +351,7 @@ describe "A method definition inside a metaclass scope" do
351
351
  end
352
352
 
353
353
  describe "A nested method definition" do
354
- pending "creates an instance method when evaluated in an instance method" do
354
+ it "creates an instance method when evaluated in an instance method" do
355
355
  class DefSpecNested
356
356
  def create_instance_method
357
357
  def an_instance_method;self;end
@@ -369,7 +369,7 @@ describe "A nested method definition" do
369
369
  DefSpecNested.should have_instance_method(:an_instance_method)
370
370
  end
371
371
 
372
- pending "creates a class method when evaluated in a class method" do
372
+ it "creates a class method when evaluated in a class method" do
373
373
  class DefSpecNested
374
374
  class << self
375
375
  def create_class_method
@@ -386,7 +386,7 @@ describe "A nested method definition" do
386
386
  lambda { DefSpecNested.new.a_class_method }.should raise_error(NoMethodError)
387
387
  end
388
388
 
389
- pending "creates a singleton method when evaluated in the metaclass of an instance" do
389
+ it "creates a singleton method when evaluated in the metaclass of an instance" do
390
390
  class DefSpecNested
391
391
  def create_singleton_method
392
392
  class << self
@@ -430,7 +430,7 @@ describe "A method definition inside an instance_eval" do
430
430
  lambda { other.a_metaclass_eval_method }.should raise_error(NoMethodError)
431
431
  end
432
432
 
433
- pending "creates a class method when the receiver is a class" do
433
+ it "creates a class method when the receiver is a class" do
434
434
  DefSpecNested.instance_eval do
435
435
  def an_instance_eval_class_method;self;end
436
436
  end
@@ -441,7 +441,7 @@ describe "A method definition inside an instance_eval" do
441
441
  end
442
442
 
443
443
  describe "A method definition in an eval" do
444
- pending "creates an instance method" do
444
+ it "creates an instance method" do
445
445
  class DefSpecNested
446
446
  def eval_instance_method
447
447
  eval "def an_eval_instance_method;self;end", binding
@@ -459,7 +459,7 @@ describe "A method definition in an eval" do
459
459
  lambda { Object.new.an_eval_instance_method }.should raise_error(NoMethodError)
460
460
  end
461
461
 
462
- pending "creates a class method" do
462
+ it "creates a class method" do
463
463
  class DefSpecNestedB
464
464
  class << self
465
465
  def eval_class_method
@@ -476,7 +476,7 @@ describe "A method definition in an eval" do
476
476
  lambda { DefSpecNestedB.new.an_eval_class_method}.should raise_error(NoMethodError)
477
477
  end
478
478
 
479
- pending "creates a singleton method" do
479
+ it "creates a singleton method" do
480
480
  class DefSpecNested
481
481
  def eval_singleton_method
482
482
  class << self
@@ -499,7 +499,7 @@ describe "a method definition that sets more than one default parameter all to t
499
499
  def foo(a=b=c={})
500
500
  [a,b,c]
501
501
  end
502
- pending "assigns them all the same object by default" do
502
+ it "assigns them all the same object by default" do
503
503
  foo.should == [{},{},{}]
504
504
  a, b, c = foo
505
505
  a.should eql(b)
@@ -516,7 +516,7 @@ describe "a method definition that sets more than one default parameter all to t
516
516
  a.should_not equal(d)
517
517
  end
518
518
 
519
- pending "only allows overriding the default value of the first such parameter in each set" do
519
+ it "only allows overriding the default value of the first such parameter in each set" do
520
520
  lambda { foo(1,2) }.should raise_error(ArgumentError)
521
521
  end
522
522
 
@@ -524,7 +524,7 @@ describe "a method definition that sets more than one default parameter all to t
524
524
  [a,b,c,d]
525
525
  end
526
526
 
527
- pending "treats the argument after the multi-parameter normally" do
527
+ it "treats the argument after the multi-parameter normally" do
528
528
  bar.should == [1,1,1,2]
529
529
  bar(3).should == [3,nil,nil,2]
530
530
  bar(3,4).should == [3,nil,nil,4]
@@ -534,7 +534,7 @@ end
534
534
 
535
535
  describe "The def keyword" do
536
536
  describe "within a closure" do
537
- pending "looks outside the closure for the visibility" do
537
+ it "looks outside the closure for the visibility" do
538
538
  module DefSpecsLambdaVisibility
539
539
  private
540
540
 
@@ -45,11 +45,11 @@ describe "The defined? keyword when called with a method name" do
45
45
  defined?(Kernel.puts).should == "method"
46
46
  end
47
47
 
48
- pending "returns nil if the method is private" do
48
+ it "returns nil if the method is private" do
49
49
  defined?(Object.print).should be_nil
50
50
  end
51
51
 
52
- pending "returns nil if the method is protected" do
52
+ it "returns nil if the method is protected" do
53
53
  defined?(DefinedSpecs::Basic.new.protected_method).should be_nil
54
54
  end
55
55
 
@@ -36,7 +36,7 @@ describe "An ensure block inside a begin block" do
36
36
  end
37
37
  end
38
38
 
39
- pending "is executed even when a symbol is thrown in it's corresponding begin block" do
39
+ it "is executed even when a symbol is thrown in it's corresponding begin block" do
40
40
  begin
41
41
  catch(:symbol) do
42
42
  begin
@@ -89,7 +89,7 @@ describe "An ensure block inside a method" do
89
89
  @obj.executed.should == [:method, :rescue, :ensure]
90
90
  end
91
91
 
92
- pending "is executed even when a symbol is thrown in the method" do
92
+ it "is executed even when a symbol is thrown in the method" do
93
93
  catch(:symbol) { @obj.throw_in_method_with_ensure }
94
94
  @obj.executed.should == [:method, :ensure]
95
95
  end