Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Very terse implementation of Array#rindex.
  • Loading branch information
nirvdrum committed Feb 4, 2015
1 parent d05cd12 commit dd523bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/array/rindex_tags.txt
Expand Up @@ -3,8 +3,6 @@ fails:Array#rindex returns size-1 if last element == to object
fails:Array#rindex returns 0 if only first element == to object
fails:Array#rindex returns nil if no element == to object
fails:Array#rindex returns correct index even after delete_at
fails:Array#rindex properly handles empty recursive arrays
fails:Array#rindex properly handles recursive arrays
fails:Array#rindex accepts a block instead of an argument
fails:Array#rindex ignores the block if there is an argument
fails:Array#rindex rechecks the array size during iteration
Expand Down
27 changes: 27 additions & 0 deletions truffle/src/main/ruby/jruby/truffle/core/shims.rb
Expand Up @@ -154,10 +154,37 @@ def extended_modules(object)
[]
end

def trap(signal)
end

end

class File
def gets
read.split("\n").first
end

def rewind
end

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton Feb 5, 2015

Contributor

If we shim something to nothing like this perhaps we should puts 'warning.... I can imagine spending hours thinking 'I'm not getting a method missing error - why isn't this doing anything...'.

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Feb 5, 2015

Author Contributor

This wasn't supposed to be committed. I guess I screwed up staging the commit. I'll back it out.


def set_encoding(encoding, internal_encoding)
end
end

class String
def gsub(*args)
dup.gsub!(*args)
end
end

class Array
def rindex(obj)
index = nil

each_with_index do |e, i|
index = i if e == obj
end

index
end
end

0 comments on commit dd523bb

Please sign in to comment.