Skip to content

Commit 6f3b602

Browse files
aardvark179chrisseaton
authored andcommitted
Fixup more specs
1 parent 917462a commit 6f3b602

File tree

9 files changed

+32
-37
lines changed

9 files changed

+32
-37
lines changed

spec/tags/core/enumerable/sort_by_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/tags/core/hash/fetch_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/tags/core/hash/fetch_values_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/tags/core/hash/filter_tags.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

spec/tags/core/hash/merge_tags.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
fails:Hash#merge accepts multiple hashes
22
fails:Hash#merge accepts zero arguments and returns self
3-
fails:Hash#merge! accepts multiple hashes
4-
fails:Hash#merge! accepts zero arguments

spec/truffle/methods/Hash.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ empty?
2727
eql?
2828
fetch
2929
fetch_values
30+
filter
31+
filter!
3032
flatten
3133
has_key?
3234
has_value?

src/main/ruby/core/enumerator.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,3 +576,6 @@ def reset
576576

577577
class Enumerator::ArithmeticSequence < Enumerator
578578
end
579+
580+
class Enumerator::Chain < Enumerator
581+
end

src/main/ruby/core/exception.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,15 @@ def initialize(*args)
417417
end
418418

419419
class KeyError < IndexError
420+
421+
attr_reader :receiver
422+
attr_reader :key
423+
424+
def initialize(message = nil, receiver: nil, key: nil)
425+
@receiver = receiver
426+
@key = key
427+
super(message)
428+
end
420429
end
421430

422431
class SignalException < Exception

src/main/ruby/core/hash.rb

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def fetch(key, default=undefined)
219219
end
220220

221221
return default unless undefined.equal?(default)
222-
raise KeyError, "key #{key} not found"
222+
raise KeyError.new("key #{key} not found", :receiver => self, :key => key)
223223
end
224224

225225
def fetch_values(*keys, &block)
@@ -242,23 +242,25 @@ def keep_if
242242
self
243243
end
244244

245-
def merge!(other)
245+
def merge!(*others)
246246
Truffle.check_frozen
247247

248-
other = Truffle::Type.coerce_to other, Hash, :to_hash
248+
others.each do |other|
249+
other = Truffle::Type.coerce_to other, Hash, :to_hash
249250

250-
if block_given?
251-
other.each_pair do |key,value|
252-
if key? key
253-
__store__ key, yield(key, self[key], value)
254-
else
251+
if block_given?
252+
other.each_pair do |key,value|
253+
if key? key
254+
__store__ key, yield(key, self[key], value)
255+
else
256+
__store__ key, value
257+
end
258+
end
259+
else
260+
other.each_pair do |key,value|
255261
__store__ key, value
256262
end
257263
end
258-
else
259-
other.each_pair do |key,value|
260-
__store__ key, value
261-
end
262264
end
263265
self
264266
end
@@ -283,6 +285,8 @@ def select
283285
selected
284286
end
285287

288+
alias_method :filter, :select
289+
286290
def select!
287291
return to_enum(:select!) { size } unless block_given?
288292

@@ -297,6 +301,8 @@ def select!
297301
self
298302
end
299303

304+
alias_method :filter!, :select!
305+
300306
def to_h
301307
if block_given?
302308
super

0 commit comments

Comments
 (0)