Skip to content

Commit

Permalink
Showing 80 changed files with 381 additions and 305 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -1868,7 +1868,7 @@ public IRubyObject flatten(ThreadContext context, IRubyObject level) {
public IRubyObject getCompareByIdentity(ThreadContext context) {
modify();
setComparedByIdentity(true);
return this;
return rehash();
}

@JRubyMethod(name = "compare_by_identity?")
11 changes: 0 additions & 11 deletions core/src/main/java/org/jruby/javasupport/DummyForJavaUtil.java

This file was deleted.

5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
@@ -1647,4 +1647,9 @@ static boolean isDefaultMethod(final Method method) {
return false;
}

/**
* @see JavaUtil#CAN_SET_ACCESSIBLE
*/
@SuppressWarnings("unused") private static final byte _ = 72;

}
21 changes: 11 additions & 10 deletions core/src/main/java/org/jruby/javasupport/JavaUtil.java
Original file line number Diff line number Diff line change
@@ -98,12 +98,13 @@ public class JavaUtil {

if (RubyInstanceConfig.CAN_SET_ACCESSIBLE) {
try {
// We want to check if we can access a commonly-existing private field through reflection. If so,
// we're probably able to access some other fields too later on.
Field f = DummyForJavaUtil.class.getDeclaredField("PRIVATE");
// We want to check if we can access a commonly-existing private field through reflection.
// If so, we're probably able to access some other fields too later on.
Field f = Java.class.getDeclaredField("_");
f.setAccessible(true);
canSetAccessible = f.get(null).equals(DummyForJavaUtil.PUBLIC);
} catch (Exception t) {
canSetAccessible = f.getByte(null) == 72;
}
catch (Exception t) {
// added this so if things are weird in the future we can debug without
// spinning a new binary
if (Options.JI_LOGCANSETACCESSIBLE.load()) {
@@ -130,20 +131,20 @@ public static IRubyObject[] convertJavaArrayToRuby(final Ruby runtime, final Obj

public static RubyArray convertJavaArrayToRubyWithNesting(final ThreadContext context, final Object array) {
final int length = Array.getLength(array);
final RubyArray outer = context.runtime.newArray(length);
final IRubyObject[] rubyElements = new IRubyObject[length];
for ( int i = 0; i < length; i++ ) {
final Object element = Array.get(array, i);
if ( element instanceof ArrayJavaProxy ) {
outer.append( convertJavaArrayToRubyWithNesting(context, ((ArrayJavaProxy) element).getObject()) );
rubyElements[i] = convertJavaArrayToRubyWithNesting(context, ((ArrayJavaProxy) element).getObject());
}
else if ( element != null && element.getClass().isArray() ) {
outer.append( convertJavaArrayToRubyWithNesting(context, element) );
rubyElements[i] = convertJavaArrayToRubyWithNesting(context, element);
}
else {
outer.append( convertJavaToUsableRubyObject(context.runtime, element) );
rubyElements[i] = convertJavaToUsableRubyObject(context.runtime, element);
}
}
return outer;
return context.runtime.newArrayNoCopy(rubyElements);
}

public static JavaConverter getJavaConverter(Class clazz) {
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/util/JarResource.java
Original file line number Diff line number Diff line change
@@ -63,6 +63,12 @@ private static JarResource createJarResource(String jarPath, String entryPath, b
String[] entries = index.getDirEntries(entryPath);
if (entries != null) {
return new JarDirectoryResource(jarPath, rootSlashPrefix, entryPath, entries);
} else if (entryPath.length() > 1 && entryPath.endsWith("/")) { // in case 'foo/' passed
entries = index.getDirEntries(entryPath.substring(0, entryPath.length() - 1));

if (entries != null) {
return new JarDirectoryResource(jarPath, rootSlashPrefix, entryPath, entries);
}
}

JarEntry jarEntry = index.getJarEntry(entryPath);
24 changes: 9 additions & 15 deletions core/src/main/ruby/jruby/kernel.rb
Original file line number Diff line number Diff line change
@@ -4,21 +4,15 @@
load 'jruby/kernel/jruby/type.rb'
load 'jruby/kernel/signal.rb'

# Java 7 process launching support
spec_version = ENV_JAVA['java.specification.version']

unless JRuby.runtime.posix.native?
# native POSIX uses new logic for backquote
# GH-1148: ProcessBuilder is not available on GAE
begin
# Try to access ProcessBuilder; if it fails, don't define our special process logic
java.lang.ProcessBuilder
load 'jruby/kernel/jruby/process_manager.rb' if spec_version && spec_version >= '1.7'
rescue Exception
warn "ProcessBuilder unavailable; using default backtick" if $VERBOSE
# leave old backtick logic in place
end
end
require 'jruby'
begin
# Try to access ProcessBuilder; if it fails, don't define our special process logic
java.lang.ProcessBuilder # GH-1148: ProcessBuilder is not available on GAE
load 'jruby/kernel/jruby/process_manager.rb'
rescue Exception
warn "ProcessBuilder unavailable; using default backtick" if $VERBOSE
# leave old backtick logic in place
end unless JRuby.runtime.posix.native? # native POSIX uses new logic for back-quote

# These are loads so they don't pollute LOADED_FEATURES
load 'jruby/kernel/kernel.rb'
2 changes: 0 additions & 2 deletions core/src/main/ruby/jruby/kernel/jruby/process_manager.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'jruby'

module JRuby
# Implementations of key core process-launching methods using Java 7 process
# launching APIs.
1 change: 0 additions & 1 deletion spec/jruby.2.3.mspec
Original file line number Diff line number Diff line change
@@ -63,7 +63,6 @@ class MSpecScript
MSpec.enable_feature :continuation_library
MSpec.disable_feature :fork
MSpec.enable_feature :encoding
MSpec.enable_feature :readline

# Filter out ObjectSpace specs if ObjectSpace is disabled
unless JRuby.objectspace
10 changes: 6 additions & 4 deletions spec/mspec/lib/mspec/commands/mkspec.rb
Original file line number Diff line number Diff line change
@@ -69,10 +69,12 @@ def create_directory(mod)
end

def write_requires(dir, file)
/\A#{Regexp.escape config[:base]}\/?(.*)/ =~ dir
parents = '../' * ($1.split('/').length + 1)
prefix = config[:base] + '/'
raise dir unless dir.start_with? prefix
sub = dir[prefix.size..-1]
parents = '../' * (sub.split('/').length + 1)

File.open file, 'w' do |f|
File.open(file, 'w') do |f|
f.puts "require File.expand_path('../#{parents}spec_helper', __FILE__)"
config[:requires].each do |lib|
f.puts "require '#{lib}'"
@@ -94,7 +96,7 @@ def write_version(f)
def write_spec(file, meth, exists)
if exists
out = `#{ruby} #{MSPEC_HOME}/bin/mspec-run --dry-run -fs -e '#{meth}' #{file}`
return if out =~ /#{Regexp.escape meth}/
return if out.include?(meth)
end

File.open file, 'a' do |f|
8 changes: 2 additions & 6 deletions spec/mspec/lib/mspec/runner/filters/match.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
class MatchFilter
def initialize(what, *strings)
@what = what
@descriptions = to_regexp(*strings)
end

def to_regexp(*strings)
strings.map { |str| Regexp.new Regexp.escape(str) }
@strings = strings
end

def ===(string)
@descriptions.any? { |d| d === string }
@strings.any? { |s| string.include?(s) }
end

def register
2 changes: 1 addition & 1 deletion spec/mspec/lib/mspec/runner/formatters/junit.rb
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ def finish
def encode_for_xml(str)
encode_as_latin1(str).gsub("<", LT).gsub(">", GT).
gsub('"', QU).gsub("'", AP).gsub("&", AM).
gsub(/[#{Regexp.escape("\0\1\2\3\4\5\6\7\8")}]/, "?")
tr("\x00-\x08", "?")
end

def encode_as_latin1(str)
9 changes: 5 additions & 4 deletions spec/mspec/lib/mspec/runner/mspec.rb
Original file line number Diff line number Diff line change
@@ -347,16 +347,17 @@ def self.write_tag(tag)
# file if it is empty.
def self.delete_tag(tag)
deleted = false
pattern = /#{tag.tag}.*#{Regexp.escape(tag.escape(tag.description))}/
desc = tag.escape(tag.description)
file = tags_file
if File.exist? file
lines = IO.readlines(file)
File.open(file, "wb") do |f|
lines.each do |line|
unless pattern =~ line.chomp
f.puts line unless line.empty?
else
line = line.chomp
if line.start_with?(tag.tag) and line.end_with?(desc)
deleted = true
else
f.puts line unless line.empty?
end
end
end
12 changes: 6 additions & 6 deletions spec/mspec/spec/commands/mkspec_spec.rb
Original file line number Diff line number Diff line change
@@ -189,7 +189,7 @@
@script.stub(:puts)

@response = double("system command response")
@response.stub(:=~).and_return(false)
@response.stub(:include?).and_return(false)
@script.stub(:`).and_return(@response)
end

@@ -200,18 +200,18 @@
@script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
end

it "escapes the Regexp when checking for method name in the spec file output" do
Regexp.should_receive(:escape).with("Array#[]=")
it "checks for the method name in the spec file output" do
@response.should_receive(:include?).with("Array#[]=")
@script.write_spec("spec/core/yarra/element_set_spec.rb", "Array#[]=", true)
end

it "returns nil if the spec file exists and contains a spec for the method" do
@response.stub(:=~).and_return(true)
@response.stub(:include?).and_return(true)
@script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true).should == nil
end

it "does not print the spec file name if it exists and contains a spec for the method" do
@response.stub(:=~).and_return(true)
@response.stub(:include?).and_return(true)
@script.should_not_receive(:puts)
@script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
end
@@ -228,7 +228,7 @@
end

it "writes a template spec to the file if it exists but contains no spec for the method" do
@response.should_receive(:=~).and_return(false)
@response.should_receive(:include?).and_return(false)
@file.should_receive(:puts).twice
@script.should_receive(:puts).with("spec/core/tcejbo/inspect_spec.rb")
@script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
10 changes: 0 additions & 10 deletions spec/mspec/spec/runner/filters/match_spec.rb
Original file line number Diff line number Diff line change
@@ -2,16 +2,6 @@
require 'mspec/runner/mspec'
require 'mspec/runner/filters/match'

describe MatchFilter, "#to_regexp" do
before :each do
@filter = MatchFilter.new nil
end

it "converts its arguments to Regexp instances" do
@filter.to_regexp('a', 'b', 'c').should == [/a/, /b/, /c/]
end
end

describe MatchFilter, "#===" do
before :each do
@filter = MatchFilter.new nil, 'a', 'b', 'c'
2 changes: 1 addition & 1 deletion spec/mspec/spec/runner/mspec_spec.rb
Original file line number Diff line number Diff line change
@@ -520,7 +520,7 @@
MSpec.delete_tag(@tag).should == true
MSpec.delete_tag(SpecTag.new("incomplete:The#best method ever")).should == true
MSpec.delete_tag(SpecTag.new("benchmark:The#fastest method today")).should == true
MSpec.delete_tag(SpecTag.new("extended:\"Multi-line\ntext\ntag\"")).should == true
MSpec.delete_tag(SpecTag.new('extended:"Multi-line\ntext\ntag"')).should == true
File.exist?(tmp("tags.txt", false)).should == false
end
end
6 changes: 3 additions & 3 deletions spec/ruby/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
sudo: false
language: ruby
rvm:
- 2.1.8
- 2.2.4
- 2.3.0
- 2.1.10
- 2.2.6
- 2.3.3
- ruby-head
install:
- git clone https://github.com/ruby/mspec.git ../mspec
6 changes: 3 additions & 3 deletions spec/ruby/core/array/sample_spec.rb
Original file line number Diff line number Diff line change
@@ -76,10 +76,10 @@
[1, 2].sample(random: obj).should be_an_instance_of(Fixnum)
end

it "ignores an Object passed for the RNG if it does not define #rand" do
obj = mock("array_sample_random")
it "raises a NoMethodError if an object passed for the RNG does not define #rand" do
obj = BasicObject.new

[1, 2].sample(random: obj).should be_an_instance_of(Fixnum)
lambda { [1, 2].sample(random: obj) }.should raise_error(NoMethodError)
end

describe "when the object returned by #rand is a Fixnum" do
8 changes: 3 additions & 5 deletions spec/ruby/core/array/shuffle_spec.rb
Original file line number Diff line number Diff line change
@@ -40,12 +40,10 @@
result.should include(1, 2)
end

it "ignores an Object passed for the RNG if it does not define #rand" do
obj = mock("array_shuffle_random")
it "raises a NoMethodError if an object passed for the RNG does not define #rand" do
obj = BasicObject.new

result = [1, 2].shuffle(random: obj)
result.size.should == 2
result.should include(1, 2)
lambda { [1, 2].shuffle(random: obj) }.should raise_error(NoMethodError)
end

it "accepts a Float for the value returned by #rand" do
12 changes: 0 additions & 12 deletions spec/ruby/core/file/constants/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -29,15 +29,3 @@
end
end
end

ruby_version_is "2.3" do
platform_is :linux do
describe "File::TMPFILE" do
it "is defined" do
# Since Linux 3.11, does not work Travis (probably because built on a older host).
has_tmpfile = !ENV.key?('TRAVIS') && (`uname -r`.chomp.split('.').map(&:to_i) <=> [3,11]) >= 0
File.const_defined?(:TMPFILE).should == has_tmpfile
end
end
end
end
43 changes: 43 additions & 0 deletions spec/ruby/core/file/open_spec.rb
Original file line number Diff line number Diff line change
@@ -518,6 +518,31 @@
File.size(@file).should == 0
end

ruby_version_is "2.3" do
platform_is :linux do
if defined?(File::TMPFILE)
it "creates an unnamed temporary file with File::TMPFILE" do
dir = tmp("").chomp("/")
rm_r @file
Dir["#{dir}/*"].should == []
begin
File.open(dir, "r+", flags: File::TMPFILE) do |io|
io.write("ruby")
io.flush
io.rewind
io.read.should == "ruby"
Dir["#{dir}/*"].should == []
end
rescue Errno::EOPNOTSUPP, Errno::EINVAL
# EOPNOTSUPP: no support from the filesystem
# EINVAL: presumably bug in glibc
1.should == 1
end
end
end
end
end

it "raises a TypeError if passed a filename that is not a String or Integer type" do
lambda { File.open(true) }.should raise_error(TypeError)
lambda { File.open(false) }.should raise_error(TypeError)
@@ -553,6 +578,24 @@
@fh = File.open(@file, options)
end

ruby_version_is "2.3" do
it "accepts extra flags as a keyword argument and combine with a string mode" do
lambda {
File.open(@file, "w", flags: File::EXCL) { }
}.should raise_error(Errno::EEXIST)

lambda {
File.open(@file, mode: "w", flags: File::EXCL) { }
}.should raise_error(Errno::EEXIST)
end

it "accepts extra flags as a keyword argument and combine with an integer mode" do
lambda {
File.open(@file, File::WRONLY | File::CREAT, flags: File::EXCL) { }
}.should raise_error(Errno::EEXIST)
end
end

platform_is_not :windows do
describe "on a FIFO" do
before :each do
15 changes: 3 additions & 12 deletions spec/ruby/core/float/round_spec.rb
Original file line number Diff line number Diff line change
@@ -70,18 +70,9 @@
0.42.round(2.0**30).should == 0.42
end

ruby_version_is ""..."2.4" do
it "returns big values rounded to nearest" do
+2.5e20.round(-20).should eql( +3 * 10 ** 20 )
-2.5e20.round(-20).should eql( -3 * 10 ** 20 )
end
end

ruby_version_is "2.4" do
it "returns big values rounded to nearest even" do
+2.5e20.round(-20).should eql( +2 * 10 ** 20 )
-2.5e20.round(-20).should eql( -2 * 10 ** 20 )
end
it "returns big values rounded to nearest" do
+2.5e20.round(-20).should eql( +3 * 10 ** 20 )
-2.5e20.round(-20).should eql( -3 * 10 ** 20 )
end

# redmine #5272
21 changes: 5 additions & 16 deletions spec/ruby/core/integer/round_spec.rb
Original file line number Diff line number Diff line change
@@ -24,22 +24,11 @@
(-25 * 10**70 + 1).round(-71).should eql(-20 * 10**70)
end

ruby_version_is ""..."2.4" do
it "returns itself rounded to nearest if passed a negative value" do
+250.round(-2).should eql(+300)
-250.round(-2).should eql(-300)
(+25 * 10**70).round(-71).should eql(+30 * 10**70)
(-25 * 10**70).round(-71).should eql(-30 * 10**70)
end
end

ruby_version_is "2.4" do
it "returns itself rounded to nearest even if passed a negative value" do
+250.round(-2).should eql(+200)
-250.round(-2).should eql(-200)
(+25 * 10**70).round(-71).should eql(+20 * 10**70)
(-25 * 10**70).round(-71).should eql(-20 * 10**70)
end
it "returns itself rounded to nearest if passed a negative value" do
+250.round(-2).should eql(+300)
-250.round(-2).should eql(-300)
(+25 * 10**70).round(-71).should eql(+30 * 10**70)
(-25 * 10**70).round(-71).should eql(-30 * 10**70)
end

platform_is_not wordsize: 32 do
6 changes: 0 additions & 6 deletions spec/ruby/core/kernel/clone_spec.rb
Original file line number Diff line number Diff line change
@@ -57,12 +57,6 @@ class << clone
end
end

it "raises TypeError when called on nil" do
lambda {
nil.clone
}.should raise_error(TypeError)
end

it "replaces a singleton object's metaclass with a new copy with the same superclass" do
cls = Class.new do
def bar
22 changes: 22 additions & 0 deletions spec/ruby/core/kernel/shared/dup_clone.rb
Original file line number Diff line number Diff line change
@@ -100,4 +100,26 @@ def initialize_copy(original)
lambda { :my_symbol.send(@method) }.should raise_error(TypeError)
end
end

ruby_version_is '2.4' do
it "returns nil for NilClass" do
nil.send(@method).should == nil
end

it "returns true for TrueClass" do
true.send(@method).should == true
end

it "returns false for FalseClass" do
false.send(@method).should == false
end

it "returns the same Integer for Integer" do
1.send(@method).should == 1
end

it "returns the same Symbol for Symbol" do
:my_symbol.send(@method).should == :my_symbol
end
end
end
14 changes: 12 additions & 2 deletions spec/ruby/core/string/shared/each_line.rb
Original file line number Diff line number Diff line change
@@ -42,11 +42,21 @@
it "yields paragraphs (broken by 2 or more successive newlines) when passed ''" do
a = []
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n"]
ruby_version_is ''...'2.5' do
a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n"]
end
ruby_version_is '2.5' do
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n"]
end

a = []
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\ndog".send(@method, '') { |s| a << s }
a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n", "dog"]
ruby_version_is ''...'2.5' do
a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n", "dog"]
end
ruby_version_is '2.5' do
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n", "dog"]
end
end

describe "uses $/" do
19 changes: 3 additions & 16 deletions spec/ruby/core/time/strftime_spec.rb
Original file line number Diff line number Diff line change
@@ -45,21 +45,8 @@
end

# Date/DateTime round at creation time, but Time does it in strftime.
ruby_version_is ""..."2.4" do
it "rounds an offset to the nearest second when formatting with %z" do
time = @new_time_with_offset[2012, 1, 1, 0, 0, 0, Rational(36645, 10)]
time.strftime("%::z").should == "+01:01:05"
end
end

ruby_version_is "2.4" do
it "rounds an offset to the nearest even second when formatting with %z" do
time = @new_time_with_offset[2012, 1, 1, 0, 0, 0, Rational(36645, 10)]
time.strftime("%::z").should == "+01:01:04"
time = @new_time_with_offset[2012, 1, 1, 0, 0, 0, Rational(36655, 10)]
time.strftime("%::z").should == "+01:01:06"
time = @new_time_with_offset[2012, 1, 1, 0, 0, 0, Rational(36665, 10)]
time.strftime("%::z").should == "+01:01:06"
end
it "rounds an offset to the nearest second when formatting with %z" do
time = @new_time_with_offset[2012, 1, 1, 0, 0, 0, Rational(36645, 10)]
time.strftime("%::z").should == "+01:01:05"
end
end
1 change: 0 additions & 1 deletion spec/ruby/default.mspec
Original file line number Diff line number Diff line change
@@ -48,5 +48,4 @@ class MSpecScript
MSpec.enable_feature :continuation_library
MSpec.enable_feature :fork if respond_to?(:fork, true)
MSpec.enable_feature :encoding
MSpec.enable_feature :readline unless PlatformGuard.windows?
end
46 changes: 26 additions & 20 deletions spec/ruby/library/bigdecimal/inspect_spec.rb
Original file line number Diff line number Diff line change
@@ -11,31 +11,37 @@
@bigdec.inspect.kind_of?(String).should == true
end

it "returns String starting with #" do
@bigdec.inspect[0].should == ?#
end
ruby_version_is ""..."2.4" do
it "returns String starting with #" do
@bigdec.inspect[0].should == ?#
end

it "encloses information in angle brackets" do
@bigdec.inspect.should =~ /^.<.*>$/
end
it "encloses information in angle brackets" do
@bigdec.inspect.should =~ /^.<.*>$/
end

it "is comma separated list of three items" do
@bigdec.inspect.should =~ /...*,.*,.*/
end
it "is comma separated list of three items" do
@bigdec.inspect.should =~ /...*,.*,.*/
end

it "value after first comma is value as string" do
@bigdec.inspect.split(",")[1].should == "\'0.12345678E4\'"
end
it "value after first comma is value as string" do
@bigdec.inspect.split(",")[1].should == "\'0.12345678E4\'"
end

it "last part is number of significant digits" do
signific_string = "#{@bigdec.precs[0]}(#{@bigdec.precs[1]})"
@bigdec.inspect.split(",")[2].should == signific_string + ">"
end
it "last part is number of significant digits" do
signific_string = "#{@bigdec.precs[0]}(#{@bigdec.precs[1]})"
@bigdec.inspect.split(",")[2].should == signific_string + ">"
end

it "looks like this" do
regex = /^\#\<BigDecimal\:.*,'0\.12345678E4',[0-9]+\([0-9]+\)>$/
@bigdec.inspect.should =~ regex
it "looks like this" do
regex = /^\#\<BigDecimal\:.*,'0\.12345678E4',[0-9]+\([0-9]+\)>$/
@bigdec.inspect.should =~ regex
end
end

ruby_version_is "2.4" do
it "looks like this" do
@bigdec.inspect.should == "0.12345678e4"
end
end
end

19 changes: 14 additions & 5 deletions spec/ruby/library/bigdecimal/new_spec.rb
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@
# ^ to_f to avoid Rational type
}
(1..9).each {|i|
BigDecimal.new("100.#{i}").to_s.should == "0.100#{i}E3"
BigDecimal.new("-100.#{i}").to_s.should == "-0.100#{i}E3"
BigDecimal.new("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i
BigDecimal.new("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i
}
end

@@ -32,7 +32,6 @@
BigDecimal.new(" \t\n \rNaN \n").nan?.should == true
BigDecimal.new(" \t\n \rInfinity \n").infinite?.should == 1
BigDecimal.new(" \t\n \r-Infinity \n").infinite?.should == -1
BigDecimal.new(" \t\n \r-\t\t\tInfinity \n").should == 0.0
end

it "ignores trailing garbage" do
@@ -42,8 +41,18 @@
BigDecimal.new("1E2E3E4E5E").should == BigDecimal.new("100")
end

it "treats invalid strings as 0.0" do
BigDecimal.new("ruby").should == BigDecimal.new("0.0")
ruby_version_is ""..."2.4" do
it "treats invalid strings as 0.0" do
BigDecimal.new("ruby").should == BigDecimal.new("0.0")
BigDecimal.new(" \t\n \r-\t\t\tInfinity \n").should == BigDecimal.new("0.0")
end
end

ruby_version_is "2.4" do
it "raises ArgumentError for invalid strings" do
lambda { BigDecimal.new("ruby") }.should raise_error(ArgumentError)
lambda { BigDecimal.new(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError)
end
end

it "allows omitting the integer part" do
2 changes: 1 addition & 1 deletion spec/ruby/library/bigdecimal/sqrt_spec.rb
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
end

it "returns square root of 0.9E-99999 with desired precision" do
@frac_2.sqrt(1).to_s.should == "0.3E-49999"
@frac_2.sqrt(1).to_s.should =~ /\A0\.3E-49999\z/i
end

it "raises ArgumentError when no argument is given" do
11 changes: 6 additions & 5 deletions spec/ruby/library/bigdecimal/to_s_spec.rb
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
end

it "the default format looks like 0.xxxxEnn" do
@bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/
@bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/i
end

it "takes an optional argument" do
@@ -29,9 +29,10 @@
end

it "inserts a space every n chars, if integer n is supplied" do
str =\
"0.314 159 265 358 979 323 846 264 338 327 950 288 419 716 939 937E1"
@bigdec.to_s(3).should == str
re =\
/\A0\.314 159 265 358 979 323 846 264 338 327 950 288 419 716 939 937E1\z/i
@bigdec.to_s(3).should =~ re

str1 = '-123.45678 90123 45678 9'
BigDecimal.new("-123.45678901234567890").to_s('5F').should == str1
# trailing zeroes removed
@@ -58,7 +59,7 @@
end

it "can use engineering notation" do
@bigdec.to_s("E").should =~ /^0\.[0-9]*E[0-9]*$/
@bigdec.to_s("E").should =~ /^0\.[0-9]*E[0-9]*$/i
end

it "can use conventional floating point notation" do
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/basic_quote_characters_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

platform_is_not :darwin do
process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.basic_quote_characters" do
it "returns not nil" do
Readline.basic_quote_characters.should_not be_nil
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.basic_word_break_characters" do
it "returns not nil" do
Readline.basic_word_break_characters.should_not be_nil
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.completer_quote_characters" do
it "returns nil" do
Readline.completer_quote_characters.should be_nil
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.completer_word_break_characters" do
it "returns nil" do
Readline.completer_word_break_characters.should be_nil
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.completion_append_character" do
it "returns not nil" do
Readline.completion_append_character.should_not be_nil
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/completion_case_fold_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.completion_case_fold" do
it "returns nil" do
Readline.completion_case_fold.should be_nil
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/completion_proc_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.completion_proc" do
it "returns nil" do
Readline.completion_proc.should be_nil
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

# Note: additional specs for HISTORY are in 'history' subdir.
describe "Readline::HISTORY" do
it "is defined" do
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/emacs_editing_mode_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

platform_is_not :darwin do
process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.emacs_editing_mode" do
it "returns nil" do
Readline.emacs_editing_mode.should be_nil
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/filename_quote_characters_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

platform_is_not :darwin do
process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.filename_quote_characters" do
it "returns nil" do
Readline.filename_quote_characters.should be_nil
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/append_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.<<" do
it "appends the given Object to the history" do
Readline::HISTORY << "1"
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/delete_at_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.delete_at" do
it "deletes and returns the history entry at the specified index" do
Readline::HISTORY.push("1", "2", "3")
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/each_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.each" do
before :each do
Readline::HISTORY.push("1", "2", "3")
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/element_reference_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.[]" do
before :each do
Readline::HISTORY.push("1", "2", "3")
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/element_set_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.[]=" do
before :each do
Readline::HISTORY.push("1", "2", "3")
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/empty_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.empty?" do
it "returns true when the history is empty" do
Readline::HISTORY.should be_empty
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/history_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY" do
it "is extended with the Enumerable module" do
Readline::HISTORY.should be_kind_of(Enumerable)
3 changes: 1 addition & 2 deletions spec/ruby/library/readline/history/length_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'
require File.expand_path('../shared/size', __FILE__)

describe "Readline::HISTORY.length" do
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/pop_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.pop" do
it "returns nil when the history is empty" do
Readline::HISTORY.pop.should be_nil
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/push_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.push" do
it "pushes all passed Objects into the history" do
Readline::HISTORY.push("1", "2", "3")
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/shift_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.shift" do
it "returns nil when the history is empty" do
Readline::HISTORY.shift.should be_nil
3 changes: 1 addition & 2 deletions spec/ruby/library/readline/history/size_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'
require File.expand_path('../shared/size', __FILE__)

describe "Readline::HISTORY.size" do
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/history/to_s_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline::HISTORY.to_s" do
it "returns 'HISTORY'" do
Readline::HISTORY.to_s.should == "HISTORY"
37 changes: 17 additions & 20 deletions spec/ruby/library/readline/readline_spec.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.readline" do
before :each do
@file = tmp('readline')
File.open(@file, 'w') do |file|
file.puts "test\n"
end
@stdin_back = STDIN.dup
@stdout_back = STDOUT.dup
STDIN.reopen(@file, 'r')
STDOUT.reopen("/dev/null")
@out = tmp('out.txt')
touch(@file) { |f|
f.puts "test"
}
@options = { options: "-rreadline", args: [@out, "< #{@file}"] }
end

after :each do
rm_r @file
STDIN.reopen(@stdin_back)
@stdin_back.close
STDOUT.reopen(@stdout_back)
@stdout_back.close
rm_r @file, @out
end

it "returns the input string" do
Readline.readline.should == "test"
end
# Somehow those specs block on Windows
platform_is_not :windows do
it "returns the input string" do
ruby_exe('File.write ARGV[0], Readline.readline', @options)
File.read(@out).should == "test"
end

it "taints the returned strings" do
Readline.readline.tainted?.should be_true
it "taints the returned strings" do
ruby_exe('File.write ARGV[0], Readline.readline.tainted?', @options)
File.read(@out).should == "true"
end
end
end
end
12 changes: 12 additions & 0 deletions spec/ruby/library/readline/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.expand_path('../../../spec_helper', __FILE__)
unless MSpec.retrieve(:features).key?(:readline)
begin
require 'readline'
rescue LoadError
else
# rb-readline behaves quite differently
if $".grep(/\brbreadline\.rb$/).empty?
MSpec.enable_feature :readline
end
end
end
4 changes: 1 addition & 3 deletions spec/ruby/library/readline/vi_editing_mode_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../spec_helper', __FILE__)

platform_is_not :darwin do
process_is_foreground do
with_feature :readline do
require 'readline'

describe "Readline.vi_editing_mode" do
it "returns nil" do
Readline.vi_editing_mode.should be_nil
14 changes: 14 additions & 0 deletions spec/ruby/library/socket/basicsocket/recv_spec.rb
Original file line number Diff line number Diff line change
@@ -76,4 +76,18 @@
ScratchPad.recorded.should == "firstline\377"
end

ruby_version_is "2.3" do
it "allows an output buffer as third argument" do
socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
socket.write("data")

client = @server.accept
buf = "foo"
client.recv(4, 0, buf)
client.close
buf.should == "data"

socket.close
end
end
end
3 changes: 3 additions & 0 deletions spec/ruby/library/socket/shared/pack_sockaddr.rb
Original file line number Diff line number Diff line change
@@ -38,8 +38,11 @@
path = Socket.unpack_sockaddr_un(sockaddr_un).encode('UTF-8', 'UTF-8')
path.should == '/home/вася/sock'
end
end

platform_is_not :windows, :aix do
it "raises if path length exceeds max size" do
# AIX doesn't raise error
long_path = Array.new(512, 0).join
lambda { Socket.public_send(@method, long_path) }.should raise_error(ArgumentError)
end
12 changes: 12 additions & 0 deletions spec/ruby/library/socket/shared/recv_nonblock.rb
Original file line number Diff line number Diff line change
@@ -31,6 +31,18 @@
@s1.recv_nonblock(5).should == "aaa"
end

ruby_version_is "2.3" do
it "allows an output buffer as third argument" do
@s1.bind(Socket.pack_sockaddr_in(SocketSpecs.port, "127.0.0.1"))
@s2.send("data", 0, @s1.getsockname)
IO.select([@s1], nil, nil, 2)

buf = "foo"
@s1.recv_nonblock(5, 0, buf)
buf.should == "data"
end
end

it "does not block if there's no data available" do
@s1.bind(Socket.pack_sockaddr_in(SocketSpecs.port, "127.0.0.1"))
@s2.send("a", 0, @s1.getsockname)
6 changes: 6 additions & 0 deletions spec/ruby/library/socket/socket/accept_nonblock_spec.rb
Original file line number Diff line number Diff line change
@@ -28,4 +28,10 @@
end
}
end

ruby_version_is '2.3' do
it 'returns :wait_readable in exceptionless mode' do
@socket.accept_nonblock(exception: false).should == :wait_readable
end
end
end
5 changes: 4 additions & 1 deletion spec/ruby/library/socket/tcpserver/new_spec.rb
Original file line number Diff line number Diff line change
@@ -85,9 +85,12 @@ def t.to_str; SocketSpecs.port.to_s; end
}.should raise_error(Errno::EADDRINUSE)
end

platform_is_not :windows do
platform_is_not :windows, :aix do
# A known bug in AIX. getsockopt(2) does not properly set
# the fifth argument for SO_REUSEADDR.
it "sets SO_REUSEADDR on the resulting server" do
@server = TCPServer.new('127.0.0.1', SocketSpecs.port)
@server.getsockopt(:SOCKET, :REUSEADDR).data.should_not == "\x00\x00\x00\x00"
@server.getsockopt(:SOCKET, :REUSEADDR).int.should_not == 0
end
end
7 changes: 7 additions & 0 deletions spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb
Original file line number Diff line number Diff line change
@@ -26,4 +26,11 @@
IO.select([@socket])
@socket.recv_nonblock(50).should == "TCPSocket#recv_nonblock"
end

ruby_version_is '2.3' do
it 'returns :wait_readable in exceptionless mode' do
@socket = TCPSocket.new @hostname, SocketSpecs.port
@socket.recv_nonblock(50, exception: false).should == :wait_readable
end
end
end
14 changes: 2 additions & 12 deletions spec/ruby/library/socket/udpsocket/new_spec.rb
Original file line number Diff line number Diff line change
@@ -26,17 +26,7 @@
@socket.should be_an_instance_of(UDPSocket)
end

platform_is_not :solaris do
it 'raises Errno::EAFNOSUPPORT if unsupported family passed' do
lambda { UDPSocket.new(-1) }.should raise_error(Errno::EAFNOSUPPORT)
end
end

platform_is :solaris do
# Solaris throws error EPROTONOSUPPORT if the protocol family is not recognized.
# https://docs.oracle.com/cd/E19253-01/816-5170/socket-3socket/index.html
it 'raises Errno::EPROTONOSUPPORT if unsupported family passed' do
lambda { UDPSocket.new(-1) }.should raise_error(Errno::EPROTONOSUPPORT)
end
it 'raises Errno::EAFNOSUPPORT if unsupported family passed' do
lambda { UDPSocket.new(-1) }.should raise_error(Errno::EAFNOSUPPORT)
end
end
6 changes: 6 additions & 0 deletions spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb
Original file line number Diff line number Diff line change
@@ -30,5 +30,11 @@
it "returns a UNIXSocket" do
@socket.should be_kind_of(UNIXSocket)
end

ruby_version_is '2.3' do
it 'returns :wait_readable in exceptionless mode' do
@server.accept_nonblock(exception: false).should == :wait_readable
end
end
end
end
15 changes: 13 additions & 2 deletions spec/ruby/library/stringio/external_encoding_spec.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,18 @@
describe "StringIO#external_encoding" do
it "gets the encoding of the underlying String" do
io = StringIO.new
io.set_encoding Encoding::UTF_8
io.external_encoding.should == Encoding::UTF_8
io.set_encoding Encoding::EUC_JP
io.external_encoding.should == Encoding::EUC_JP
end

ruby_version_is "2.3" do
it "does not set the encoding of its buffer string if the string is frozen" do
str = "foo".freeze
enc = str.encoding
io = StringIO.new(str)
io.set_encoding Encoding::EUC_JP
io.external_encoding.should == Encoding::EUC_JP
str.encoding.should == enc
end
end
end
1 change: 1 addition & 0 deletions spec/ruby/optional/capi/ext/rubyspec.h
Original file line number Diff line number Diff line change
@@ -602,6 +602,7 @@
#define HAVE_RB_TIME_TIMEVAL 1
#define HAVE_RB_TIME_TIMESPEC 1
#ifdef RUBY_VERSION_IS_2_3
#define HAVE_RB_TIMESPEC_NOW 1
#define HAVE_RB_TIME_TIMESPEC_NEW 1
#endif

13 changes: 13 additions & 0 deletions spec/ruby/optional/capi/ext/time_spec.c
Original file line number Diff line number Diff line change
@@ -65,6 +65,15 @@ static VALUE time_spec_rb_time_timespec_new(VALUE self, VALUE sec, VALUE nsec, V
}
#endif

#ifdef HAVE_RB_TIMESPEC_NOW
static VALUE time_spec_rb_time_from_timspec_now(VALUE self, VALUE offset) {
struct timespec ts;
rb_timespec_now(&ts);

return rb_time_timespec_new(&ts, NUM2INT(offset));
}
#endif

#ifdef HAVE_TIMET2NUM
static VALUE time_spec_TIMET2NUM(VALUE self) {
time_t t = 10;
@@ -107,6 +116,10 @@ void Init_time_spec(void) {
#ifdef HAVE_RB_TIME_TIMESPEC_NEW
rb_define_method(cls, "rb_time_timespec_new", time_spec_rb_time_timespec_new, 3);
#endif

#ifdef HAVE_RB_TIMESPEC_NOW
rb_define_method(cls, "rb_time_from_timespec", time_spec_rb_time_from_timspec_now, 1);
#endif
}

#ifdef __cplusplus
8 changes: 7 additions & 1 deletion spec/ruby/optional/capi/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -86,8 +86,9 @@ def compile_extension(name)
ldshared += " #{RbConfig::CONFIG["ARCH_FLAG"]}" if RbConfig::CONFIG["ARCH_FLAG"]
libpath = "-L#{path}"
libs = RbConfig::CONFIG["LIBS"]
dldflags = "#{RbConfig::CONFIG["LDFLAGS"]} #{RbConfig::CONFIG["DLDFLAGS"]}"
dldflags = "#{RbConfig::CONFIG["LDFLAGS"]} #{RbConfig::CONFIG["DLDFLAGS"]} #{RbConfig::CONFIG["EXTDLDFLAGS"]}"
dldflags.sub!(/-Wl,-soname,\S+/, '')
dldflags.sub!("$(TARGET_ENTRY)", "Init_#{ext}")

link_cmd = "#{ldshared} #{obj} #{libpath} #{dldflags} #{libs} -o #{lib}"
output = `#{link_cmd}`
@@ -148,6 +149,11 @@ def compile_jruby_truffle_extconf_make(name, path, objdir)

def load_extension(name)
require compile_extension(name)
rescue LoadError
if %r{/usr/sbin/execerror ruby "\(ld 3 1 main ([/a-zA-Z0-9_\-.]+_spec\.so)"} =~ $!.message
system('/usr/sbin/execerror', "#{RbConfig::CONFIG["bindir"]}/ruby", "(ld 3 1 main #{$1}")
end
raise
end

# Constants
9 changes: 9 additions & 0 deletions spec/ruby/optional/capi/time_spec.rb
Original file line number Diff line number Diff line change
@@ -283,5 +283,14 @@
lambda { @s.rb_time_timespec_new(1447087832, 476451125, -86400) }.should raise_error(ArgumentError)
end
end

describe "rb_timespec_now" do
it "fills a struct timespec with the current time" do
now = Time.now
time = @s.rb_time_from_timespec(now.utc_offset)
time.should be_an_instance_of(Time)
(time - now).should be_close(0, 10)
end
end
end
end
27 changes: 7 additions & 20 deletions spec/ruby/shared/rational/round.rb
Original file line number Diff line number Diff line change
@@ -18,26 +18,13 @@
Rational(2, 1).round(0).should == 2
end

ruby_version_is ""..."2.4" do
it "returns the rounded value toward the nearest integer" do
Rational(1, 2).round.should == 1
Rational(-1, 2).round.should == -1
Rational(3, 2).round.should == 2
Rational(-3, 2).round.should == -2
Rational(5, 2).round.should == 3
Rational(-5, 2).round.should == -3
end
end

ruby_version_is "2.4" do
it "returns the rounded value toward the nearest even integer" do
Rational(1, 2).round.should == 0
Rational(-1, 2).round.should == 0
Rational(3, 2).round.should == 2
Rational(-3, 2).round.should == -2
Rational(5, 2).round.should == 2
Rational(-5, 2).round.should == -2
end
it "returns the rounded value toward the nearest integer" do
Rational(1, 2).round.should == 1
Rational(-1, 2).round.should == -1
Rational(3, 2).round.should == 2
Rational(-3, 2).round.should == -2
Rational(5, 2).round.should == 3
Rational(-5, 2).round.should == -3
end
end

1 change: 1 addition & 0 deletions spec/tags/ruby/library/socket/basicsocket/recv_tags.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fails:BasicSocket#recv accepts flags to specify unusual receiving behaviour
fails:BasicSocket#recv allows an output buffer as third argument
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fails:Socket#accept_nonblock raises IO::WaitReadable if the connection is not accepted yet
fails:Socket#accept_nonblock returns :wait_readable in exceptionless mode
3 changes: 3 additions & 0 deletions spec/truffle/tags/core/file/open_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
fails:File.open opens a file with a file descriptor d and a block
fails:File.open with a block propagates StandardErrors produced by close
slow:File.open on a FIFO opens it as a normal file
fails:File.open creates an unnamed temporary file with File::TMPFILE
fails:File.open accepts extra flags as a keyword argument and combine with a string mode
fails:File.open accepts extra flags as a keyword argument and combine with an integer mode
1 change: 1 addition & 0 deletions spec/truffle/tags/library/socket/basicsocket/recv_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fails:BasicSocket#recv receives a specified number of bytes of a message from another socket
fails:BasicSocket#recv accepts flags to specify unusual receiving behaviour
fails:BasicSocket#recv gets lines delimited with a custom separator
fails:BasicSocket#recv allows an output buffer as third argument
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fails:Socket#accept_nonblock raises IO::WaitReadable if the connection is not accepted yet
fails:Socket#accept_nonblock returns :wait_readable in exceptionless mode
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fails:TCPSocket#recv_nonblock returns a String read from the socket
fails:TCPSocket#recv_nonblock returns :wait_readable in exceptionless mode
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fails:UNIXServer#accept_nonblock accepts a connection in a non-blocking way
fails:UNIXServer#accept_nonblock returns a UNIXSocket
fails:UNIXServer#accept_nonblock returns :wait_readable in exceptionless mode
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:StringIO#external_encoding does not set the encoding of its buffer string if the string is frozen
17 changes: 17 additions & 0 deletions test/jruby/test_dir.rb
Original file line number Diff line number Diff line change
@@ -243,6 +243,23 @@ def test_mkdir_within_classloader
end
end

def test_stat_directory_in_jar_with_trailing_slash
jar_file = File.expand_path('../jar_with_relative_require1.jar', __FILE__)
$CLASSPATH << jar_file
source_file = "jar:file:#{jar_file}!/test/require_relative1.rb"
assert File.exist?(source_file), "test is wrong, #{source_file} doesn't even exist"
assert_equal false, File.directory?(source_file)
assert_equal false, File.directory?(source_file + "/")
assert_raise(Errno::ENOENT) do
File.stat(source_file + "/")
end
source_dir = File.dirname(source_file)
assert File.directory?(source_dir), "#{source_dir} not found"
source_dir += "/"
assert File.directory?(source_dir), "#{source_dir} claims to not be a directory"
assert_equal true, File.stat(source_dir).directory?
end

# JRUBY-4983
def test_entries_unicode
utf8_dir = "testDir_1/glk\u00a9"

0 comments on commit aa0ab9e

Please sign in to comment.