Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c6d34fe0afd4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 09bf597181fa
Choose a head ref
  • 2 commits
  • 134 files changed
  • 1 contributor

Commits on Jun 5, 2015

  1. Squashed 'spec/ruby/' changes from 71ff5e4..ee9abb8

    ee9abb8 Fix spec title for a Module#name spec.
    aa55755 Add spec for Enumerator.new form calling bare each.
    f2d4242 Exclude the Europe/Lisbon time zone change on OS X as it seems inaccurate.
    b0a5ebc Fix syntax for Ruby 2.0 version for Travis.
    402e570 Require at least 2.0.0p598 on Travis.
    b5fa5d3 Use a consistent style for literal arrays in Array#concat spec.
    8f8fb81 rb_sym2str() is 2.2-only.
    0e7a261 Fix core specs for 2.0.0p643.
    92a1506 Fix file name for Process::Status#&.
    1c55da4 Fix guard for keyword argument spec.
    3b9ac9b Do not speculate on identity of keyword-like argument hashes.
    b633b06 Adding missing require for FileUtils.
    5531d57 Reintroduce Number arg specs for Regexp.new
    1574a22 use already defined methods from the fixture class
    c265a11 implement specs for comparing a method defined via define_method and a method defined via def
    8448314 ported over jruby's fix for Proc#curry, this closes #2951
    914090e Removed timeout from Process.detach specs.
    f7500c2 Added spec for Array#concat with shifted start.
    31a833f Added stdarg.h include to ruby.h.
    92d81b7 Added C-API specs for rb_vsprintf.
    873b7aa Added RHASH_SET_IFNONE/rb_hash_set_ifnone
    8a49b9c Added rb_sym2str()
    bcb70e2 Added rb_hash_lookup2()
    fb2bf67 Add specs for cases where timezone used was changed.
    7bc8c1b Fixed testing Symbol is a valid constant.
    ddd1f8f Add failing spec for prepended module method aliasing.
    5d3ce50 Fix Module#public_instance_method for prepended modules.
    fcacf19 Use consistent style in prepend specs.
    76682f4 Add specs for prepended module method ownership (one failing).
    9006ddb Ruby spec for multibyte constant names
    104176f Add specs for #3360 (case-when with splatted arrays from variables).
    48a30a6 Update Proc#curry specs to include 0-ary lambdas
    e0c9464 Updated String#sub/sub! specs for ArgumentError
    f3ed63e Enumerator#size specs for Enumerator
    0230e29 Enumerator#size specs for Struct
    e8cce95 Enumerator#size specs for IO
    47a6d4a Enumerator#size specs for ENV
    1d24cd9 Specs for Enumerator#size for Dir
    459dd14 Specs for Enumerator#size for ARGF
    e09c1d6 Updated Enumerator#size specs for String
    561f896 Enumerator#size specs for Numeric#step.
    3683eff Enumerator#size specs for Kernel#loop.
    7f290d1 Update Enumerator#size specs for Integer
    9c9a9ab Enumerator#size calculation specs for Range
    d3eec29 Enumerator#size calculation specs for Hash
    b1c468d New Enumerator#size tests for the Array class.
    c9719f1 New Enumerator/Enumerable size calculation tests
    61b9654 Extra arg validation tests on each_cons/each_slice
    3f4351a Creates enumeratorized shared specs.
    585fe5c Remove special case logic for String#slice(<Symbol>) It is okay to remove this special-case logic here because Symbol#to_int no longer exists in Ruby 1.9+, so Symbol-to-Fixnum coercion will fail with TypeError (which matches MRI behavior). Resolves #3335.
    a038ec6 refactored Marshal.load specs and updated CI tags
    3a7876b Added new Marshal.load spec for object with user-defined _dump
    fc96758 Added more Marshal.load specs for objects with user-defined _dumps
    b1b521a Fix Array#slice! with length argument for single item arrays
    123f35c Add Array#slice! positive length check and spec
    c811934 Spec for calling top-level methods in wrapped load
    579dc2c Updates spec name.
    6079006 Adds specs to Array methods that return an Enumerator. The tests check if the size method on the resulting Enumerator instance returns the correct value.
    bb14c39 Adds specs to Enumerable methods that return an Enumerator. The tests check if the size method on the resulting Enumerator instance returns the correct value.
    ebf235b Adds NumerousWithSize class to help spec the size method behaviour on Enumerable methods that return an Enumerator.
    6414afe Removing each_with_index changes to go into a separate pull request
    15322d2 Updating spec name and method name per code review
    894171d Fix Fixnum minus Bignum to not assume the result is a Bignum. Resolves #3316
    80748d9 Trying to fix each_slice and each_with_index
    9dbff60 Added spec for simple Object#inspect result.
    f227519 Added spec for Kernel#inspect.
    50005d2 Failing spec for String#encode with Emacs-Mule.
    f6ffd5f Added spec for a = b = m 1. Closes #3266.
    c8b23e5 Fixed Enumerable#flat_map specs.
    282810a Added C-API spec for rb_iv_{set, get} with non-ivar name.
    9d4866c Basic specs for optional variable assignments.
    1adf79a Nuke NetBeans config files.
    fba96b3 More specs for String#ascii_only? + String#replace
    a214db3 Add failing spec for distinguishing between a vcall and method when missing. (Missing method => NoMethodError, missing vcall => NameError) Demonstrates issue #3101.
    f538eb5 Re-removed obsoleted specs.
    e6d17ea Added specs for String#scrub with ASCII/BINARY.
    657dcdf Added more keyword specs.
    f629e3f Added spawn specs for STD{IN, OUT, ERR}.
    b4121d8 Add flat_map spec for enumerables that yield multiple values
    0edd4ca Adding a missing 'should'
    caf25d4 Rely on data file instead of signal file and always write to it.
    bcf1fe2 Stop waiting for the daemon as soon as we see the signal file.
    
    git-subtree-dir: spec/ruby
    git-subtree-split: ee9abb86f494bb0aac0d1cb6300e48c82c1d087c
    eregon committed Jun 5, 2015
    Copy the full SHA
    9a66b35 View commit details
  2. Copy the full SHA
    09bf597 View commit details
Showing with 1,839 additions and 300 deletions.
  1. +2 −2 spec/ruby/.travis.yml
  2. +23 −0 spec/ruby/core/argf/shared/each_byte.rb
  3. +23 −0 spec/ruby/core/argf/shared/each_char.rb
  4. +18 −0 spec/ruby/core/argf/shared/each_codepoint.rb
  5. +18 −6 spec/ruby/core/argf/shared/each_line.rb
  6. +3 −0 spec/ruby/core/array/bsearch_spec.rb
  7. +21 −0 spec/ruby/core/array/combination_spec.rb
  8. +13 −0 spec/ruby/core/array/concat_spec.rb
  9. +7 −0 spec/ruby/core/array/cycle_spec.rb
  10. +3 −0 spec/ruby/core/array/delete_if_spec.rb
  11. +2 −0 spec/ruby/core/array/each_index_spec.rb
  12. +2 −0 spec/ruby/core/array/each_spec.rb
  13. +29 −0 spec/ruby/core/array/permutation_spec.rb
  14. +3 −0 spec/ruby/core/array/reject_spec.rb
  15. +27 −0 spec/ruby/core/array/repeated_combination_spec.rb
  16. +24 −0 spec/ruby/core/array/repeated_permutation_spec.rb
  17. +6 −0 spec/ruby/core/array/reverse_each_spec.rb
  18. +3 −0 spec/ruby/core/array/rindex_spec.rb
  19. +2 −0 spec/ruby/core/array/select_spec.rb
  20. +12 −0 spec/ruby/core/array/shared/collect.rb
  21. +7 −0 spec/ruby/core/array/shared/keep_if.rb
  22. +11 −0 spec/ruby/core/array/slice_spec.rb
  23. +3 −0 spec/ruby/core/array/sort_by_spec.rb
  24. +1 −1 spec/ruby/core/array/transpose_spec.rb
  25. +13 −3 spec/ruby/core/dir/each_spec.rb
  26. +15 −0 spec/ruby/core/dir/foreach_spec.rb
  27. +6 −0 spec/ruby/core/enumerable/chunk_spec.rb
  28. +18 −0 spec/ruby/core/enumerable/cycle_spec.rb
  29. +3 −0 spec/ruby/core/enumerable/drop_while_spec.rb
  30. +42 −6 spec/ruby/core/enumerable/each_cons_spec.rb
  31. +3 −0 spec/ruby/core/enumerable/each_entry_spec.rb
  32. +43 −0 spec/ruby/core/enumerable/each_slice_spec.rb
  33. +3 −0 spec/ruby/core/enumerable/each_with_index_spec.rb
  34. +6 −0 spec/ruby/core/enumerable/each_with_object_spec.rb
  35. +3 −0 spec/ruby/core/enumerable/find_index_spec.rb
  36. +15 −0 spec/ruby/core/enumerable/fixtures/classes.rb
  37. +3 −0 spec/ruby/core/enumerable/group_by_spec.rb
  38. +3 −0 spec/ruby/core/enumerable/max_by_spec.rb
  39. +3 −0 spec/ruby/core/enumerable/min_by_spec.rb
  40. +3 −0 spec/ruby/core/enumerable/minmax_by_spec.rb
  41. +3 −0 spec/ruby/core/enumerable/partition_spec.rb
  42. +3 −0 spec/ruby/core/enumerable/reject_spec.rb
  43. +3 −0 spec/ruby/core/enumerable/reverse_each_spec.rb
  44. +4 −0 spec/ruby/core/enumerable/shared/collect.rb
  45. +39 −12 spec/ruby/core/enumerable/shared/collect_concat.rb
  46. +33 −0 spec/ruby/core/enumerable/shared/enumerable_enumeratorized.rb
  47. +42 −0 spec/ruby/core/enumerable/shared/enumeratorized.rb
  48. +3 −0 spec/ruby/core/enumerable/shared/find.rb
  49. +4 −0 spec/ruby/core/enumerable/shared/find_all.rb
  50. +6 −0 spec/ruby/core/enumerable/slice_before_spec.rb
  51. +3 −0 spec/ruby/core/enumerable/sort_by_spec.rb
  52. +3 −0 spec/ruby/core/enumerable/take_while_spec.rb
  53. +9 −0 spec/ruby/core/enumerator/each_with_index_spec.rb
  54. +9 −0 spec/ruby/core/enumerator/with_index_spec.rb
  55. +3 −0 spec/ruby/core/env/delete_if_spec.rb
  56. +3 −0 spec/ruby/core/env/each_key_spec.rb
  57. +3 −0 spec/ruby/core/env/each_value_spec.rb
  58. +3 −0 spec/ruby/core/env/keep_if_spec.rb
  59. +5 −0 spec/ruby/core/env/reject_spec.rb
  60. +5 −0 spec/ruby/core/env/select_spec.rb
  61. +7 −0 spec/ruby/core/env/shared/each.rb
  62. +8 −0 spec/ruby/core/fixnum/minus_spec.rb
  63. +2 −0 spec/ruby/core/hash/delete_if_spec.rb
  64. +2 −0 spec/ruby/core/hash/each_key_spec.rb
  65. +2 −0 spec/ruby/core/hash/each_pair_spec.rb
  66. +2 −0 spec/ruby/core/hash/each_spec.rb
  67. +2 −0 spec/ruby/core/hash/each_value_spec.rb
  68. +2 −0 spec/ruby/core/hash/keep_if_spec.rb
  69. +3 −0 spec/ruby/core/hash/reject_spec.rb
  70. +3 −0 spec/ruby/core/hash/select_spec.rb
  71. +32 −5 spec/ruby/core/integer/downto_spec.rb
  72. +12 −0 spec/ruby/core/integer/times_spec.rb
  73. +32 −5 spec/ruby/core/integer/upto_spec.rb
  74. +14 −4 spec/ruby/core/io/each_byte_spec.rb
  75. +13 −3 spec/ruby/core/io/foreach_spec.rb
  76. +14 −0 spec/ruby/core/io/lines_spec.rb
  77. +14 −4 spec/ruby/core/io/shared/chars.rb
  78. +12 −2 spec/ruby/core/io/shared/codepoints.rb
  79. +16 −6 spec/ruby/core/io/shared/each.rb
  80. +15 −0 spec/ruby/core/kernel/inspect_spec.rb
  81. +10 −0 spec/ruby/core/kernel/loop_spec.rb
  82. +33 −5 spec/ruby/core/kernel/shared/load.rb
  83. +85 −52 spec/ruby/core/marshal/shared/load.rb
  84. +8 −0 spec/ruby/core/method/shared/eql.rb
  85. +12 −0 spec/ruby/core/module/const_defined_spec.rb
  86. +19 −0 spec/ruby/core/module/prepend_spec.rb
  87. +101 −0 spec/ruby/core/numeric/step_spec.rb
  88. +11 −0 spec/ruby/core/proc/curry_spec.rb
  89. +3 −3 spec/ruby/core/process/daemon_spec.rb
  90. +6 −8 spec/ruby/core/process/detach_spec.rb
  91. +3 −11 spec/ruby/core/process/fixtures/common.rb
  92. +3 −3 spec/ruby/core/process/fixtures/daemon.rb
  93. 0 spec/ruby/core/process/status/{_spec.rb → bit_and_spec.rb}
  94. +3 −0 spec/ruby/core/range/bsearch_spec.rb
  95. +3 −0 spec/ruby/core/range/each_spec.rb
  96. +83 −0 spec/ruby/core/range/step_spec.rb
  97. +12 −0 spec/ruby/core/regexp/new_spec.rb
  98. +11 −1 spec/ruby/core/string/ascii_only_spec.rb
  99. +22 −4 spec/ruby/core/string/each_byte_spec.rb
  100. +4 −0 spec/ruby/core/string/element_reference_spec.rb
  101. +32 −0 spec/ruby/core/string/gsub_spec.rb
  102. +12 −0 spec/ruby/core/string/scrub_spec.rb
  103. +22 −4 spec/ruby/core/string/shared/each_char_without_block.rb
  104. +31 −7 spec/ruby/core/string/shared/each_codepoint_without_block.rb
  105. +14 −4 spec/ruby/core/string/shared/each_line_without_block.rb
  106. +8 −0 spec/ruby/core/string/shared/encode.rb
  107. +6 −0 spec/ruby/core/string/shared/slice.rb
  108. +4 −0 spec/ruby/core/string/slice_spec.rb
  109. +12 −0 spec/ruby/core/string/sub_spec.rb
  110. +16 −6 spec/ruby/core/string/upto_spec.rb
  111. +2 −0 spec/ruby/core/struct/each_pair_spec.rb
  112. +2 −0 spec/ruby/core/struct/each_spec.rb
  113. +2 −0 spec/ruby/core/struct/select_spec.rb
  114. +25 −0 spec/ruby/core/time/shared/local.rb
  115. +9 −0 spec/ruby/fixtures/code/load_wrap_method_fixture.rb
  116. +4 −0 spec/ruby/fixtures/constants.rb
  117. +26 −3 spec/ruby/language/block_spec.rb
  118. +41 −0 spec/ruby/language/case_spec.rb
  119. +50 −0 spec/ruby/language/method_spec.rb
  120. +39 −0 spec/ruby/language/optional_assignments_spec.rb
  121. +14 −5 spec/ruby/language/send_spec.rb
  122. +0 −60 spec/ruby/language/versions/def_2.0_spec.rb
  123. +0 −15 spec/ruby/nbproject/project.properties
  124. +0 −18 spec/ruby/nbproject/project.xml
  125. +20 −0 spec/ruby/optional/capi/ext/hash_spec.c
  126. +8 −0 spec/ruby/optional/capi/ext/rubyspec.h
  127. +22 −0 spec/ruby/optional/capi/ext/string_spec.c
  128. +10 −0 spec/ruby/optional/capi/ext/symbol_spec.c
  129. +26 −0 spec/ruby/optional/capi/hash_spec.rb
  130. +6 −0 spec/ruby/optional/capi/object_spec.rb
  131. +1 −0 spec/ruby/optional/capi/spec_helper.rb
  132. +7 −0 spec/ruby/optional/capi/string_spec.rb
  133. +8 −0 spec/ruby/optional/capi/symbol_spec.rb
  134. +90 −32 spec/ruby/shared/process/spawn.rb
4 changes: 2 additions & 2 deletions spec/ruby/.travis.yml
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ os:
- linux
- osx
rvm:
- 2.0.0
- 2.1
- 2.0.0-p598
- 2.1.5
- 2.2.2
- ruby-head
script:
23 changes: 23 additions & 0 deletions spec/ruby/core/argf/shared/each_byte.rb
Original file line number Diff line number Diff line change
@@ -36,4 +36,27 @@
bytes.should == @bytes
end
end

describe "when no block is given" do
it "returns an Enumerator" do
argv [@file1_name, @file2_name] do
enum = ARGF.send(@method)
enum.should be_an_instance_of(enumerator_class)

bytes = []
enum.each { |b| bytes << b }
bytes.should == @bytes
end
end

describe "returned Enumerator" do
describe "size" do
it "should return nil" do
argv [@file1_name, @file2_name] do
ARGF.send(@method).size.should == nil
end
end
end
end
end
end
23 changes: 23 additions & 0 deletions spec/ruby/core/argf/shared/each_char.rb
Original file line number Diff line number Diff line change
@@ -36,4 +36,27 @@
chars.should == @chars
end
end

describe "when no block is given" do
it "returns an Enumerator" do
argv [@file1_name, @file2_name] do
enum = ARGF.send(@method)
enum.should be_an_instance_of(enumerator_class)

chars = []
enum.each { |c| chars << c }
chars.should == @chars
end
end

describe "returned Enumerator" do
describe "size" do
it "should return nil" do
argv [@file1_name, @file2_name] do
ARGF.send(@method).size.should == nil
end
end
end
end
end
end
18 changes: 18 additions & 0 deletions spec/ruby/core/argf/shared/each_codepoint.rb
Original file line number Diff line number Diff line change
@@ -41,4 +41,22 @@
ARGF.send(@method).to_a.should == @codepoints
end
end

describe "when no block is given" do
it "returns an Enumerator" do
argv @filenames do
ARGF.send(@method).should be_an_instance_of(enumerator_class)
end
end

describe "returned Enumerator" do
describe "size" do
it "should return nil" do
argv @filenames do
ARGF.send(@method).size.should == nil
end
end
end
end
end
end
24 changes: 18 additions & 6 deletions spec/ruby/core/argf/shared/each_line.rb
Original file line number Diff line number Diff line change
@@ -37,12 +37,6 @@
end
end

it "returns an Enumerator when passed no block" do
argv [@file1_name, @file2_name] do
ARGF.send(@method).should be_an_instance_of(enumerator_class)
end
end

describe "with a separator" do
it "yields each separated section of all streams" do
argv [@file1_name, @file2_name] do
@@ -51,4 +45,22 @@
end
end
end

describe "when no block is given" do
it "returns an Enumerator" do
argv [@file1_name, @file2_name] do
ARGF.send(@method).should be_an_instance_of(enumerator_class)
end
end

describe "returned Enumerator" do
describe "size" do
it "should return nil" do
argv [@file1_name, @file2_name] do
ARGF.send(@method).size.should == nil
end
end
end
end
end
end
3 changes: 3 additions & 0 deletions spec/ruby/core/array/bsearch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

describe "Array#bsearch" do
it "returns an Enumerator when not passed a block" do
[1].bsearch.should be_an_instance_of(enumerator_class)
end

it_behaves_like :enumeratorized_with_unknown_size, :bsearch, [1,2,3]

it "raises a TypeError if the block returns an Object" do
lambda { [1].bsearch { Object.new } }.should raise_error(TypeError)
end
21 changes: 21 additions & 0 deletions spec/ruby/core/array/combination_spec.rb
Original file line number Diff line number Diff line change
@@ -50,4 +50,25 @@
end
accum.should == [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]
end

describe "when no block is given" do
describe "returned Enumerator" do
describe "size" do
it "returns 0 when the number of combinations is < 0" do
@array.combination(-1).size.should == 0
[].combination(-2).size.should == 0
end
it "returns the binomial coeficient between the array size the number of combinations" do
@array.combination(5).size.should == 0
@array.combination(4).size.should == 1
@array.combination(3).size.should == 4
@array.combination(2).size.should == 6
@array.combination(1).size.should == 4
@array.combination(0).size.should == 1
[].combination(0).size.should == 1
[].combination(1).size.should == 0
end
end
end
end
end
13 changes: 13 additions & 0 deletions spec/ruby/core/array/concat_spec.rb
Original file line number Diff line number Diff line change
@@ -96,4 +96,17 @@
ary[2].untrusted?.should be_true
ary[3].untrusted?.should be_false
end

it "appends elements to an Array with enough capacity that has been shifted" do
ary = [1, 2, 3, 4, 5]
2.times { ary.shift }
2.times { ary.pop }
ary.concat([5, 6]).should == [3, 5, 6]
end

it "appends elements to an Array without enough capacity that has been shifted" do
ary = [1, 2, 3, 4]
3.times { ary.shift }
ary.concat([5, 6]).should == [4, 5, 6]
end
end
7 changes: 7 additions & 0 deletions spec/ruby/core/array/cycle_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

describe "Array#cycle" do
before :each do
@@ -91,4 +92,10 @@
it "raises a TypeError if passed false" do
lambda { @array.cycle(false) { } }.should raise_error(TypeError)
end

before :all do
@object = [1, 2, 3, 4]
@empty_object = []
end
it_should_behave_like :enumeratorized_with_cycle_size
end
3 changes: 3 additions & 0 deletions spec/ruby/core/array/delete_if_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/enumeratorize', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

describe "Array#delete_if" do
before do
@@ -58,4 +59,6 @@
@a.delete_if{ true }
@a.untrusted?.should be_true
end

it_behaves_like :enumeratorized_with_origin_size, :delete_if, [1,2,3]
end
2 changes: 2 additions & 0 deletions spec/ruby/core/array/each_index_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/enumeratorize', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
@@ -37,4 +38,5 @@
end

it_behaves_like :enumeratorize, :each_index
it_behaves_like :enumeratorized_with_origin_size, :each_index, [1,2,3]
end
2 changes: 2 additions & 0 deletions spec/ruby/core/array/each_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/enumeratorize', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
@@ -27,4 +28,5 @@
end

it_behaves_like :enumeratorize, :each
it_behaves_like :enumeratorized_with_origin_size, :each, [1,2,3]
end
29 changes: 29 additions & 0 deletions spec/ruby/core/array/permutation_spec.rb
Original file line number Diff line number Diff line change
@@ -106,4 +106,33 @@

accum.should == [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
end

describe "when no block is given" do
describe "returned Enumerator" do
describe "size" do
describe "with an array size greater than 0" do
it "returns the descending factorial of array size and given length" do
@numbers.permutation(4).size.should == 0
@numbers.permutation(3).size.should == 6
@numbers.permutation(2).size.should == 6
@numbers.permutation(1).size.should == 3
@numbers.permutation(0).size.should == 1
end
it "returns the descending factorial of array size with array size when there's no param" do
@numbers.permutation.size.should == 6
[1,2,3,4].permutation.size.should == 24
[1].permutation.size.should == 1
end
end
describe "with an empty array" do
it "returns 1 when the given length is 0" do
[].permutation(0).size.should == 1
end
it "returns 1 when there's param" do
[].permutation.size.should == 1
end
end
end
end
end
end
3 changes: 3 additions & 0 deletions spec/ruby/core/array/reject_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/enumeratorize', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

describe "Array#reject" do
it "returns a new array without elements for which block is true" do
@@ -42,6 +43,7 @@
end

it_behaves_like :enumeratorize, :reject
it_behaves_like :enumeratorized_with_origin_size, :reject, [1,2,3]
end

describe "Array#reject!" do
@@ -109,4 +111,5 @@
end

it_behaves_like :enumeratorize, :reject!
it_behaves_like :enumeratorized_with_origin_size, :reject!, [1,2,3]
end
27 changes: 27 additions & 0 deletions spec/ruby/core/array/repeated_combination_spec.rb
Original file line number Diff line number Diff line change
@@ -54,4 +54,31 @@
end
accum.sort.should == [[10, 10], [10, 11], [10, 12], [11, 11], [11, 12], [12, 12]]
end

describe "when no block is given" do
describe "returned Enumerator" do
describe "size" do
it "returns 0 when the combination_size is < 0" do
@array.repeated_combination(-1).size.should == 0
[].repeated_combination(-2).size.should == 0
end

it "returns 1 when the combination_size is 0" do
@array.repeated_combination(0).size.should == 1
[].repeated_combination(0).size.should == 1
end

it "returns the binomial coeficient between combination_size and array size + combination_size -1" do
@array.repeated_combination(5).size.should == 21
@array.repeated_combination(4).size.should == 15
@array.repeated_combination(3).size.should == 10
@array.repeated_combination(2).size.should == 6
@array.repeated_combination(1).size.should == 3
@array.repeated_combination(0).size.should == 1
[].repeated_combination(0).size.should == 1
[].repeated_combination(1).size.should == 0
end
end
end
end
end
24 changes: 24 additions & 0 deletions spec/ruby/core/array/repeated_permutation_spec.rb
Original file line number Diff line number Diff line change
@@ -67,4 +67,28 @@
[1, 2, 2], [2, 1, 1], [2, 1, 2],
[2, 2, 1], [2, 2, 2]]
end

describe "when no block is given" do
describe "returned Enumerator" do
describe "size" do
it "returns 0 when combination_size is < 0" do
@numbers.repeated_permutation(-1).size.should == 0
[].repeated_permutation(-1).size.should == 0
end

it "returns array size ** combination_size" do
@numbers.repeated_permutation(4).size.should == 81
@numbers.repeated_permutation(3).size.should == 27
@numbers.repeated_permutation(2).size.should == 9
@numbers.repeated_permutation(1).size.should == 3
@numbers.repeated_permutation(0).size.should == 1
[].repeated_permutation(4).size.should == 0
[].repeated_permutation(3).size.should == 0
[].repeated_permutation(2).size.should == 0
[].repeated_permutation(1).size.should == 0
[].repeated_permutation(0).size.should == 1
end
end
end
end
end
6 changes: 6 additions & 0 deletions spec/ruby/core/array/reverse_each_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/enumeratorize', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
@@ -33,5 +34,10 @@
ScratchPad.recorded.should == [array, array, array, array, array, 3.0, 'two', 1]
end

it "returns the correct size when no block is given" do
[1, 2, 3].reverse_each.size.should == 3
end

it_behaves_like :enumeratorize, :reverse_each
it_behaves_like :enumeratorized_with_origin_size, :reverse_each, [1,2,3]
end
3 changes: 3 additions & 0 deletions spec/ruby/core/array/rindex_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)

# Modifying a collection while the contents are being iterated
# gives undefined behavior. See
@@ -72,4 +73,6 @@
enum.each { |x| x < 2 }.should == 4
end
end

it_behaves_like :enumeratorized_with_unknown_size, :bsearch, [1,2,3]
end
Loading