Skip to content

Commit

Permalink
Run specs for Hash.try_convert
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 29, 2013
1 parent 7387277 commit da88c21
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spec/filters/bugs/hash.rb
@@ -1,4 +1,6 @@
opal_filter "Hash" do
fails "Hash includes Enumerable"

fails "Hash#assoc only returns the first matching key-value pair for identity hashes"

fails "Hash.[] creates a Hash; values can be provided as a list of value-pairs in an array"
Expand Down Expand Up @@ -72,6 +74,11 @@
fails "Hash#has_key? compares keys with the same #hash value via #eql?"
fails "Hash#has_key? returns true if argument is a key"

fails "Hash#hash returns the same hash for recursive hashes through arrays"
fails "Hash#hash returns the same hash for recursive hashes"
fails "Hash#hash generates a hash for recursive hash structures"
fails "Hash#hash returns a value which doesn't depend on the hash order"

fails "Hash#include? compares keys with the same #hash value via #eql?"
fails "Hash#include? returns true if argument is a key"

Expand Down Expand Up @@ -105,6 +112,8 @@

fails "Hash#rassoc uses #== to compare the argument to the values"

fails "Hash#rehash reorganizes the hash by recomputing all key hash codes"

fails "Hash#reject returns subclass instance for subclasses"
fails "Hash#reject processes entries with the same order as reject!"
fails "Hash#reject! removes keys from self for which the block yields true"
Expand All @@ -124,7 +133,20 @@
fails "Hash#store stores unequal keys that hash to the same value"
fails "Hash#store associates the key with the value and return the value"

fails "Hash#sort converts self to a nested array of [key, value] arrays and sort with Array#sort"
fails "Hash#sort works when some of the keys are themselves arrays"
fails "Hash#sort uses block to sort array if passed a block"

fails "Hash#to_s handles hashes with recursive values"

fails "Hash.try_convert does not rescue exceptions raised by #to_hash"
fails "Hash.try_convert sends #to_hash to the argument and raises TypeError if it's not a kind of Hash"
fails "Hash.try_convert sends #to_hash to the argument and returns the result if it's a kind of Hash"
fails "Hash.try_convert sends #to_hash to the argument and returns the result if it's a Hash"
fails "Hash.try_convert sends #to_hash to the argument and returns the result if it's nil"
fails "Hash.try_convert returns nil when the argument does not respond to #to_hash"
fails "Hash.try_convert returns the argument if it's a kind of Hash"
fails "Hash.try_convert returns the argument if it's a Hash"

fails "Hash#update tries to convert the passed argument to a hash using #to_hash"
end
1 change: 1 addition & 0 deletions spec/filters/unsupported/frozen.rb
Expand Up @@ -83,4 +83,5 @@
fails "Hash#update raises a RuntimeError on a frozen instance that would not be modified"
fails "Hash#update checks frozen status before coercing an object with #to_hash"
fails "Hash#update raises a RuntimeError on a frozen instance that is modified"
fails "Hash#rehash raises a RuntimeError if called on a frozen instance"
end
4 changes: 4 additions & 0 deletions spec/rubyspecs
Expand Up @@ -170,6 +170,7 @@ core/hash/fetch_spec
core/hash/flatten_spec
core/hash/has_key_spec
core/hash/has_value_spec
core/hash/hash_spec
core/hash/include_spec
core/hash/index_spec
core/hash/indexes_spec
Expand All @@ -186,16 +187,19 @@ core/hash/member_spec
core/hash/merge_spec
core/hash/new_spec
core/hash/rassoc_spec
core/hash/rehash_spec
core/hash/reject_spec
core/hash/replace_spec
core/hash/select_spec
core/hash/shift_spec
core/hash/size_spec
core/hash/sort_spec
core/hash/store_spec
core/hash/to_a_spec
core/hash/to_h_spec
core/hash/to_hash_spec
core/hash/to_s_spec
core/hash/try_convert_spec
core/hash/update_spec
core/hash/value_spec
core/hash/values_at_spec
Expand Down

0 comments on commit da88c21

Please sign in to comment.