Skip to content

Commit

Permalink
Showing 4 changed files with 61 additions and 27 deletions.
15 changes: 9 additions & 6 deletions mx.jruby/mx_jruby.py
Original file line number Diff line number Diff line change
@@ -288,9 +288,16 @@ def runBenchmark(self, benchmark, bmSuiteArgs):
else:
sys.stderr.write(out.data)

# TODO CS 24-Jun-16, return an error point?
# TODO CS 24-Jun-16, how can we fail the wider suite?
return []
return [{
'benchmark': benchmark,
'metric.name': 'throughput',
'metric.value': 0,
'metric.unit': 'op/s',
'metric.better': 'higher',
'extra.metric.warmedup': 'true',
'extra.error': 'failed'
}]

classic_benchmarks = [
'binary-trees',
@@ -436,10 +443,6 @@ def benchmarks(self):
benchmarks.extend([benchmark_file + ':' + b.strip() for b in out.data.split('\n') if len(b.strip()) > 0])
else:
sys.stderr.write(out.data)

# TODO CS 24-Jun-16, return an error point?
# TODO CS 24-Jun-16, how can we fail the wider suite?
return []
return benchmarks

def time(self):
14 changes: 0 additions & 14 deletions spec/truffle/tags/core/array/bsearch_index_tags.txt

This file was deleted.

7 changes: 0 additions & 7 deletions spec/truffle/tags/core/array/dig_tags.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
fails:Array#dig returns #at with one arg
fails:Array#dig recurses array elements
fails:Array#dig raises without any args
fails:Array#dig calls #dig on the result of #at with the remaining arguments
fails:Array#dig raises a TypeError for a non-numeric index
fails:Array#dig returns the nested value specified if the sequence includes a key
fails:Array#dig raises a TypeError if any intermediate step does not respond to #dig
fails:Array#dig raises an ArgumentError if no arguments provided
fails:Array#dig returns nil if any intermediate step is nil
52 changes: 52 additions & 0 deletions truffle/src/main/ruby/core/array.rb
Original file line number Diff line number Diff line change
@@ -196,6 +196,49 @@ def bsearch
nil
end

def bsearch_index
return to_enum :bsearch_index unless block_given?

m = Rubinius::Mirror::Array.reflect self

tuple = m.tuple

min = start = m.start
max = total = start + m.total

last_true = nil
i = start + m.total / 2

while max >= min and i >= start and i < total
x = yield tuple.at(i)

return i if x == 0

case x
when Numeric
if x > 0
min = i + 1
else
max = i - 1
end
when true
last_true = i
max = i - 1
when false, nil
min = i + 1
else
raise TypeError, "wrong argument type (must be numeric, true, false or nil)"
end

i = min + (max - min) / 2
end

return i if max > min
return last_true if last_true

nil
end

def combination(num)
num = Rubinius::Type.coerce_to_collection_index num

@@ -272,6 +315,15 @@ def cycle(n=nil)
nil
end

def dig(idx, *more)
result = self.at(idx)
if result.nil? || more.empty?
result
else
result.dig(*more)
end
end

def each_index
return to_enum(:each_index) { size } unless block_given?

0 comments on commit b5f32fd

Please sign in to comment.