Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into 1.8.7
Browse files Browse the repository at this point in the history
Conflicts:
	Gemfile.installed
	gems_list.txt
	kernel/common/enumerable.rb
	kernel/common/rational.rb
	kernel/common/string.rb
	kernel/common/type.rb
	spec/ruby/language/method_spec.rb
	vm/builtin/system.cpp
  • Loading branch information
brixen committed Jan 25, 2015
2 parents 0889b35 + 96f8eda commit 7c89ed7
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 127 deletions.
2 changes: 2 additions & 0 deletions Gemfile.installed
Expand Up @@ -12,4 +12,6 @@ gem "racc", "~> 1.4"
gem "rake", "~> 10.1"
gem "json", "~> 1.8"
gem "rdoc", "~> 4.0"

gem "rb-readline", "~> 0.5"
gem "rubysl-readline", "~> 2.0"
6 changes: 6 additions & 0 deletions Rakefile
Expand Up @@ -11,6 +11,12 @@ if ENV["CDPATH"]
ENV.delete("CDPATH")
end

# Wipe out RUBYGEMS_GEMDEPS, it causes the build to fail with
# "no such file to load -- tsort" when running rbx extconf.rb
if ENV["RUBYGEMS_GEMDEPS"]
ENV.delete("RUBYGEMS_GEMDEPS")
end

$trace ||= false
$VERBOSE = true
$verbose = Rake.application.options.trace || ARGV.delete("-v")
Expand Down
7 changes: 5 additions & 2 deletions kernel/common/array.rb
Expand Up @@ -616,12 +616,15 @@ def fill(a=undefined, b=undefined, c=undefined)
unless undefined.equal?(c)
raise ArgumentError, "wrong number of arguments"
end
one, two = a, b
one = a
two = b
else
if undefined.equal?(a)
raise ArgumentError, "wrong number of arguments"
end
obj, one, two = a, b, c
obj = a
one = b
two = c
end

if one.kind_of? Range
Expand Down
3 changes: 2 additions & 1 deletion kernel/common/autoload.rb
Expand Up @@ -57,7 +57,8 @@ def resolve
end

def find_const(under)
current, constant = under, undefined
current = under
constant = undefined

while current
if entry = current.constant_table.lookup(name)
Expand Down
4 changes: 3 additions & 1 deletion kernel/common/string.rb
Expand Up @@ -728,7 +728,9 @@ def delete!(*strings)

self.modify!

i, j = 0, -1
i = 0
j = -1

while i < @num_bytes
c = @data[i]
unless table[c] == 1
Expand Down
16 changes: 14 additions & 2 deletions kernel/common/time.rb
Expand Up @@ -101,10 +101,22 @@ def self.compose(offset, p1, p2=nil, p3=nil, p4=nil, p5=nil, p6=nil, p7=nil,
raise ArgumentError, "wrong number of arguments (9 for 1..8)"
end

y, m, d, hr, min, sec, usec = p1, p2, p3, p4, p5, p6, p7
y = p1
m = p2
d = p3
hr = p4
min = p5
sec = p6
usec = p7
is_dst = -1
else
y, m, d, hr, min, sec, usec = p6, p5, p4, p3, p2, p1, 0
y = p6
m = p5
d = p4
hr = p3
min = p2
sec = p1
usec = 0
is_dst = is_dst ? 1 : 0
end

Expand Down
4 changes: 2 additions & 2 deletions kernel/common/type.rb
Expand Up @@ -247,8 +247,8 @@ def self.check_null_safe(string)

def self.const_get(mod, name, inherit = true)
name = coerce_to_constant_name name

current, constant = mod, undefined
current = mod
constant = undefined

while current
if bucket = current.constant_table.lookup(name)
Expand Down
8 changes: 6 additions & 2 deletions kernel/platform/library.rb
Expand Up @@ -222,9 +222,13 @@ def pointer_as_function(name, ptr, args, ret)

def callback(a1, a2, a3=nil)
if a3
name, params, ret = a1, a2, a3
name = a1
params = a2
ret = a3
else
name, params, ret = nil, a1, a2
name = nil
params = a1
ret = a2
end

args = params.map { |x| find_type(x) }
Expand Down
16 changes: 14 additions & 2 deletions rakelib/preinstall_gems.rb
Expand Up @@ -21,12 +21,24 @@
:install_dir => install_dir
}

gems.each do |gem|
next if File.directory? "#{install_dir}/gems/#{gem[0..-5]}"
def install(gem, install_dir, options)
return if File.directory? "#{install_dir}/gems/#{gem[0..-5]}"

file = File.join(BUILD_CONFIG[:gems_cache], "#{gem}")

installer = Gem::Installer.new file, options
spec = installer.install
puts "Installed #{spec.name} (#{spec.version})"
end

gems.each do |gem|
next if gem =~ /readline/

install gem, install_dir, options
end

if RUBY_PLATFORM =~ /freebsd/
install(gems.find { |g| g =~ /rubysl-readline/ }, install_dir, options)
else
install(gems.find { |g| g =~ /rb-readline/ }, install_dir, options)
end
52 changes: 33 additions & 19 deletions spec/ruby/core/enumerable/shared/collect_concat.rb
@@ -1,31 +1,45 @@
describe :enumerable_collect_concat, :shared => true do
it "returns a new array with the results of passing each element to block, flattened one level" do
it "yields elements to the block and flattens one level" do
numerous = EnumerableSpecs::Numerous.new(1, [2, 3], [4, [5, 6]], {:foo => :bar})
numerous.send(@method){ |i| i }.should == [1, 2, 3, 4, [5, 6], {:foo => :bar}]
numerous.send(@method) { |i| i }.should == [1, 2, 3, 4, [5, 6], {:foo => :bar}]
end

it "skips elements that are empty Arrays" do
numerous = EnumerableSpecs::Numerous.new(1, [], 2)
numerous.send(@method){ |i| i }.should == [1, 2]
it "appends non-Array elements that do not define #to_ary" do
obj = mock("to_ary undefined")

numerous = EnumerableSpecs::Numerous.new(1, obj, 2)
numerous.send(@method) { |i| i }.should == [1, obj, 2]
end

it "concatenates the result of calling #to_ary if it returns an Array" do
obj = mock("to_ary defined")
obj.should_receive(:to_ary).and_return([:a, :b])

numerous = EnumerableSpecs::Numerous.new(1, obj, 2)
numerous.send(@method) { |i| i }.should == [1, :a, :b, 2]
end

it "calls to_ary but not to_a" do
obj = mock('array-like')
obj.should_receive(:to_ary).and_return([:foo])
obj2 = mock('has a to_a')
obj2.should_not_receive(:to_a)
it "does not call #to_a" do
obj = mock("to_ary undefined")
obj.should_not_receive(:to_a)

numerous = EnumerableSpecs::Numerous.new(obj, obj2)
numerous.send(@method){ |i| i }.should == [:foo, obj2]
numerous = EnumerableSpecs::Numerous.new(1, obj, 2)
numerous.send(@method) { |i| i }.should == [1, obj, 2]
end

it "only returns the first value when multiple values are yielded" do
obj = Object.new
def obj.each
yield(1, 2)
end
obj.extend(Enumerable)
obj.send(@method){ |i| i }.should == [1]
it "appends an element that defines #to_ary that returns nil" do
obj = mock("to_ary defined")
obj.should_receive(:to_ary).and_return(nil)

numerous = EnumerableSpecs::Numerous.new(1, obj, 2)
numerous.send(@method) { |i| i }.should == [1, obj, 2]
end

it "raises a TypeError if an element defining #to_ary does not return an Array or nil" do
obj = mock("to_ary defined")
obj.should_receive(:to_ary).and_return("array")

lambda { [1, obj, 3].flat_map { |i| i } }.should raise_error(TypeError)
end

it "returns an enumerator when no block given" do
Expand Down

0 comments on commit 7c89ed7

Please sign in to comment.