opal 0.3.2 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. data/README.md +85 -127
  2. data/bin/opal +3 -3
  3. data/lib/core.rb +114 -0
  4. data/{gems/core/lib → lib}/core/array.rb +68 -187
  5. data/{gems/core/lib → lib}/core/basic_object.rb +22 -5
  6. data/lib/core/class.rb +38 -0
  7. data/{gems/core/lib → lib}/core/dir.rb +1 -1
  8. data/lib/core/enumerable.rb +33 -0
  9. data/{gems/core/lib → lib}/core/error.rb +1 -4
  10. data/{gems/core/lib → lib}/core/false_class.rb +0 -0
  11. data/{gems/core/lib → lib}/core/file.rb +11 -3
  12. data/{gems/core/lib → lib}/core/hash.rb +12 -0
  13. data/{gems/core/lib → lib}/core/kernel.rb +114 -86
  14. data/lib/core/match_data.rb +33 -0
  15. data/lib/core/module.rb +97 -0
  16. data/{gems/core/lib → lib}/core/nil_class.rb +0 -0
  17. data/{gems/core/lib → lib}/core/numeric.rb +5 -0
  18. data/{gems/core/lib → lib}/core/object.rb +0 -0
  19. data/{gems/core/lib → lib}/core/proc.rb +13 -3
  20. data/{gems/core/lib → lib}/core/range.rb +10 -0
  21. data/{gems/core/lib → lib}/core/regexp.rb +33 -1
  22. data/{gems/core/lib → lib}/core/string.rb +25 -10
  23. data/{gems/core/lib → lib}/core/symbol.rb +3 -3
  24. data/{gems/core/lib → lib}/core/top_self.rb +0 -0
  25. data/{gems/core/lib → lib}/core/true_class.rb +0 -0
  26. data/lib/dev.rb +169 -0
  27. data/{gems/ospec/lib → lib}/ospec.rb +1 -0
  28. data/lib/ospec/autorun.rb +8 -0
  29. data/{gems/ospec/lib → lib}/ospec/dsl.rb +2 -2
  30. data/{gems/ospec/lib → lib}/ospec/example.rb +0 -0
  31. data/{gems/ospec/lib → lib}/ospec/example/before_and_after_hooks.rb +0 -0
  32. data/{gems/ospec/lib → lib}/ospec/example/errors.rb +0 -0
  33. data/{gems/ospec/lib → lib}/ospec/example/example_group.rb +0 -0
  34. data/{gems/ospec/lib → lib}/ospec/example/example_group_factory.rb +0 -3
  35. data/{gems/ospec/lib → lib}/ospec/example/example_group_hierarchy.rb +4 -3
  36. data/{gems/ospec/lib → lib}/ospec/example/example_group_methods.rb +1 -1
  37. data/{gems/ospec/lib → lib}/ospec/example/example_group_proxy.rb +3 -2
  38. data/{gems/ospec/lib → lib}/ospec/example/example_methods.rb +1 -1
  39. data/{gems/ospec/lib → lib}/ospec/example/example_proxy.rb +7 -7
  40. data/{gems/ospec/lib → lib}/ospec/expectations.rb +0 -0
  41. data/{gems/ospec/lib → lib}/ospec/expectations/errors.rb +0 -0
  42. data/{gems/ospec/lib → lib}/ospec/expectations/fail_with.rb +4 -3
  43. data/{gems/ospec/lib → lib}/ospec/expectations/handler.rb +6 -0
  44. data/lib/ospec/helpers/scratch.rb +18 -0
  45. data/{gems/ospec/lib → lib}/ospec/matchers.rb +2 -2
  46. data/{gems/ospec/lib → lib}/ospec/matchers/be.rb +0 -0
  47. data/{gems/ospec/lib → lib}/ospec/matchers/generated_descriptions.rb +0 -0
  48. data/{gems/ospec/lib → lib}/ospec/matchers/operator_matcher.rb +2 -0
  49. data/lib/ospec/matchers/raise_error.rb +38 -0
  50. data/lib/ospec/runner.rb +90 -0
  51. data/{gems/ospec/lib → lib}/ospec/runner/example_group_runner.rb +10 -13
  52. data/lib/ospec/runner/formatter/html_formatter.rb +139 -0
  53. data/{gems/ospec/lib → lib}/ospec/runner/formatter/terminal_formatter.rb +0 -0
  54. data/{gems/ospec/lib → lib}/ospec/runner/options.rb +1 -3
  55. data/{gems/ospec/lib → lib}/ospec/runner/reporter.rb +0 -9
  56. data/lib/racc/parser.rb +165 -0
  57. data/lib/strscan.rb +52 -0
  58. data/{lib → opal_lib}/opal.rb +2 -0
  59. data/opal_lib/opal/build_methods.rb +51 -0
  60. data/opal_lib/opal/builder.rb +164 -0
  61. data/opal_lib/opal/bundle.rb +70 -0
  62. data/opal_lib/opal/command.rb +68 -0
  63. data/{lib → opal_lib}/opal/context.rb +21 -9
  64. data/{lib → opal_lib}/opal/context/console.rb +0 -2
  65. data/opal_lib/opal/context/file_system.rb +34 -0
  66. data/{lib → opal_lib}/opal/context/loader.rb +26 -8
  67. data/opal_lib/opal/gem.rb +84 -0
  68. data/{lib → opal_lib}/opal/rake/builder_task.rb +2 -2
  69. data/opal_lib/opal/rake/spec_task.rb +32 -0
  70. data/{lib → opal_lib}/opal/ruby/nodes.rb +730 -109
  71. data/{lib → opal_lib}/opal/ruby/parser.rb +90 -23
  72. data/opal_lib/opal/ruby/ruby_parser.rb +4862 -0
  73. data/opal_lib/opal/ruby/ruby_parser.y +1454 -0
  74. data/opal_lib/opal/version.rb +4 -0
  75. data/runtime/class.js +359 -0
  76. data/runtime/debug.js +84 -0
  77. data/runtime/fs.js +199 -0
  78. data/runtime/init.js +558 -0
  79. data/runtime/loader.js +351 -0
  80. data/runtime/module.js +109 -0
  81. data/runtime/post.js +10 -0
  82. data/runtime/pre.js +7 -0
  83. data/runtime/runtime.js +351 -0
  84. metadata +88 -175
  85. data/.gitignore +0 -7
  86. data/Changelog +0 -31
  87. data/LICENSE +0 -75
  88. data/Rakefile +0 -86
  89. data/gems/core/README.md +0 -14
  90. data/gems/core/Rakefile +0 -8
  91. data/gems/core/core.gemspec +0 -13
  92. data/gems/core/lib/core.rb +0 -34
  93. data/gems/core/lib/core/class.rb +0 -31
  94. data/gems/core/lib/core/module.rb +0 -100
  95. data/gems/core/lib/core/vm.rb +0 -16
  96. data/gems/core/spec/core/array/append_spec.rb +0 -30
  97. data/gems/core/spec/core/array/assoc_spec.rb +0 -29
  98. data/gems/core/spec/core/array/at_spec.rb +0 -37
  99. data/gems/core/spec/core/array/clear_spec.rb +0 -22
  100. data/gems/core/spec/core/array/collect_bang_spec.rb +0 -27
  101. data/gems/core/spec/core/array/collect_spec.rb +0 -27
  102. data/gems/core/spec/core/array/compact_spec.rb +0 -41
  103. data/gems/core/spec/core/array/concat_spec.rb +0 -15
  104. data/gems/core/spec/core/array/constructor_spec.rb +0 -14
  105. data/gems/core/spec/core/array/each_spec.rb +0 -9
  106. data/gems/core/spec/core/array/element_reference_spec.rb +0 -4
  107. data/gems/core/spec/core/array/first_spec.rb +0 -35
  108. data/gems/core/spec/core/array/include_spec.rb +0 -9
  109. data/gems/core/spec/core/array/join_spec.rb +0 -6
  110. data/gems/core/spec/core/array/last_spec.rb +0 -51
  111. data/gems/core/spec/core/array/length_spec.rb +0 -6
  112. data/gems/core/spec/core/array/map_spec.rb +0 -33
  113. data/gems/core/spec/core/array/reverse_spec.rb +0 -6
  114. data/gems/core/spec/core/builtin_constants/builtin_constants_spec.rb +0 -7
  115. data/gems/core/spec/core/false/and_spec.rb +0 -10
  116. data/gems/core/spec/core/false/inspect_spec.rb +0 -6
  117. data/gems/core/spec/core/false/or_spec.rb +0 -10
  118. data/gems/core/spec/core/false/to_s_spec.rb +0 -6
  119. data/gems/core/spec/core/false/xor_spec.rb +0 -10
  120. data/gems/core/spec/core/file/join_spec.rb +0 -19
  121. data/gems/core/spec/core/hash/assoc_spec.rb +0 -32
  122. data/gems/core/spec/core/kernel/instance_eval_spec.rb +0 -0
  123. data/gems/core/spec/core/kernel/loop_spec.rb +0 -24
  124. data/gems/core/spec/core/kernel/raise_spec.rb +0 -0
  125. data/gems/core/spec/core/module/attr_accessor_spec.rb +0 -28
  126. data/gems/core/spec/core/number/lt_spec.rb +0 -12
  127. data/gems/core/spec/core/string/sub_spec.rb +0 -24
  128. data/gems/core/spec/core/true/and_spec.rb +0 -10
  129. data/gems/core/spec/core/true/inspect_spec.rb +0 -6
  130. data/gems/core/spec/core/true/or_spec.rb +0 -10
  131. data/gems/core/spec/core/true/to_s_spec.rb +0 -6
  132. data/gems/core/spec/core/true/xor_spec.rb +0 -10
  133. data/gems/core/spec/language/and_spec.rb +0 -61
  134. data/gems/core/spec/language/array_spec.rb +0 -68
  135. data/gems/core/spec/language/block_spec.rb +0 -38
  136. data/gems/core/spec/language/break_spec.rb +0 -36
  137. data/gems/core/spec/language/case_spec.rb +0 -103
  138. data/gems/core/spec/language/def_spec.rb +0 -21
  139. data/gems/core/spec/language/eigenclass_spec.rb +0 -60
  140. data/gems/core/spec/language/file_spec.rb +0 -13
  141. data/gems/core/spec/language/fixtures/block.rb +0 -21
  142. data/gems/core/spec/language/fixtures/super.rb +0 -293
  143. data/gems/core/spec/language/hash_spec.rb +0 -29
  144. data/gems/core/spec/language/if_spec.rb +0 -54
  145. data/gems/core/spec/language/loop_spec.rb +0 -11
  146. data/gems/core/spec/language/metaclass_spec.rb +0 -21
  147. data/gems/core/spec/language/method_spec.rb +0 -124
  148. data/gems/core/spec/language/next_spec.rb +0 -25
  149. data/gems/core/spec/language/or_spec.rb +0 -34
  150. data/gems/core/spec/language/redo_spec.rb +0 -24
  151. data/gems/core/spec/language/regexp_spec.rb +0 -26
  152. data/gems/core/spec/language/rescue_spec.rb +0 -20
  153. data/gems/core/spec/language/return_spec.rb +0 -47
  154. data/gems/core/spec/language/string_spec.rb +0 -25
  155. data/gems/core/spec/language/super_spec.rb +0 -32
  156. data/gems/core/spec/language/until_spec.rb +0 -157
  157. data/gems/core/spec/language/variables_spec.rb +0 -155
  158. data/gems/core/spec/language/while_spec.rb +0 -163
  159. data/gems/core/spec/spec_helper.rb +0 -5
  160. data/gems/core_fs/README.md +0 -19
  161. data/gems/dev/Rakefile +0 -5
  162. data/gems/dev/lib/dev.js +0 -99
  163. data/gems/dev/lib/dev/generator.js +0 -1264
  164. data/gems/dev/lib/dev/parser.js +0 -979
  165. data/gems/dev/lib/dev/ruby_parser.js +0 -1088
  166. data/gems/dev/lib/dev/ruby_parser.y +0 -1267
  167. data/gems/dev/lib/dev/string_scanner.js +0 -38
  168. data/gems/dev/tools/racc2js/README.md +0 -39
  169. data/gems/dev/tools/racc2js/math_parser.js +0 -222
  170. data/gems/dev/tools/racc2js/math_parser.rb +0 -133
  171. data/gems/dev/tools/racc2js/math_parser.y +0 -28
  172. data/gems/dev/tools/racc2js/parser.js +0 -218
  173. data/gems/dev/tools/racc2js/racc2js.rb +0 -153
  174. data/gems/json/README.md +0 -4
  175. data/gems/json/json.gemspec +0 -14
  176. data/gems/json/lib/json.rb +0 -64
  177. data/gems/json/lib/json/ext.rb +0 -51
  178. data/gems/json/lib/json/json2.js +0 -481
  179. data/gems/ospec/README.md +0 -0
  180. data/gems/ospec/lib/ospec/autorun.rb +0 -3
  181. data/gems/ospec/lib/ospec/runner.rb +0 -40
  182. data/gems/ospec/lib/ospec/runner/formatter/html_formatter.rb +0 -91
  183. data/gems/ospec/ospec.gemspec +0 -0
  184. data/gems/rquery/README.md +0 -9
  185. data/gems/rquery/lib/rquery.rb +0 -10
  186. data/gems/rquery/lib/rquery/ajax.rb +0 -4
  187. data/gems/rquery/lib/rquery/css.rb +0 -96
  188. data/gems/rquery/lib/rquery/document.rb +0 -25
  189. data/gems/rquery/lib/rquery/element.rb +0 -292
  190. data/gems/rquery/lib/rquery/event.rb +0 -108
  191. data/gems/rquery/lib/rquery/jquery.js +0 -8177
  192. data/gems/rquery/lib/rquery/request.rb +0 -138
  193. data/gems/rquery/lib/rquery/response.rb +0 -49
  194. data/gems/rquery/rquery.gemspec +0 -16
  195. data/lib/opal.js +0 -1597
  196. data/lib/opal/builder.rb +0 -117
  197. data/lib/opal/bundle.rb +0 -131
  198. data/lib/opal/command.rb +0 -11
  199. data/lib/opal/context/file_system.rb +0 -19
  200. data/lib/opal/gem.rb +0 -153
  201. data/lib/opal/ruby/ruby_parser.rb +0 -5170
  202. data/lib/opal/ruby/ruby_parser.y +0 -1298
  203. data/opal.gemspec +0 -15
@@ -1,29 +0,0 @@
1
-
2
- describe "Array#assoc" do
3
- it "returns the first array whose 1st item is == obj or nil" do
4
- s1 = ["colors", "red", "blue", "green"]
5
- s2 = [:letters, "a", "b", "c"]
6
- s3 = [4]
7
- s4 = ["colors", "cyan", "yellow", "magenda"]
8
- s5 = [:letters, "a", "i", "u"]
9
- s_nil = [nil, nil]
10
- a = [s1, s2, s3, s4, s5, s_nil]
11
- a.assoc(s1.first).should == s1
12
- a.assoc(s2.first).should == s2
13
- a.assoc(s3.first).should == s3
14
- a.assoc(s4.first).should == s1
15
- a.assoc(s5.first).should == s2
16
- a.assoc(s_nil.first).should == s_nil
17
- a.assoc(4).should == s3
18
- a.assoc("key not in array").should == nil
19
- end
20
-
21
- it "ignores any non-Array elements" do
22
- [1, 2, 3].assoc(2).should == nil
23
- s1 = [4]
24
- s2 = [5, 4, 3]
25
- a = ["foo", [], s1, s2, nil, []]
26
- a.assoc(s1.first).should == s1
27
- a.assoc(s2.first).should == s2
28
- end
29
- end
@@ -1,37 +0,0 @@
1
-
2
- describe "Array#at" do
3
- it "returns the (n+1)'th element for the passed index n" do
4
- a = [1, 2, 3, 4, 5, 6]
5
- a.at(0).should == 1
6
- a.at(1).should == 2
7
- a.at(5).should == 6
8
- end
9
-
10
- it "returns nil if the given index is greater than or equal to the array's length" do
11
- a = [1, 2, 3, 4, 5, 6]
12
- a.at(6).should == nil
13
- a.at(7).should == nil
14
- end
15
-
16
- it "returns the (-n)'th element from the last, for the given negative index n" do
17
- a = [1, 2, 3, 4, 5, 6]
18
- a.at(-1).should == 6
19
- a.at(-2).should == 5
20
- a.at(-6).should == 1
21
- end
22
-
23
- it "returns nil if the given index is less than -len, where len is the length of the array" do
24
- a = [1, 2, 3, 4, 5, 6]
25
- a.at(-7).should == nil
26
- a.at(-8).should == nil
27
- end
28
-
29
- it "does not extend the array unless the given index is out of range" do
30
- a = [1, 2, 3, 4, 5, 6]
31
- a.length.should == 6
32
- a.at(100)
33
- a.length.should == 6
34
- a.at(-100)
35
- a.length.should == 6
36
- end
37
- end
@@ -1,22 +0,0 @@
1
-
2
- describe "Array#clear" do
3
- it "removes all elements" do
4
- a = [1, 2, 3, 4]
5
- a.clear
6
- # # a.clear.should == a
7
- a.should == []
8
- end
9
-
10
- it "returns self" do
11
- a = [1]
12
- oid = a.object_id
13
- a.clear.object_id.should == oid
14
- end
15
-
16
- it "leaves the Array empty" do
17
- a = [1]
18
- a.clear
19
- a.empty?.should == true
20
- a.size.should == 0
21
- end
22
- end
@@ -1,27 +0,0 @@
1
-
2
- describe "Array#collect!" do
3
- it "replaces each element with the value returned by block" do
4
- a = [7, 9, 3, 5]
5
- a.collect! { |i| i - 1 }
6
- a.should == [6, 8, 2, 4]
7
- end
8
-
9
- it "returns self" do
10
- a = [1, 2, 3, 4, 5]
11
- b = a.collect! { |i| i + 1 }
12
- a.object_id.should == b.object_id
13
- end
14
-
15
- it "returns the evaluated value of block but its contents is partially modified, if it broke in the block" do
16
- a = ['a', 'b', 'c', 'd']
17
- b = a.collect! do |i|
18
- if i == 'c'
19
- break 0
20
- else
21
- i + '!'
22
- end
23
- end
24
- b.should == 0
25
- a.should == ['a!', 'b!', 'c', 'd']
26
- end
27
- end
@@ -1,27 +0,0 @@
1
-
2
- describe "Array#collect" do
3
- it "returns a copy of array with each element replaced by the value returned by block" do
4
- a = ['a', 'b', 'c', 'd']
5
- b = a.collect { |i| i + '!'}
6
- b.should == ['a!', 'b!', 'c!', 'd!']
7
- # a.object_id.should_not == a.object_id
8
- end
9
-
10
- it "does not change self" do
11
- a = ['a', 'b', 'c', 'd']
12
- b = a.collect { |i| i + '!' }
13
- a.should == ['a', 'b', 'c', 'd']
14
- end
15
-
16
- it "returns the evaluated value of the block if it broke in the block" do
17
- a = ['a', 'b', 'c', 'd']
18
- b = a.collect do |i|
19
- if i == 'c'
20
- break 0
21
- else
22
- i + '!'
23
- end
24
- end
25
- b.should == 0
26
- end
27
- end
@@ -1,41 +0,0 @@
1
-
2
- describe "Array#compact" do
3
- it "returns a copy of array with all nil elements removed" do
4
- a = [1, 2, 4]
5
- a.compact.should == [1, 2, 4]
6
- a = [1, nil, 2, 4]
7
- a.compact.should == [1, 2, 4]
8
- a = [1, 2, 4, nil]
9
- a.compact.should == [1, 2, 4]
10
- a = [nil, 1, 2, 4]
11
- a.compact.should == [1, 2, 4]
12
- end
13
-
14
- it "does not return self" do
15
- a = [1, 2, 3]
16
- a.compact.object_id.should_not == a.object_id
17
- end
18
- end
19
-
20
- describe "Array#compact!" do
21
- it "removes all nil elements" do
22
- a = ['a', nil, 'b', false, 'c']
23
- a.compact!.object_id.should == a.object_id
24
- a.should == ['a', 'b', false, 'c']
25
- a = [nil, 'a', 'b', false, 'c']
26
- a.compact!.object_id.should == a.object_id
27
- a.should == ['a', 'b', false, 'c']
28
- a = ['a', 'b', false, 'c', nil]
29
- a.compact!.object_id.should == a.object_id
30
- a.should == ['a', 'b', false, 'c']
31
- end
32
-
33
- it "returns self if some nil elements are removed" do
34
- a = ['a', nil, 'b', false, 'c']
35
- a.compact!.object_id.should == a.object_id
36
- end
37
-
38
- it "returns nil if there are no nil elements to remove" do
39
- [1, 2, false, 3].compact!.should == nil
40
- end
41
- end
@@ -1,15 +0,0 @@
1
-
2
- describe "Array#concat" do
3
- it "appends the elements in the other array" do
4
- ary = [1, 2, 3]
5
- ary.concat([9, 10, 11])
6
- ary.should == [1, 2, 3, 9, 10, 11]
7
- ary.concat []
8
- ary.should == [1, 2, 3, 9, 10, 11]
9
- end
10
-
11
- it "does not loop endlessly when argument is self" do
12
- ary = ["x", "y"]
13
- ary.concat(ary).should == ["x", "y", "x", "y"]
14
- end
15
- end
@@ -1,14 +0,0 @@
1
-
2
- describe "Array.[]" do
3
- it "returns a new array populated with the given elements" do
4
- obj = Object.new
5
- Array.[](5, true, nil, 'a', "Ruby", obj).should == [5, true, nil, 'a', "Ruby", obj]
6
- end
7
- end
8
-
9
- describe "Array[]" do
10
- it "is a synonym for .[]" do
11
- obj = Object.new
12
- Array[5, true, nil, 'a', "Ruby", obj].should == [5, true, nil, 'a', "Ruby", obj]
13
- end
14
- end
@@ -1,9 +0,0 @@
1
-
2
- describe "Array#each" do
3
- it "yields each element to the block" do
4
- a = []
5
- x = [1, 2, 3]
6
- x.each { |item| a << item }.should == x
7
- a.should == [1, 2, 3]
8
- end
9
- end
@@ -1,4 +0,0 @@
1
-
2
- describe "Array#[]" do
3
-
4
- end
@@ -1,35 +0,0 @@
1
-
2
- describe "Array#first" do
3
- it "returns the first element" do
4
- # %W{a b c}.first.should == 'a'
5
- [nil].first.should == nil
6
- end
7
-
8
- it "returns nil if self is empty" do
9
- [].first.should == nil
10
- end
11
-
12
- it "returns the first count elements if given a count" do
13
- [true, false, true, nil, false].first(2).should == [true, false]
14
- end
15
-
16
- it "returns an empty array when passed count on an empty array" do
17
- [].first(0).should == []
18
- [].first(1).should == []
19
- [].first(2).should == []
20
- end
21
-
22
- it "returns an empty array when passed count == 0" do
23
- [1, 2, 3, 4, 5].first(0).should == []
24
- end
25
-
26
- it "returns an array containing the first element when passed count == 1" do
27
- [1, 2, 3, 4, 5].first(1).should == [1]
28
- end
29
-
30
- it "raises an argument error when count is negative"
31
-
32
- it "returns the entire array when count > length" do
33
- [1, 2, 3, 4, 5, 6, 7, 8, 9].first(10).should == [1, 2, 3, 4, 5, 6, 7, 8, 9]
34
- end
35
- end
@@ -1,9 +0,0 @@
1
-
2
- describe "Array#include?" do
3
- it "returns true if object is present, false otherwise" do
4
- [1, 2, "a", "b"].include?("c").should == false
5
- [1, 2, "a", "b"].include?("a").should == true
6
- end
7
-
8
- it "determines presence by using element == obj"
9
- end
@@ -1,6 +0,0 @@
1
- describe "Array#join" do
2
- it "returns an empty string if the Array is empty" do
3
- a = Array.new
4
- a.join(':').should == ""
5
- end
6
- end
@@ -1,51 +0,0 @@
1
-
2
- describe "Array#last" do
3
- it "returns the last element" do
4
- [1, 1, 1, 1, 2].last.should == 2
5
- end
6
-
7
- it "returns nil if self is empty" do
8
- [].last.should == nil
9
- end
10
-
11
- it "returns the last count elements if given a count" do
12
- [1, 2, 3, 4, 5, 9].last(3).should == [4, 5, 9]
13
- end
14
-
15
- it "returns an empty array when passeed a count on an empty array" do
16
- [].last(0).should == []
17
- [].last(1).should == []
18
- end
19
-
20
- it "returns an empty array when count == 0" do
21
- [1, 2, 3, 4, 5].last(0).should == []
22
- end
23
-
24
- it "returns an array containing the last element when passed count == 1" do
25
- [1, 2, 3, 4, 5].last(1).should == [5]
26
- end
27
-
28
- it "returns the entire array when count > length" do
29
- [1, 2, 3, 4, 5, 9].last(10).should == [1, 2, 3, 4, 5, 9]
30
- end
31
-
32
- it "returns an array which is independant to the original when passed count" do
33
- ary = [1, 2, 3, 4, 5]
34
- ary.last(0).replace([1, 2])
35
- ary.should == [1, 2, 3, 4, 5]
36
- ary.last(1).replace([1, 2])
37
- ary.should == [1, 2, 3, 4, 5]
38
- ary.last(6).replace([1, 2])
39
- ary.should == [1, 2, 3, 4, 5]
40
- end
41
-
42
- it "is not destructive" do
43
- a = [1, 2, 3]
44
- a.last
45
- a.should == [1, 2, 3]
46
- a.last(2)
47
- a.should == [1, 2, 3]
48
- a.last(3)
49
- a.should == [1, 2, 3]
50
- end
51
- end
@@ -1,6 +0,0 @@
1
- describe "Array#length" do
2
- it "returns the number of elements" do
3
- [].length.should == 0
4
- [1, 2, 3].length.should == 3
5
- end
6
- end
@@ -1,33 +0,0 @@
1
-
2
- describe "Array#map" do
3
- it "returns a copy of array with each element replaced by the value returned by block" do
4
- a = ['a', 'b', 'c', 'd']
5
- b = a.map { |i| i + '!' }
6
- b.should == ['a!', 'b!', 'c!', 'd!']
7
-
8
- # ignore
9
- # b.object_id.should_not == a.object_id
10
- end
11
-
12
- it "does not return subclass instance"
13
-
14
- it "does not change self" do
15
- a = ['a', 'b', 'c', 'd']
16
- b = a.map { |i| i + '!' }
17
- a.should == ['a', 'b', 'c', 'd']
18
- end
19
-
20
- it "returns the evaluated value of the block if it broke in the block" do
21
- a = ['a', 'b', 'c', 'd']
22
- b = a.map { |i|
23
- if i == 'c'
24
- break 0
25
- else
26
- i + '!'
27
- end
28
- }
29
- b.should == 0
30
- end
31
-
32
- it "returns an enumerator when no block given"
33
- end
@@ -1,6 +0,0 @@
1
- describe "Array#reverse" do
2
- it "returns a new array with the elements in reverse order" do
3
- [].reverse.should == []
4
- [1, 3, 5, 2].reverse.should == [2, 5, 3, 1]
5
- end
6
- end
@@ -1,7 +0,0 @@
1
-
2
- describe "RUBY_VERSION" do
3
-
4
- it "is a String" do
5
- # RUBY_VERSION.class.should == String
6
- end
7
- end
@@ -1,10 +0,0 @@
1
-
2
- describe "FalseClass#&" do
3
- it "returns false" do
4
- (false & false).should == false
5
- (false & true).should == false
6
- (false & nil).should == false
7
- (false & "").should == false
8
- (false & 'x').should == false
9
- end
10
- end
@@ -1,6 +0,0 @@
1
-
2
- describe "FalseClass#inspect" do
3
- it "returns the string 'false'" do
4
- false.inspect.should == "false"
5
- end
6
- end
@@ -1,10 +0,0 @@
1
-
2
- describe "FalseClass#|" do
3
- it "returns false if other is nil or false, otherwise true" do
4
- (false | false).should == false
5
- (false | true).should == true
6
- (false | nil).should == false
7
- (false | "").should == true
8
- (false | 'x').should == true
9
- end
10
- end