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: 0ac8eca75dd4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 51ef78b6b5c4
Choose a head ref
  • 2 commits
  • 164 files changed
  • 1 contributor

Commits on Feb 2, 2016

  1. Squashed 'spec/ruby/' changes from cfdf72f..d9a07bf

    d9a07bf Module#define_method behaved differently with visibility in 2.0.0
    38fdfa7 Module#prepend is private in 2.0.0
    09374e5 New spec for visibility with Module#define_method and UnboundMethod
    bc87a91 Fix UnboundMethod#owner specs to actually use UnboundMethod.
    05f25e3 Fix spec description in Method#owner.
    5a39e5a Add spec for prepend in the presence of define_method super.
    42f6a39 Add example for SizedQueue#num_waiting
    f27b277 Clearer name in class_variable_get spec
    10a5eb4 Spec for U with malformed UTF-8 sequences.
    ce8d46b Show the command when linking fails
    25f9b87 Get rid of all "should_not raise_error" in language specs
    6dba10a Better way to check the exact error class
    a2e628f Fix bad expectation
    fa031c0 Merge pull request #184 from phluid61/20160120-float-0x1p1
    8bd00d6 add descriptive wrapper and tests for base case
    cdd29a8 add tests for Float('0x1p1') and Float('0x1P1')
    162df6a Add --disable-gems to support icc
    a90ecb2 Fix Float::EPSILON spec
    d8d81ef Cut to a decent amount of precision for Float::MIN and MAX
    01278ce Float::MIN is 2.2250738585072e-308 in Ruby
    253a399 Unify Bignum#size spec
    774563a Fix typo
    9011723 Use 1.9-style for Hash literals
    102bf17 It seems #eval can be aliased on multiple implementations
    a9a24cd Remove deviates_on behaving as the compliant specs
    d0b5223 Replace hash_class by Hash
    c7ca97d Use Hash literals instead of the new_hash helper
    d4483ff Fix year in the history section
    75ec48b Try to clarify what it is and what it is not
    fec9f62 Fix wording in the history section
    ad889cc Fix reference in C extension specs header
    179f605 rb_str_len is not public API
    6536b8b Remove old and unused version file
    976c99a Fix a typo
    dd6b920 Fix references in CONTRIBUTING
    35f18ac Add a section about the history and RubySpec
    09adfe9 Fix a few more names in the README
    217fbbe Update README to reflect the new name
    878ed3e Fix URLs to point the new repo name.
    70b1140 Spec the default values of IO#sync for standard streams.
    7753d2f Reorder Zlib deflate specs
    76488f6 Fix warning in Zlib deflate spec
    763d9ea Add specs for streaming in inflate processing
    f484f34 Solaris 10 on x86 wrongly returns ai_pprotocol as 0
    a5c0605 Remove bad spec
    8b118fd Specify new behavior for Enumerable{chunk,slice_before}
    5885e2b Initial spec for Queue#close and Queue#closed?
    ba17b3d Spec for the new behavior of Kernel#loop
    f59a862 No silent rescue in Comparable#<=> is now released behavior in 2.3
    9a20b87 Treat paths with unicode characters as binary to avoid depending on the locale.
    5ab735b Merge pull request #180 from ruby/string-split
    0d2c110 Add more String#split examples
    68159c3 Skip filesystem encoding dependent spec
    fe83324 Remove old guarded spec, implementations should be allowed to do either.
    0db9d4a  Fix IO#write_nonblock spec under 2.0
    40957a3 Fix IO#read_nonblock spec under 2.0
    fc0d729 Add a spec covering calling #instance_eval with a proc from a method
    e32825a Added specs for RARRAY_AREF.
    997fc93 Added spec for IO#write_nonblock raising
    45dcbd1 Test IO#read_nonblock raising EAGAINWaitReadable
    400a56f Fix a typo s/refering/referring/
    c76d706 Fixed Dir.pwd spec with unicode characters.
    0512054 Add spec about -> lambda scoping.
    f0b6cf6 Accomodate for Thread#backtrace being nil when thread is not started yet.
    7462ac9 BigDecimal.new raises ArgumentError when Float is used without precision
    79f43c0 do not raise when precision is passed to BigDecimal#round
    26ac864 Fix line in Exception#backtrace spec.
    2269430 Move the fixture class to fixtures.
    d799042 Merge pull request #178 from yuki24/add-spec-for-name-error-receiver
    abee55f Merge pull request #177 from yuki24/add-specs-for-name-error-name
    fc420f3 Add specs for NameError#name
    c127124 Add more examples for NameError#receiver
    b09e8fd Simplify a spec for NameError#receiver
    674b32f Speficy that hidden metaclasses stay hidden.
    7b99cfc Merge pull request #179 from yuki24/use-latest-rubies
    0d96eb5 Use the latest rubies on Travis
    2617339 Add spec for Symbol#to_proc plus Proc#parameters => [[:rest]]
    bbcb689 Mask out specs+fixtures for keyreq added in 2.1.
    df59b1f Add some simple specs for Method#parameters with keyword args.
    bac69ca wait for the parent to read
    4960e98 Revert "wait for the parent to read" because of stall on Solaris
    822aac3 NetHTTPSpecs.start_server should not use hardcoded port number.
    379401f Fix and complete Thread#name spec.
    9912132 [ruby-2.3 core/thread] - Add specs for Thread#name and Thread#name=
    ae8ef6a Explicitly state the relation between classes since this spec is meta-meta
    1a31f57 Merge pull request #173 from nobu/bug/fd-passing-tests
    652d332 wait for the parent to read
    f60ee1e Merge pull request #172 from nobu/feature/dig_change
    e34b1a4 separate TypeError cases on dig
    7526c4e Merge pull request #171 from nobu/feature/dig_change
    4d25005 dig method update
    2f8577d Ruby 2.3 doesn't raise error
    72b2688 Specify the behavior of Date#<< with respect to the version
    f8358bd Merge pull request #170 from nobu/bug/Date-minus_month-exception
    1fdd93d do not mind excepction class
    53f535b Merge pull request #168 from cthulhua/chunk_while
    f4ae8fc [ruby-2.3 core/enumerable] - Add specs for enumerable#chunk_while
    1b726f7 Merge pull request #167 from nobu/bug/fix-infection-from-range
    2a8f30a Fix version to ruby_bug
    67fb1f7 Merge pull request #166 from nobu/bug/fix-infection-from-range
    7198825 Fix infection from Range
    e1b1ba6 Use the container infrastructure on Travis CI
    5cec3a3 Fix UTF-8 Encoding constant name in StringIO specs
    c330bfd Fix StringIO specs file structure
    e148e90 Fix StringIO#isatty describe title
    1f358a4 Fix location of ObjectSpace fixtures.
    
    git-subtree-dir: spec/ruby
    git-subtree-split: d9a07bfec7af8baef9daa85f2de9dcb9e18da170
    eregon committed Feb 2, 2016
    Copy the full SHA
    69be235 View commit details
  2. Copy the full SHA
    51ef78b View commit details
Showing with 1,393 additions and 845 deletions.
  1. +4 −3 spec/ruby/.travis.yml
  2. +3 −3 spec/ruby/CONTRIBUTING.md
  3. +30 −11 spec/ruby/README.md
  4. +15 −4 spec/ruby/core/array/shared/inspect.rb
  5. +9 −0 spec/ruby/core/basicobject/instance_eval_spec.rb
  6. +11 −54 spec/ruby/core/bignum/size_spec.rb
  7. +6 −8 spec/ruby/core/comparable/equal_value_spec.rb
  8. +17 −10 spec/ruby/core/dir/pwd_spec.rb
  9. +1 −2 spec/ruby/core/encoding/converter/primitive_convert_spec.rb
  10. +9 −0 spec/ruby/core/enumerable/chunk_spec.rb
  11. +38 −0 spec/ruby/core/enumerable/chunk_while_spec.rb
  12. +7 −10 spec/ruby/core/enumerable/slice_before_spec.rb
  13. +1 −1 spec/ruby/core/exception/backtrace_spec.rb
  14. +24 −16 spec/ruby/core/exception/fixtures/common.rb
  15. +55 −1 spec/ruby/core/exception/name_spec.rb
  16. +47 −5 spec/ruby/core/exception/receiver_spec.rb
  17. +0 −23 spec/ruby/core/fiber/resume_spec.rb
  18. +10 −15 spec/ruby/core/float/constants_spec.rb
  19. +2 −2 spec/ruby/core/hash/allocate_spec.rb
  20. +5 −5 spec/ruby/core/hash/any_spec.rb
  21. +5 −5 spec/ruby/core/hash/clear_spec.rb
  22. +1 −1 spec/ruby/core/hash/clone_spec.rb
  23. +6 −6 spec/ruby/core/hash/compare_by_identity_spec.rb
  24. +25 −26 spec/ruby/core/hash/constructor_spec.rb
  25. +13 −13 spec/ruby/core/hash/default_proc_spec.rb
  26. +7 −7 spec/ruby/core/hash/default_spec.rb
  27. +5 −5 spec/ruby/core/hash/delete_if_spec.rb
  28. +9 −9 spec/ruby/core/hash/delete_spec.rb
  29. +9 −4 spec/ruby/core/hash/dig_spec.rb
  30. +5 −5 spec/ruby/core/hash/each_key_spec.rb
  31. +1 −1 spec/ruby/core/hash/each_pair_spec.rb
  32. +1 −1 spec/ruby/core/hash/each_spec.rb
  33. +3 −3 spec/ruby/core/hash/each_value_spec.rb
  34. +18 −18 spec/ruby/core/hash/element_reference_spec.rb
  35. +5 −5 spec/ruby/core/hash/empty_spec.rb
  36. +1 −1 spec/ruby/core/hash/equal_value_spec.rb
  37. +11 −11 spec/ruby/core/hash/fetch_spec.rb
  38. +1 −1 spec/ruby/core/hash/fetch_values_spec.rb
  39. +8 −8 spec/ruby/core/hash/fixtures/classes.rb
  40. +2 −2 spec/ruby/core/hash/flatten_spec.rb
  41. +3 −3 spec/ruby/core/hash/hash_spec.rb
  42. +3 −3 spec/ruby/core/hash/initialize_spec.rb
  43. +6 −6 spec/ruby/core/hash/invert_spec.rb
  44. +5 −5 spec/ruby/core/hash/keep_if_spec.rb
  45. +8 −8 spec/ruby/core/hash/keys_spec.rb
  46. +22 −22 spec/ruby/core/hash/merge_spec.rb
  47. +10 −10 spec/ruby/core/hash/new_spec.rb
  48. +2 −2 spec/ruby/core/hash/rehash_spec.rb
  49. +12 −12 spec/ruby/core/hash/reject_spec.rb
  50. +12 −12 spec/ruby/core/hash/select_spec.rb
  51. +6 −6 spec/ruby/core/hash/shared/each.rb
  52. +30 −30 spec/ruby/core/hash/shared/eql.rb
  53. +7 −7 spec/ruby/core/hash/shared/equal.rb
  54. +6 −6 spec/ruby/core/hash/shared/index.rb
  55. +2 −2 spec/ruby/core/hash/shared/iteration.rb
  56. +6 −6 spec/ruby/core/hash/shared/key.rb
  57. +6 −6 spec/ruby/core/hash/shared/length.rb
  58. +13 −13 spec/ruby/core/hash/shared/replace.rb
  59. +8 −8 spec/ruby/core/hash/shared/store.rb
  60. +9 −9 spec/ruby/core/hash/shared/to_s.rb
  61. +10 −10 spec/ruby/core/hash/shared/update.rb
  62. +5 −5 spec/ruby/core/hash/shared/value.rb
  63. +1 −1 spec/ruby/core/hash/shared/values_at.rb
  64. +5 −5 spec/ruby/core/hash/shift_spec.rb
  65. +3 −3 spec/ruby/core/hash/sort_spec.rb
  66. +4 −4 spec/ruby/core/hash/to_a_spec.rb
  67. +1 −1 spec/ruby/core/hash/to_h_spec.rb
  68. +1 −1 spec/ruby/core/hash/to_hash_spec.rb
  69. +1 −1 spec/ruby/core/hash/to_proc_spec.rb
  70. +1 −1 spec/ruby/core/hash/values_spec.rb
  71. +8 −2 spec/ruby/core/io/read_nonblock_spec.rb
  72. +14 −0 spec/ruby/core/io/sync_spec.rb
  73. +31 −0 spec/ruby/core/io/write_nonblock_spec.rb
  74. +57 −0 spec/ruby/core/kernel/Float_spec.rb
  75. +5 −7 spec/ruby/core/kernel/eval_spec.rb
  76. +11 −0 spec/ruby/core/kernel/loop_spec.rb
  77. +3 −0 spec/ruby/core/method/fixtures/classes.rb
  78. +5 −0 spec/ruby/core/method/fixtures/classes21.rb
  79. +19 −0 spec/ruby/core/method/parameters_spec.rb
  80. +4 −3 spec/ruby/core/module/alias_method_spec.rb
  81. +2 −2 spec/ruby/core/module/autoload_spec.rb
  82. +13 −11 spec/ruby/core/module/define_method_spec.rb
  83. +1 −1 spec/ruby/core/module/prepend_spec.rb
  84. +4 −3 spec/ruby/core/module/undef_method_spec.rb
  85. +1 −1 spec/ruby/core/objectspace/define_finalizer_spec.rb
  86. +9 −1 spec/ruby/core/objectspace/each_object_spec.rb
  87. 0 spec/ruby/core/objectspace/{fixtures.rb → fixtures/classes.rb}
  88. +6 −8 spec/ruby/core/range/inspect_spec.rb
  89. +6 −8 spec/ruby/core/range/to_s_spec.rb
  90. +6 −6 spec/ruby/core/string/gsub_spec.rb
  91. +14 −0 spec/ruby/core/string/split_spec.rb
  92. +6 −6 spec/ruby/core/string/sub_spec.rb
  93. +5 −0 spec/ruby/core/symbol/to_proc_spec.rb
  94. +40 −0 spec/ruby/core/thread/name_spec.rb
  95. +4 −3 spec/ruby/language/alias_spec.rb
  96. +7 −9 spec/ruby/language/block_spec.rb
  97. +1 −2 spec/ruby/language/class_spec.rb
  98. +1 −1 spec/ruby/language/magic_comment_spec.rb
  99. +1 −17 spec/ruby/language/not_spec.rb
  100. +16 −7 spec/ruby/language/predefined_spec.rb
  101. +19 −25 spec/ruby/language/rescue_spec.rb
  102. +3 −9 spec/ruby/language/super_spec.rb
  103. +0 −1 spec/ruby/language/symbol_spec.rb
  104. +10 −9 spec/ruby/language/throw_spec.rb
  105. +4 −3 spec/ruby/language/undef_spec.rb
  106. +16 −5 spec/ruby/library/date/minus_month_spec.rb
  107. +1 −1 spec/ruby/library/net/http/http/copy_spec.rb
  108. +1 −1 spec/ruby/library/net/http/http/delete_spec.rb
  109. +1 −1 spec/ruby/library/net/http/http/finish_spec.rb
  110. +5 −1 spec/ruby/library/net/http/http/fixtures/http_server.rb
  111. +3 −2 spec/ruby/library/net/http/http/get_print_spec.rb
  112. +3 −2 spec/ruby/library/net/http/http/get_response_spec.rb
  113. +3 −2 spec/ruby/library/net/http/http/get_spec.rb
  114. +1 −1 spec/ruby/library/net/http/http/head_spec.rb
  115. +4 −3 spec/ruby/library/net/http/http/inspect_spec.rb
  116. +1 −1 spec/ruby/library/net/http/http/lock_spec.rb
  117. +1 −1 spec/ruby/library/net/http/http/mkcol_spec.rb
  118. +1 −1 spec/ruby/library/net/http/http/move_spec.rb
  119. +1 −1 spec/ruby/library/net/http/http/options_spec.rb
  120. +2 −1 spec/ruby/library/net/http/http/post_form_spec.rb
  121. +1 −1 spec/ruby/library/net/http/http/post_spec.rb
  122. +1 −1 spec/ruby/library/net/http/http/propfind_spec.rb
  123. +1 −1 spec/ruby/library/net/http/http/proppatch_spec.rb
  124. +1 −1 spec/ruby/library/net/http/http/put_spec.rb
  125. +1 −1 spec/ruby/library/net/http/http/request_spec.rb
  126. +1 −1 spec/ruby/library/net/http/http/send_request_spec.rb
  127. +1 −1 spec/ruby/library/net/http/http/set_debug_output_spec.rb
  128. +1 −1 spec/ruby/library/net/http/http/shared/request_get.rb
  129. +1 −1 spec/ruby/library/net/http/http/shared/request_head.rb
  130. +1 −1 spec/ruby/library/net/http/http/shared/request_post.rb
  131. +1 −1 spec/ruby/library/net/http/http/shared/request_put.rb
  132. +1 −1 spec/ruby/library/net/http/http/shared/started.rb
  133. +8 −7 spec/ruby/library/net/http/http/start_spec.rb
  134. +1 −1 spec/ruby/library/net/http/http/trace_spec.rb
  135. +1 −1 spec/ruby/library/net/http/http/unlock_spec.rb
  136. +63 −61 spec/ruby/library/socket/socket/getaddrinfo_spec.rb
  137. +7 −21 spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb
  138. 0 spec/ruby/library/stringio/{codepoints.rb → codepoints_spec.rb}
  139. 0 spec/ruby/library/stringio/{each_codepoint.rb → each_codepoint_spec.rb}
  140. +2 −2 spec/ruby/library/stringio/{external_encoding.rb → external_encoding_spec.rb}
  141. +1 −1 spec/ruby/library/stringio/{internal_encoding.rb → internal_encoding_spec.rb}
  142. +1 −1 spec/ruby/library/stringio/isatty_spec.rb
  143. +2 −2 spec/ruby/library/stringio/{set_encoding.rb → set_encoding_spec.rb}
  144. +6 −0 spec/ruby/library/stringio/ungetbyte_spec.rb
  145. +9 −0 spec/ruby/library/thread/queue/close_spec.rb
  146. +9 −0 spec/ruby/library/thread/queue/closed_spec.rb
  147. +26 −0 spec/ruby/library/thread/shared/queue/close.rb
  148. +12 −0 spec/ruby/library/thread/shared/queue/closed.rb
  149. +9 −0 spec/ruby/library/thread/sizedqueue/close_spec.rb
  150. +9 −0 spec/ruby/library/thread/sizedqueue/closed_spec.rb
  151. +87 −14 spec/ruby/library/zlib/deflate/deflate_spec.rb
  152. +29 −0 spec/ruby/library/zlib/inflate/finish_spec.rb
  153. +43 −0 spec/ruby/library/zlib/inflate/inflate_spec.rb
  154. +9 −0 spec/ruby/optional/capi/array_spec.rb
  155. +10 −0 spec/ruby/optional/capi/ext/array_spec.c
  156. +0 −5 spec/ruby/optional/capi/ext/mri.h
  157. +4 −2 spec/ruby/optional/capi/ext/rubyspec.h
  158. +0 −10 spec/ruby/optional/capi/ext/string_spec.c
  159. +1 −1 spec/ruby/optional/capi/io_spec.rb
  160. +3 −2 spec/ruby/optional/capi/spec_helper.rb
  161. +0 −6 spec/ruby/optional/capi/string_spec.rb
  162. +10 −10 spec/ruby/shared/process/spawn.rb
  163. +1 −1 spec/ruby/shared/rational/exponent.rb
  164. +0 −3 spec/ruby/version.rb
7 changes: 4 additions & 3 deletions spec/ruby/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
sudo: false
language: ruby
rvm:
- 2.0.0-p647
- 2.1.7
- 2.2.3
- 2.0.0-p648
- 2.1.8
- 2.2.4
- ruby-head
install:
- git clone https://github.com/ruby/mspec.git ../mspec
6 changes: 3 additions & 3 deletions spec/ruby/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ Specify `core` or `library` as the `base`.

#### Finding unspecified core methods

This is very easy, just run the command below in your `rubyspec` directory.
This is very easy, just run the command below in your `spec` directory.
`ruby` must be a recent version of MRI.

$ ruby --disable-gem ../mspec/bin/mkspec
@@ -56,8 +56,8 @@ In general, the usage of guards should be minimized as possible.
The following guards are deprecated and should not be used in new code:
* `not_compliant_on`: Simply tag the spec as failing instead.
If it makes sense to test part of the example, split it (an example should have only one or a few `should`).
* `compliant_on` / `deviates_on`: RubySpec defines common behavior and not implementation details.
Use the implementation suite of tests/specs for these.
* `compliant_on` / `deviates_on`: The Ruby Spec Suite defines common behavior and not implementation details.
Use the implementation test suite for these.

### Style

41 changes: 30 additions & 11 deletions spec/ruby/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
# RubySpec
# The Ruby Spec Suite

[![Build Status](https://travis-ci.org/ruby/rubyspec.svg)](https://travis-ci.org/ruby/rubyspec)
[![Build Status](https://travis-ci.org/ruby/spec.svg)](https://travis-ci.org/ruby/spec)

RubySpec is an executable specification for the Ruby programming language.
The specs describe the Ruby language syntax as well as the core and standard library classes.
The Ruby Spec Suite is a test suite for the behavior of the Ruby programming language.

The RubySpec files are written using a RSpec-like syntax.
MSpec is the purpose-built framework for running RubySpec.
It is not a standardized specification like the ISO one, and does not aim to become one.
Instead, it is a practical tool to describe and test the behavior of Ruby with code.

Every example code has a textual description, which presents several advantages:

* It is easier to understand the intent of the author
* It documents how recent versions of Ruby should behave
* It helps Ruby implementations to agree on a common behavior

The specs are written with syntax similar to RSpec 2.
They are run with MSpec, the purpose-built framework for running the Ruby Spec Suite.
For more information, see the [MSpec](http://github.com/ruby/mspec) project.

The specs describe the [language syntax](language/), the [core library](core/) and the [standard library](library/).
The language specs are grouped by keyword while the core and standard library specs are grouped by class and method.

### Running the specs

First, clone this repository:

$ git clone https://github.com/ruby/rubyspec.git
$ git clone https://github.com/ruby/spec.git

Then move to it:

$ cd rubyspec
$ cd spec

Clone [MSpec](http://github.com/ruby/mspec):

$ git clone https://github.com/ruby/mspec.git ../mspec

And run the RubySpec suite:
And run the spec suite:

$ ../mspec/bin/mspec

This will execute all the RubySpec specs using the executable named `ruby` on your current PATH.
This will execute all the specs using the executable named `ruby` on your current PATH.

### Running Specs with a Specific Ruby Implementation

@@ -59,4 +70,12 @@ In similar fashion, the following commands run the respective specs:

### Contributing

See [CONTRIBUTING.md](https://github.com/ruby/rubyspec/blob/master/CONTRIBUTING.md).
See [CONTRIBUTING.md](https://github.com/ruby/spec/blob/master/CONTRIBUTING.md).

### History and RubySpec

This project was originally born from [Rubinius](https://github.com/rubinius/rubinius) tests being converted to the spec style.
These specs were later extracted to their own project, RubySpec, with a specific vision and principles.
At the end of 2014, Brian Shirai, the creator of RubySpec, decided to [end RubySpec](http://rubinius.com/2014/12/31/matz-s-ruby-developers-don-t-use-rubyspec/).
A couple months later, the different repositories were merged and [the project was revived](http://eregon.github.io/rubyspec/2015/07/29/rubyspec-is-reborn.html).
On 12 January 2016, the name was changed to "The Ruby Spec Suite" for clarity and to let the RubySpec ideology rest in peace.
19 changes: 15 additions & 4 deletions spec/ruby/core/array/shared/inspect.rb
Original file line number Diff line number Diff line change
@@ -81,11 +81,22 @@
array.send(@method).encoding.name.should == "US-ASCII"
end

it "raises if inspected result is not default external encoding" do
utf_16be = mock("utf_16be")
utf_16be.should_receive(:inspect).and_return("utf_16be".encode!(Encoding::UTF_16BE))
ruby_version_is ''...'2.3' do
it "raises if inspected result is not default external encoding" do
utf_16be = mock("utf_16be")
utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))

lambda { [utf_16be].send(@method) }.should raise_error(Encoding::CompatibilityError)
lambda { [utf_16be].send(@method) }.should raise_error(Encoding::CompatibilityError)
end
end

ruby_version_is '2.3' do
it "raises if inspected result is not default external encoding" do
utf_16be = mock("utf_16be")
utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))

[utf_16be].send(@method).should == '["utf_16be \u3042"]'
end
end
end
end
9 changes: 9 additions & 0 deletions spec/ruby/core/basicobject/instance_eval_spec.rb
Original file line number Diff line number Diff line change
@@ -150,4 +150,13 @@ class B; end
(1 << 64).instance_eval { def foo; end }
end.should raise_error(TypeError)
end

it "evaluates procs originating from methods" do
def meth(arg); arg; end

m = method(:meth)
obj = Object.new

obj.instance_eval(&m).should == obj
end
end
65 changes: 11 additions & 54 deletions spec/ruby/core/bignum/size_spec.rb
Original file line number Diff line number Diff line change
@@ -2,60 +2,17 @@

describe "Bignum#size" do
ruby_version_is "2.1" do
it "returns the number of bytes whose number of bytes is larger than the size of allocated binum data" do
(256**7).size.should >= 8
(256**8).size.should >= 9
(256**9).size.should >= 10
(256**10).size.should >= 10
(256**10-1).size.should >= 9
(256**11).size.should >= 12
(256**12).size.should >= 13
(256**20-1).size.should >= 20
(256**40-1).size.should >= 40
end
end

ruby_version_is ""..."2.1" do
compliant_on :ironruby do
it "returns the number of bytes in the machine representation in multiples of sizeof(BDIGIT) which is 4 where long long is 64 bit" do
(256**7).size.should == 8
(256**8).size.should == 12
(256**9).size.should == 12
(256**10).size.should == 12
(256**10-1).size.should == 12
(256**11).size.should == 12
(256**12).size.should == 16
(256**20-1).size.should == 20
(256**40-1).size.should == 40
end
end

deviates_on :rubinius, :jruby do
it "returns the number of bytes in the machine representation" do
(256**7).size .should == 8
(256**8).size .should == 9
(256**9).size .should == 10
(256**10).size .should == 11
(256**10-1).size.should == 10
(256**11).size .should == 12
(256**12).size .should == 13
(256**20-1).size .should == 20
(256**40-1).size .should == 40
end
end

deviates_on :maglev do
it "returns the number of bytes in the machine representation in multiples of four" do
(256**7).size .should == 8
(256**8).size .should == 16
(256**9).size .should == 16
(256**10).size .should == 16
(256**10-1).size.should == 16
(256**11).size .should == 16
(256**12).size .should == 20
(256**20-1).size.should == 24
(256**40-1).size.should == 44
end
it "returns the number of bytes required to hold the unsigned bignum data" do
# that is, n such that 256 * n <= val.abs < 256 * (n+1)
(256**7).size.should == 8
(256**8).size.should == 9
(256**9).size.should == 10
(256**10).size.should == 11
(256**10-1).size.should == 10
(256**11).size.should == 12
(256**12).size.should == 13
(256**20-1).size.should == 20
(256**40-1).size.should == 40
end
end
end
14 changes: 6 additions & 8 deletions spec/ruby/core/comparable/equal_value_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

no_silent_rescue = "2.3"

describe "Comparable#==" do
a = b = nil
before :each do
@@ -50,13 +48,13 @@
a.should_receive(:<=>).once.and_return("abc")
end

ruby_version_is ""...no_silent_rescue do
ruby_version_is ""..."2.3" do
it "returns false" do
(a == b).should be_false
end
end

ruby_version_is no_silent_rescue do
ruby_version_is "2.3" do
it "raises an ArgumentError" do
lambda { (a == b) }.should raise_error(ArgumentError)
end
@@ -69,14 +67,14 @@
a.should_receive(:<=>).once.and_raise(StandardError)
end

ruby_version_is ""...no_silent_rescue do
ruby_version_is ""..."2.3" do
# Behaviour confirmed by MRI test suite
it "returns false" do
(a == b).should be_false
end
end

ruby_version_is no_silent_rescue do
ruby_version_is "2.3" do
it "lets it go through" do
lambda { (a == b) }.should raise_error(StandardError)
end
@@ -89,13 +87,13 @@
a.should_receive(:<=>).once.and_raise(TypeError)
end

ruby_version_is ""...no_silent_rescue do
ruby_version_is ""..."2.3" do
it "returns false" do
(a == b).should be_false
end
end

ruby_version_is no_silent_rescue do
ruby_version_is "2.3" do
it "lets it go through" do
lambda { (a == b) }.should raise_error(TypeError)
end
27 changes: 17 additions & 10 deletions spec/ruby/core/dir/pwd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/common', __FILE__)
require File.expand_path('../shared/pwd', __FILE__)
@@ -12,19 +13,25 @@
end

it_behaves_like :dir_pwd, :pwd
end

it "correctly displays dirs with unicode characters in them" do
DirSpecs.clear_dirs
describe "Dir.pwd" do
before :each do
@name = tmp("あ").force_encoding('binary')
@fs_encoding = Encoding.find('filesystem')
end

begin
str = [0xe9].pack 'U' # Unicode é
Dir.mkdir str
File.exist?(str).should == true
after :each do
rm_r @name
end

old_pwd = Dir.pwd
Dir.chdir(str) { Dir.pwd.force_encoding('UTF-8').should == File.join(old_pwd, str) }
ensure
DirSpecs.clear_dirs
it "correctly handles dirs with unicode characters in them" do
Dir.mkdir @name
Dir.chdir @name do
if @fs_encoding == Encoding::UTF_8
Dir.pwd.encoding.should == Encoding::UTF_8
end
Dir.pwd.force_encoding('binary').should == @name
end
end
end
3 changes: 1 addition & 2 deletions spec/ruby/core/encoding/converter/primitive_convert_spec.rb
Original file line number Diff line number Diff line change
@@ -86,8 +86,7 @@
end

it "accepts an options hash" do
@ec.primitive_convert("","",nil,nil, {after_output: true})\
.should_not raise_error(ArgumentError)
@ec.primitive_convert("","",nil,nil, {after_output: true}).should == :finished
end

it "sets the destination buffer's encoding to the destination encoding if the conversion suceeded" do
9 changes: 9 additions & 0 deletions spec/ruby/core/enumerable/chunk_spec.rb
Original file line number Diff line number Diff line change
@@ -72,6 +72,15 @@
end
end

ruby_version_is "2.3" do
it "does not accept arguments" do
e = EnumerableSpecs::Numerous.new(1, 2, 3)
lambda {
e.chunk(1) {}
}.should raise_error(ArgumentError)
end
end

it 'returned Enumerator size returns nil' do
e = EnumerableSpecs::NumerousWithSize.new(1, 2, 3, 2, 1)
enum = e.chunk { |x| true }
38 changes: 38 additions & 0 deletions spec/ruby/core/enumerable/chunk_while_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

ruby_version_is "2.3" do
describe "Enumerable#chunk_while" do
before :each do
ary = [10, 9, 7, 6, 4, 3, 2, 1]
@enum = EnumerableSpecs::Numerous.new *ary
@result = @enum.chunk_while { |i, j| i - 1 == j }
@enum_length = ary.length
end

context "when given a block" do
it "returns an enumerator" do
@result.should be_an_instance_of(enumerator_class)
end

it "splits chunks between adjacent elements i and j where the block returns false" do
@result.to_a.should == [[10, 9], [7, 6], [4, 3, 2, 1]]
end

it "calls the block for length of the receiver enumerable minus one times" do
times_called = 0
@enum.chunk_while do |i, j|
times_called += 1
i - 1 == j
end.to_a
times_called.should == (@enum_length - 1)
end
end

context "when not given a block" do
it "raises an ArgumentError" do
lambda { @enum.chunk_while }.should raise_error(ArgumentError)
end
end
end
end
Loading