summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-14 14:09:56 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-14 14:09:56 +0000
commita5b83b03adc3f457f8e148fe41b1ff0b3e29ca69 (patch)
treeb04c8801ead64cdd408f383166b88a693bfb0c10 /spec
parentd593aed7b7ffafbd81d0ec7cf306f10ac91830e7 (diff)
Update to ruby/spec@032022ca
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/rubyspec/command_line/dash_upper_s_spec.rb19
-rw-r--r--spec/rubyspec/command_line/dash_x_spec.rb17
-rw-r--r--spec/rubyspec/command_line/fixtures/bin/bad_embedded_ruby.txt3
-rw-r--r--spec/rubyspec/command_line/fixtures/bin/embedded_ruby.txt (renamed from spec/rubyspec/command_line/fixtures/embedded_ruby.txt)0
-rw-r--r--spec/rubyspec/command_line/fixtures/bin/hybrid_launcher.sh4
-rw-r--r--spec/rubyspec/command_line/fixtures/bin/launcher.rb2
-rw-r--r--spec/rubyspec/core/bignum/bit_and_spec.rb4
-rw-r--r--spec/rubyspec/core/binding/eval_spec.rb10
-rw-r--r--spec/rubyspec/core/binding/fixtures/classes.rb8
-rw-r--r--spec/rubyspec/core/binding/local_variable_get_spec.rb11
-rw-r--r--spec/rubyspec/core/binding/local_variable_set_spec.rb12
-rw-r--r--spec/rubyspec/core/binding/shared/clone.rb28
-rw-r--r--spec/rubyspec/core/fiber/yield_spec.rb15
-rw-r--r--spec/rubyspec/core/file/fixtures/file_types.rb27
-rw-r--r--spec/rubyspec/core/file/ftype_spec.rb6
-rw-r--r--spec/rubyspec/core/file/stat/ftype_spec.rb7
-rw-r--r--spec/rubyspec/core/fixnum/bit_and_spec.rb15
-rw-r--r--spec/rubyspec/core/io/advise_spec.rb21
-rw-r--r--spec/rubyspec/core/process/exec_spec.rb4
-rw-r--r--spec/rubyspec/core/process/spawn_spec.rb4
-rw-r--r--spec/rubyspec/core/time/minus_spec.rb6
-rw-r--r--spec/rubyspec/language/block_spec.rb4
-rw-r--r--spec/rubyspec/language/defined_spec.rb20
-rw-r--r--spec/rubyspec/language/heredoc_spec.rb4
-rw-r--r--spec/rubyspec/language/regexp/character_classes_spec.rb7
-rw-r--r--spec/rubyspec/language/regexp_spec.rb2
-rw-r--r--spec/rubyspec/language/variables_spec.rb56
-rw-r--r--spec/rubyspec/language/while_spec.rb4
-rw-r--r--spec/rubyspec/library/socket/fixtures/classes.rb13
-rw-r--r--spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb4
-rw-r--r--spec/rubyspec/library/socket/unixserver/accept_spec.rb7
-rw-r--r--spec/rubyspec/library/socket/unixserver/for_fd_spec.rb4
-rw-r--r--spec/rubyspec/library/socket/unixserver/open_spec.rb5
-rw-r--r--spec/rubyspec/library/socket/unixserver/shared/new.rb5
-rw-r--r--spec/rubyspec/library/socket/unixsocket/addr_spec.rb4
-rw-r--r--spec/rubyspec/library/socket/unixsocket/open_spec.rb2
-rw-r--r--spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb3
-rw-r--r--spec/rubyspec/library/socket/unixsocket/path_spec.rb4
-rw-r--r--spec/rubyspec/library/socket/unixsocket/peeraddr_spec.rb4
-rw-r--r--spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb2
-rw-r--r--spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb4
-rw-r--r--spec/rubyspec/library/socket/unixsocket/send_io_spec.rb2
-rw-r--r--spec/rubyspec/library/socket/unixsocket/shared/new.rb2
-rw-r--r--spec/rubyspec/optional/capi/bignum_spec.rb7
-rw-r--r--spec/rubyspec/optional/capi/mutex_spec.rb2
-rw-r--r--spec/rubyspec/optional/capi/spec_helper.rb20
-rw-r--r--spec/rubyspec/shared/time/strftime_for_date.rb12
47 files changed, 254 insertions, 172 deletions
diff --git a/spec/rubyspec/command_line/dash_upper_s_spec.rb b/spec/rubyspec/command_line/dash_upper_s_spec.rb
new file mode 100644
index 0000000000..d0547a3630
--- /dev/null
+++ b/spec/rubyspec/command_line/dash_upper_s_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe 'The -S command line option' do
+ before :each do
+ @path = [ENV['PATH'], fixture(__FILE__, "bin")].join(':')
+ end
+
+ platform_is_not :windows do
+ it "runs launcher found in PATH, but only code after the first /\#!.*ruby.*/-ish line in target file" do
+ result = ruby_exe(nil, options: '-S hybrid_launcher.sh', env: { 'PATH' => @path }, args: '2>&1')
+ result.should == "success\n"
+ end
+
+ it "runs launcher found in PATH" do
+ result = ruby_exe(nil, options: '-S launcher.rb', env: { 'PATH' => @path }, args: '2>&1')
+ result.should == "success\n"
+ end
+ end
+end
diff --git a/spec/rubyspec/command_line/dash_x_spec.rb b/spec/rubyspec/command_line/dash_x_spec.rb
index 96b5d01156..a5306b4f75 100644
--- a/spec/rubyspec/command_line/dash_x_spec.rb
+++ b/spec/rubyspec/command_line/dash_x_spec.rb
@@ -1,10 +1,19 @@
describe "The -x command line option" do
- before :each do
- @file = fixture __FILE__, "embedded_ruby.txt"
+ it "runs code after the first /\#!.*ruby.*/-ish line in target file" do
+ embedded_ruby = fixture __FILE__, "bin/embedded_ruby.txt"
+ result = ruby_exe(embedded_ruby, options: '-x')
+ result.should == "success\n"
end
- it "runs code after the first /\#!.*ruby.*/-ish line in target file" do
- result = ruby_exe(@file, options: '-x')
+ it "fails when /\#!.*ruby.*/-ish line in target file is not found" do
+ bad_embedded_ruby = fixture __FILE__, "bin/bad_embedded_ruby.txt"
+ result = ruby_exe(bad_embedded_ruby, options: '-x', args: '2>&1')
+ result.should include "no Ruby script found in input"
+ end
+
+ it "behaves as -x was set when non-ruby shebang is encountered on first line" do
+ embedded_ruby = fixture __FILE__, "bin/hybrid_launcher.sh"
+ result = ruby_exe(embedded_ruby)
result.should == "success\n"
end
diff --git a/spec/rubyspec/command_line/fixtures/bin/bad_embedded_ruby.txt b/spec/rubyspec/command_line/fixtures/bin/bad_embedded_ruby.txt
new file mode 100644
index 0000000000..a2b7ad085f
--- /dev/null
+++ b/spec/rubyspec/command_line/fixtures/bin/bad_embedded_ruby.txt
@@ -0,0 +1,3 @@
+@@@This line is not value Ruby
+#!rub_y
+puts 'success'
diff --git a/spec/rubyspec/command_line/fixtures/embedded_ruby.txt b/spec/rubyspec/command_line/fixtures/bin/embedded_ruby.txt
index c556bf0b71..c556bf0b71 100644
--- a/spec/rubyspec/command_line/fixtures/embedded_ruby.txt
+++ b/spec/rubyspec/command_line/fixtures/bin/embedded_ruby.txt
diff --git a/spec/rubyspec/command_line/fixtures/bin/hybrid_launcher.sh b/spec/rubyspec/command_line/fixtures/bin/hybrid_launcher.sh
new file mode 100644
index 0000000000..0eede2a99f
--- /dev/null
+++ b/spec/rubyspec/command_line/fixtures/bin/hybrid_launcher.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+exec somehow this file
+#!ruby
+puts 'success'
diff --git a/spec/rubyspec/command_line/fixtures/bin/launcher.rb b/spec/rubyspec/command_line/fixtures/bin/launcher.rb
new file mode 100644
index 0000000000..92a0ee2b49
--- /dev/null
+++ b/spec/rubyspec/command_line/fixtures/bin/launcher.rb
@@ -0,0 +1,2 @@
+#!ruby
+puts 'success'
diff --git a/spec/rubyspec/core/bignum/bit_and_spec.rb b/spec/rubyspec/core/bignum/bit_and_spec.rb
index 6eca0e56f0..4bc5c11e1b 100644
--- a/spec/rubyspec/core/bignum/bit_and_spec.rb
+++ b/spec/rubyspec/core/bignum/bit_and_spec.rb
@@ -16,8 +16,8 @@ describe "Bignum#&" do
end
it "returns self bitwise AND other when one operand is negative" do
- ((2*bignum_value) & -1).should == 18446744073709551616
- ((4*bignum_value) & -1).should == 36893488147419103232
+ ((2*bignum_value) & -1).should == (2*bignum_value)
+ ((4*bignum_value) & -1).should == (4*bignum_value)
(@bignum & -0xffffffffffffff5).should == 9223372036854775809
(@bignum & -@bignum).should == 1
(@bignum & -0x8000000000000000).should == 9223372036854775808
diff --git a/spec/rubyspec/core/binding/eval_spec.rb b/spec/rubyspec/core/binding/eval_spec.rb
index cedd5fcdf9..4864b9f61f 100644
--- a/spec/rubyspec/core/binding/eval_spec.rb
+++ b/spec/rubyspec/core/binding/eval_spec.rb
@@ -13,6 +13,16 @@ describe "Binding#eval" do
bind.eval("Inside.name").should == "BindingSpecs::Demo::Inside"
end
+ it "does not leak variables to cloned bindings" do
+ obj = BindingSpecs::Demo.new(1)
+ bind = obj.get_empty_binding
+ bind2 = bind.dup
+
+ bind.eval("x = 72")
+ bind.local_variables.should == [:x]
+ bind2.local_variables.should == []
+ end
+
describe "with a file given" do
it "does not store the filename permanently" do
obj = BindingSpecs::Demo.new(1)
diff --git a/spec/rubyspec/core/binding/fixtures/classes.rb b/spec/rubyspec/core/binding/fixtures/classes.rb
index b7b7618411..05ca2479ba 100644
--- a/spec/rubyspec/core/binding/fixtures/classes.rb
+++ b/spec/rubyspec/core/binding/fixtures/classes.rb
@@ -28,5 +28,13 @@ module BindingSpecs
def get_empty_binding
binding
end
+
+ def get_binding_in_block
+ a = true
+ 1.times do
+ b = false
+ return binding
+ end
+ end
end
end
diff --git a/spec/rubyspec/core/binding/local_variable_get_spec.rb b/spec/rubyspec/core/binding/local_variable_get_spec.rb
index b7b0b14594..e65d08130e 100644
--- a/spec/rubyspec/core/binding/local_variable_get_spec.rb
+++ b/spec/rubyspec/core/binding/local_variable_get_spec.rb
@@ -42,4 +42,15 @@ describe "Binding#local_variable_get" do
bind.local_variable_get(:number).should == 10
end
+
+ it "raises a NameError on global access" do
+ bind = binding
+ lambda { bind.local_variable_get(:$0) }.should raise_error(NameError)
+ end
+
+ it "raises a NameError on special variable access" do
+ bind = binding
+ lambda { bind.local_variable_get(:$~) }.should raise_error(NameError)
+ lambda { bind.local_variable_get(:$_) }.should raise_error(NameError)
+ end
end
diff --git a/spec/rubyspec/core/binding/local_variable_set_spec.rb b/spec/rubyspec/core/binding/local_variable_set_spec.rb
index 4b14d891b3..067dcbd03e 100644
--- a/spec/rubyspec/core/binding/local_variable_set_spec.rb
+++ b/spec/rubyspec/core/binding/local_variable_set_spec.rb
@@ -56,4 +56,16 @@ describe "Binding#local_variable_set" do
bind.local_variable_set(:number, 20)
bind.local_variable_get(:number).should == 20
end
+
+ it "raises a NameError on global access" do
+ bind = binding
+ lambda { bind.local_variable_set(:$0, "") }.should raise_error(NameError)
+ end
+
+ it "raises a NameError on special variable access" do
+ bind = binding
+ lambda { bind.local_variable_set(:$~, "") }.should raise_error(NameError)
+ lambda { bind.local_variable_set(:$_, "") }.should raise_error(NameError)
+ end
+
end
diff --git a/spec/rubyspec/core/binding/shared/clone.rb b/spec/rubyspec/core/binding/shared/clone.rb
index 723e0490c3..0e934ac1b5 100644
--- a/spec/rubyspec/core/binding/shared/clone.rb
+++ b/spec/rubyspec/core/binding/shared/clone.rb
@@ -2,19 +2,33 @@ describe :binding_clone, shared: true do
before :each do
@b1 = BindingSpecs::Demo.new(99).get_binding
@b2 = @b1.send(@method)
+ @b3 = BindingSpecs::Demo.new(99).get_binding_in_block
+ @b4 = @b3.send(@method)
end
it "returns a copy of the Binding object" do
- @b1.should_not == @b2
+ [[@b1, @b2, "a"],
+ [@b3, @b4, "a", "b"]].each do |b1, b2, *vars|
+ b1.should_not == b2
- eval("@secret", @b1).should == eval("@secret", @b2)
- eval("square(2)", @b1).should == eval("square(2)", @b2)
- eval("self.square(2)", @b1).should == eval("self.square(2)", @b2)
- eval("a", @b1).should == eval("a", @b2)
+ eval("@secret", b1).should == eval("@secret", b2)
+ eval("square(2)", b1).should == eval("square(2)", b2)
+ eval("self.square(2)", b1).should == eval("self.square(2)", b2)
+ vars.each do |v|
+ eval("#{v}", b1).should == eval("#{v}", b2)
+ end
+ end
end
it "is a shallow copy of the Binding object" do
- eval("a = false", @b1)
- eval("a", @b2).should == false
+ [[@b1, @b2, "a"],
+ [@b3, @b4, "a", "b"]].each do |b1, b2, *vars|
+ vars.each do |v|
+ eval("#{v} = false", b1)
+ eval("#{v}", b2).should == false
+ end
+ b1.local_variable_set(:x, 37)
+ b2.local_variable_defined?(:x).should == false
+ end
end
end
diff --git a/spec/rubyspec/core/fiber/yield_spec.rb b/spec/rubyspec/core/fiber/yield_spec.rb
index 45054e9cec..e433da0aa9 100644
--- a/spec/rubyspec/core/fiber/yield_spec.rb
+++ b/spec/rubyspec/core/fiber/yield_spec.rb
@@ -29,6 +29,21 @@ with_feature :fiber do
fiber.resume :caller
end
+ it "does not propagate or reraise a rescued exception" do
+ fiber = Fiber.new do
+ begin
+ raise "an error in a Fiber"
+ rescue
+ Fiber.yield :first
+ end
+
+ :second
+ end
+
+ fiber.resume.should == :first
+ fiber.resume.should == :second
+ end
+
it "raises a FiberError if called from the root Fiber" do
lambda{ Fiber.yield }.should raise_error(FiberError)
end
diff --git a/spec/rubyspec/core/file/fixtures/file_types.rb b/spec/rubyspec/core/file/fixtures/file_types.rb
index 1c446b33a6..36a5ff1a95 100644
--- a/spec/rubyspec/core/file/fixtures/file_types.rb
+++ b/spec/rubyspec/core/file/fixtures/file_types.rb
@@ -1,6 +1,7 @@
module FileSpecs
- # Try to set up known locations of each filetype
- def self.reconfigure()
+ def self.configure_types
+ return if @configured
+
@file = tmp("test.txt")
@dir = Dir.pwd
@fifo = tmp("test_fifo")
@@ -15,45 +16,43 @@ module FileSpecs
@link = links.first
break
end
-
end
- end
- # TODO: Automatic reload mechanism
- reconfigure
+ @configured = true
+ end
- def self.normal_file()
- File.open(@file, "w") {} # 'Touch'
+ def self.normal_file
+ touch(@file)
yield @file
ensure
rm_r @file
end
- def self.directory()
+ def self.directory
yield @dir
end
# TODO: need a platform-independent helper here
- def self.fifo()
+ def self.fifo
system "mkfifo #{@fifo} 2> /dev/null"
yield @fifo
ensure
rm_r @fifo
end
- def self.block_device()
+ def self.block_device
yield @block
end
- def self.character_device()
+ def self.character_device
yield @char
end
- def self.symlink()
+ def self.symlink
yield @link
end
- def self.socket()
+ def self.socket
require 'socket'
name = tmp("ftype_socket.socket")
rm_r name
diff --git a/spec/rubyspec/core/file/ftype_spec.rb b/spec/rubyspec/core/file/ftype_spec.rb
index 79ed1d5b45..7c010b3e9c 100644
--- a/spec/rubyspec/core/file/ftype_spec.rb
+++ b/spec/rubyspec/core/file/ftype_spec.rb
@@ -1,7 +1,11 @@
require "#{File.dirname(__FILE__)}/../../spec_helper"
-require "#{File.dirname(__FILE__)}/fixtures/file_types.rb"
+require "#{File.dirname(__FILE__)}/fixtures/file_types"
describe "File.ftype" do
+ before :all do
+ FileSpecs.configure_types
+ end
+
it "raises ArgumentError if not given exactly one filename" do
lambda { File.ftype }.should raise_error(ArgumentError)
lambda { File.ftype('blah', 'bleh') }.should raise_error(ArgumentError)
diff --git a/spec/rubyspec/core/file/stat/ftype_spec.rb b/spec/rubyspec/core/file/stat/ftype_spec.rb
index c20109765b..588c371c39 100644
--- a/spec/rubyspec/core/file/stat/ftype_spec.rb
+++ b/spec/rubyspec/core/file/stat/ftype_spec.rb
@@ -1,7 +1,11 @@
require "#{File.dirname(__FILE__)}/../../../spec_helper"
-require "#{File.dirname(__FILE__)}/../fixtures/file_types.rb"
+require "#{File.dirname(__FILE__)}/../fixtures/file_types"
describe "File::Stat#ftype" do
+ before :all do
+ FileSpecs.configure_types
+ end
+
it "returns a String" do
FileSpecs.normal_file do |file|
File.lstat(file).ftype.should be_kind_of(String)
@@ -62,4 +66,3 @@ describe "File::Stat#ftype" do
end
end
end
-
diff --git a/spec/rubyspec/core/fixnum/bit_and_spec.rb b/spec/rubyspec/core/fixnum/bit_and_spec.rb
index 17fd8f81f5..ff0e597a52 100644
--- a/spec/rubyspec/core/fixnum/bit_and_spec.rb
+++ b/spec/rubyspec/core/fixnum/bit_and_spec.rb
@@ -8,6 +8,21 @@ describe "Fixnum#&" do
(0xffff & bignum_value + 0xffff_ffff).should == 65535
end
+ it "returns self bitwise AND other when one operand is negative" do
+ ((1 << 33) & -1).should == (1 << 33)
+ (-1 & (1 << 33)).should == (1 << 33)
+
+ ((-(1<<33)-1) & 5).should == 5
+ (5 & (-(1<<33)-1)).should == 5
+ end
+
+ it "returns self bitwise AND other when both operands are negative" do
+ (-5 & -1).should == -5
+ (-3 & -4).should == -4
+ (-12 & -13).should == -16
+ (-13 & -12).should == -16
+ end
+
it "returns self bitwise AND a Bignum" do
(-1 & 2**64).should == 18446744073709551616
end
diff --git a/spec/rubyspec/core/io/advise_spec.rb b/spec/rubyspec/core/io/advise_spec.rb
index bd3bf24bec..460b50a59d 100644
--- a/spec/rubyspec/core/io/advise_spec.rb
+++ b/spec/rubyspec/core/io/advise_spec.rb
@@ -74,16 +74,17 @@ describe "IO#advise" do
end
platform_is :linux do
- require 'etc'
- uname = if Etc.respond_to?(:uname)
- Etc.uname[:release]
- else
- `uname -r`.chomp
- end
- if (uname.split('.').map(&:to_i) <=> [3,6]) < 0
- # [ruby-core:65355] tmpfs is not supported
- else
- it "supports the willneed advice type" do
+ it "supports the willneed advice type" do
+ require 'etc'
+ uname = if Etc.respond_to?(:uname)
+ Etc.uname[:release]
+ else
+ `uname -r`.chomp
+ end
+ if (uname.split('.').map(&:to_i) <=> [3,6]) < 0
+ # [ruby-core:65355] tmpfs is not supported
+ 1.should == 1
+ else
@io.advise(:willneed).should be_nil
end
end
diff --git a/spec/rubyspec/core/process/exec_spec.rb b/spec/rubyspec/core/process/exec_spec.rb
index baf9d81c10..b4eddf526e 100644
--- a/spec/rubyspec/core/process/exec_spec.rb
+++ b/spec/rubyspec/core/process/exec_spec.rb
@@ -22,7 +22,9 @@ describe "Process.exec" do
platform_is :windows do
it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do
- lambda { Process.exec __FILE__ }.should raise_error(->(e){[Errno::EACCES, Errno::ENOEXEC].find{|exc| exc === e}})
+ lambda { Process.exec __FILE__ }.should raise_error(SystemCallError) { |e|
+ [Errno::EACCES, Errno::ENOEXEC].should include(e.class)
+ }
end
end
end
diff --git a/spec/rubyspec/core/process/spawn_spec.rb b/spec/rubyspec/core/process/spawn_spec.rb
index bd3d13f97e..66b5c5e402 100644
--- a/spec/rubyspec/core/process/spawn_spec.rb
+++ b/spec/rubyspec/core/process/spawn_spec.rb
@@ -576,7 +576,9 @@ describe "Process.spawn" do
platform_is :windows do
it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do
- lambda { Process.spawn __FILE__ }.should raise_error(->(e){[Errno::EACCES, Errno::ENOEXEC].find{|exc| exc === e}})
+ lambda { Process.spawn __FILE__ }.should raise_error(SystemCallError) { |e|
+ [Errno::EACCES, Errno::ENOEXEC].should include(e.class)
+ }
end
end
end
diff --git a/spec/rubyspec/core/time/minus_spec.rb b/spec/rubyspec/core/time/minus_spec.rb
index e4363e2467..4e2bb60333 100644
--- a/spec/rubyspec/core/time/minus_spec.rb
+++ b/spec/rubyspec/core/time/minus_spec.rb
@@ -41,7 +41,7 @@ describe "Time#-" do
time.usec.should == 123456
end
- it "tracks microseconds" do
+ it "tracks microseconds from a Rational" do
time = Time.at(Rational(777_777, 1_000_000))
time -= Rational(654_321, 1_000_000)
time.usec.should == 123_456
@@ -63,12 +63,12 @@ describe "Time#-" do
end
it "maintains microseconds precision" do
- time = Time.at(10) - Rational(1_000_000_000_000_001, 1_000_000_000_000_000)
+ time = Time.at(10) - Rational(1, 1_000_000)
time.usec.should == 999_999
end
it "maintains nanoseconds precision" do
- time = Time.at(10) - Rational(1_000_000_000_000_001, 1_000_000_000_000_000)
+ time = Time.at(10) - Rational(1, 1_000_000_000)
time.nsec.should == 999_999_999
end
diff --git a/spec/rubyspec/language/block_spec.rb b/spec/rubyspec/language/block_spec.rb
index 0ae2125ade..219d61e2bf 100644
--- a/spec/rubyspec/language/block_spec.rb
+++ b/spec/rubyspec/language/block_spec.rb
@@ -599,7 +599,7 @@ describe "A block" do
@y.m(1, 2) { |a, (b, (c, d))| [a, b, c, d] }.should == [1, 2, nil, nil]
end
- it "destructures a single multi-level Array value yielded" do
+ it "destructures a nested Array value yielded" do
@y.m(1, [2, 3]) { |a, (b, (c, d))| [a, b, c, d] }.should == [1, 2, 3, nil]
end
@@ -617,7 +617,7 @@ describe "A block" do
@y.m(1, 2) { |a, ((b, c), d)| [a, b, c, d] }.should == [1, 2, nil, nil]
end
- it "destructures a single multi-level Array value yielded" do
+ it "destructures a nested value yielded" do
@y.m(1, [2, 3]) { |a, ((b, c), d)| [a, b, c, d] }.should == [1, 2, nil, 3]
end
diff --git a/spec/rubyspec/language/defined_spec.rb b/spec/rubyspec/language/defined_spec.rb
index 790db64e86..458c74258f 100644
--- a/spec/rubyspec/language/defined_spec.rb
+++ b/spec/rubyspec/language/defined_spec.rb
@@ -881,49 +881,51 @@ end
describe "The defined? keyword for a variable scoped constant" do
after :all do
- Object.__send__(:remove_class_variable, :@@defined_specs_obj)
+ if Object.class_variable_defined? :@@defined_specs_obj
+ Object.__send__(:remove_class_variable, :@@defined_specs_obj)
+ end
end
- it "returns nil if the scoped constant is not defined" do
+ it "returns nil if the instance scoped constant is not defined" do
@defined_specs_obj = DefinedSpecs::Basic
defined?(@defined_specs_obj::Undefined).should be_nil
end
- it "returns 'constant' if the constant is defined in the scope of the variable reference" do
+ it "returns 'constant' if the constant is defined in the scope of the instance variable" do
@defined_specs_obj = DefinedSpecs::Basic
defined?(@defined_specs_obj::A).should == "constant"
end
- it "returns nil if the scoped constant is not defined" do
+ it "returns nil if the global scoped constant is not defined" do
$defined_specs_obj = DefinedSpecs::Basic
defined?($defined_specs_obj::Undefined).should be_nil
end
- it "returns 'constant' if the constant is defined in the scope of the variable reference" do
+ it "returns 'constant' if the constant is defined in the scope of the global variable" do
$defined_specs_obj = DefinedSpecs::Basic
defined?($defined_specs_obj::A).should == "constant"
end
- it "returns nil if the scoped constant is not defined" do
+ it "returns nil if the class scoped constant is not defined" do
-> {
@@defined_specs_obj = DefinedSpecs::Basic
defined?(@@defined_specs_obj::Undefined).should be_nil
}.should complain(/class variable access from toplevel/)
end
- it "returns 'constant' if the constant is defined in the scope of the variable reference" do
+ it "returns 'constant' if the constant is defined in the scope of the class variable" do
-> {
@@defined_specs_obj = DefinedSpecs::Basic
defined?(@@defined_specs_obj::A).should == "constant"
}.should complain(/class variable access from toplevel/)
end
- it "returns nil if the scoped constant is not defined" do
+ it "returns nil if the local scoped constant is not defined" do
defined_specs_obj = DefinedSpecs::Basic
defined?(defined_specs_obj::Undefined).should be_nil
end
- it "returns 'constant' if the constant is defined in the scope of the variable reference" do
+ it "returns 'constant' if the constant is defined in the scope of the local variable" do
defined_specs_obj = DefinedSpecs::Basic
defined?(defined_specs_obj::A).should == "constant"
end
diff --git a/spec/rubyspec/language/heredoc_spec.rb b/spec/rubyspec/language/heredoc_spec.rb
index 436fcb9c9e..a57a7b0bb9 100644
--- a/spec/rubyspec/language/heredoc_spec.rb
+++ b/spec/rubyspec/language/heredoc_spec.rb
@@ -69,12 +69,12 @@ HERE
SquigglyHeredocSpecs.unquoted.should == "unquoted interpolated\n"
end
- it 'allows HEREDOC with <<"identifier", interpolated' do
+ it 'allows HEREDOC with <<~"identifier", interpolated' do
require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
SquigglyHeredocSpecs.doublequoted.should == "doublequoted interpolated\n"
end
- it "allows HEREDOC with <<'identifier', no interpolation" do
+ it "allows HEREDOC with <<~'identifier', no interpolation" do
require File.expand_path('../fixtures/squiggly_heredoc', __FILE__)
SquigglyHeredocSpecs.singlequoted.should == "singlequoted \#{\"interpolated\"}\n"
end
diff --git a/spec/rubyspec/language/regexp/character_classes_spec.rb b/spec/rubyspec/language/regexp/character_classes_spec.rb
index c922ba8a5a..74568a0beb 100644
--- a/spec/rubyspec/language/regexp/character_classes_spec.rb
+++ b/spec/rubyspec/language/regexp/character_classes_spec.rb
@@ -167,10 +167,6 @@ describe "Regexp with character classes" do
"\u{36F}".match(/[[:blank:]]/).should be_nil
end
- it "doesn't match Unicode control characters with [[:blank:]]" do
- "\u{16}".match(/[[:blank:]]/).should be_nil
- end
-
it "doesn't Unicode letter characters with [[:cntrl:]]" do
"à".match(/[[:cntrl:]]/).should be_nil
end
@@ -393,9 +389,6 @@ describe "Regexp with character classes" do
it "matches Unicode Pf characters with [[:punct:]]" do
"\u{201D}".match(/[[:punct:]]/).to_a.should == ["\u{201D}"]
- end
-
- it "matches Unicode Pf characters with [[:punct:]]" do
"\u{00BB}".match(/[[:punct:]]/).to_a.should == ["\u{00BB}"]
end
diff --git a/spec/rubyspec/language/regexp_spec.rb b/spec/rubyspec/language/regexp_spec.rb
index 4a5828f2d1..d4b0c81128 100644
--- a/spec/rubyspec/language/regexp_spec.rb
+++ b/spec/rubyspec/language/regexp_spec.rb
@@ -139,7 +139,7 @@ describe "Literal Regexps" do
pattern.should_not =~ 'T'
end
- it "supports conditional regular expressions with positional capture groups" do
+ it "supports conditional regular expressions with named capture groups" do
pattern = /\A(?<word>foo)?(?(<word>)(T)|(F))\z/
pattern.should =~ 'fooT'
diff --git a/spec/rubyspec/language/variables_spec.rb b/spec/rubyspec/language/variables_spec.rb
index e0ef6b21c4..81ba54840a 100644
--- a/spec/rubyspec/language/variables_spec.rb
+++ b/spec/rubyspec/language/variables_spec.rb
@@ -156,7 +156,7 @@ describe "Multiple assignment" do
[a, b, c].should == [1, [], 2]
end
- it "raises a TypeError if #to_ary does not return an Array" do
+ it "raises a TypeError if #to_ary does not return an Array with MLHS" do
x = mock("multi-assign splat")
x.should_receive(:to_ary).and_return(1)
@@ -249,7 +249,7 @@ describe "Multiple assignment" do
[a, b].should == [1, 2]
end
- it "raises a TypeError if #to_ary does not return an Array" do
+ it "raises a TypeError if #to_ary does not return an Array on a single RHS" do
y = mock("multi-assign method return value")
y.should_receive(:to_ary).and_return(1)
@@ -359,6 +359,10 @@ describe "Multiple assignment" do
(* = *a).should == [1]
end
+ it "consumes values for a grouped anonymous splat" do
+ ((*) = *1).should == [1]
+ end
+
it "assigns a single LHS splat" do
x = 1
(*a = *x).should == [1]
@@ -445,15 +449,7 @@ describe "Multiple assignment" do
a.should == [x]
end
- it "calls #to_a to convert an Object RHS with a single LHS" do
- x = mock("multi-assign splat")
- x.should_receive(:to_a).and_return([1, 2])
-
- a = *x
- a.should == [1, 2]
- end
-
- it "raises a TypeError if #to_a does not return an Array" do
+ it "raises a TypeError if #to_a does not return an Array with a single LHS" do
x = mock("multi-assign splat")
x.should_receive(:to_a).and_return(1)
@@ -468,7 +464,7 @@ describe "Multiple assignment" do
[a, b, c].should == [1, 2, nil]
end
- it "raises a TypeError if #to_a does not return an Array" do
+ it "raises a TypeError if #to_a does not return an Array with a simple MLHS" do
x = mock("multi-assign splat")
x.should_receive(:to_a).and_return(1)
@@ -491,7 +487,7 @@ describe "Multiple assignment" do
[a, b, c].should == [1, [], 2]
end
- it "raises a TypeError if #to_a does not return an Array" do
+ it "raises a TypeError if #to_a does not return an Array with MLHS" do
x = mock("multi-assign splat")
x.should_receive(:to_a).and_return(1)
@@ -516,14 +512,6 @@ describe "Multiple assignment" do
[a, b, c, d, e, f, g].should == [1, [], nil, [], nil, [], nil]
end
- it "consumes values for an anonymous splat" do
- (* = *1).should == [1]
- end
-
- it "consumes values for a grouped anonymous splat" do
- ((*) = *1).should == [1]
- end
-
it "does not mutate a RHS Array" do
x = [1, 2, 3, 4]
a, *b, c, d = *x
@@ -544,6 +532,10 @@ describe "Multiple assignment" do
(* = 1, 2, 3).should == [1, 2, 3]
end
+ it "consumes values for a grouped anonymous splat" do
+ ((*) = 1, 2, 3).should == [1, 2, 3]
+ end
+
it "consumes values for multiple '_' variables" do
a, _, b, _, c = 1, 2, 3, 4, 5
[a, b, c].should == [1, 3, 5]
@@ -573,7 +565,7 @@ describe "Multiple assignment" do
[a, b].should == [1, [3, 4]]
end
- it "raises a TypeError if #to_a does not return an Array" do
+ it "raises a TypeError if #to_a does not return an Array with a splat MLHS" do
x = mock("multi-assign splat MRHS")
x.should_receive(:to_a).and_return(1)
@@ -588,7 +580,7 @@ describe "Multiple assignment" do
[a, b].should == [1, [x]]
end
- it "calls #to_a to convert a splatted Object as part of a MRHS with a splat MLHS" do
+ it "calls #to_a to convert a splatted Object as part of a MRHS" do
x = mock("multi-assign splat MRHS")
x.should_receive(:to_a).and_return([3, 4])
@@ -596,14 +588,14 @@ describe "Multiple assignment" do
[a, b].should == [3, [4, 1]]
end
- it "raises a TypeError if #to_a does not return an Array" do
+ it "raises a TypeError if #to_a does not return an Array with a splat MRHS" do
x = mock("multi-assign splat MRHS")
x.should_receive(:to_a).and_return(1)
lambda { a, *b = *x, 1 }.should raise_error(TypeError)
end
- it "does not call #to_ary to convert a splatted Object as part of a MRHS with a splat MRHS" do
+ it "does not call #to_ary to convert a splatted Object with a splat MRHS" do
x = mock("multi-assign splat MRHS")
x.should_not_receive(:to_ary)
@@ -627,24 +619,16 @@ describe "Multiple assignment" do
a.should == [1, 2, 3]
end
- it "assigns a grouped LHS with splats from nested Arrays" do
+ it "assigns a grouped LHS with splats from nested Arrays for simple values" do
(a, *b), c, (*d, (e, *f, g)) = 1, 2, 3, 4
[a, b, c, d, e, f, g].should == [1, [], 2, [], 3, [], nil]
end
- it "assigns a grouped LHS with splats from nested Arrays" do
+ it "assigns a grouped LHS with splats from nested Arrays for nested arrays" do
(a, *b), c, (*d, (e, *f, g)) = [1, [2, 3]], [4, 5], [6, 7, 8]
[a, b, c, d, e, f, g].should == [1, [[2, 3]], [4, 5], [6, 7], 8, [], nil]
end
- it "consumes values for an anonymous splat" do
- (* = 1, 2, 3).should == [1, 2, 3]
- end
-
- it "consumes values for a grouped anonymous splat" do
- ((*) = 1, 2, 3).should == [1, 2, 3]
- end
-
it "calls #to_ary to convert an Object when the position receiving the value is a multiple assignment" do
x = mock("multi-assign mixed RHS")
x.should_receive(:to_ary).and_return([1, 2])
@@ -677,7 +661,7 @@ describe "Multiple assignment" do
[a, b, c, d].should == [1, [2, 3], 4, 5]
end
- it "raises a TypeError if #to_ary does not return an Array" do
+ it "raises a TypeError if #to_ary does not return an Array in a MRHS" do
x = mock("multi-assign mixed splatted RHS")
x.should_receive(:to_ary).and_return(x)
diff --git a/spec/rubyspec/language/while_spec.rb b/spec/rubyspec/language/while_spec.rb
index a498112919..00e948e41f 100644
--- a/spec/rubyspec/language/while_spec.rb
+++ b/spec/rubyspec/language/while_spec.rb
@@ -127,7 +127,7 @@ describe "The while expression" do
a.should == [1, 2]
end
- it "stops running body if interrupted by break in a parenthesized attribute op-assign-or value" do
+ it "stops running body if interrupted by break with unless in a parenthesized attribute op-assign-or value" do
a = mock("attribute assignment break")
a.should_receive(:m).twice.and_return(nil)
a.should_receive(:m=)
@@ -142,7 +142,7 @@ describe "The while expression" do
end.should be_nil
end
- it "stops running body if interrupted by break in a begin ... end attribute op-assign-or value" do
+ it "stops running body if interrupted by break with unless in a begin ... end attribute op-assign-or value" do
a = mock("attribute assignment break")
a.should_receive(:m).twice.and_return(nil)
a.should_receive(:m=)
diff --git a/spec/rubyspec/library/socket/fixtures/classes.rb b/spec/rubyspec/library/socket/fixtures/classes.rb
index ddb2396731..f154330b9d 100644
--- a/spec/rubyspec/library/socket/fixtures/classes.rb
+++ b/spec/rubyspec/library/socket/fixtures/classes.rb
@@ -51,7 +51,18 @@ module SocketSpecs
end
def self.socket_path
- tmp("unix_server_spec.socket", false)
+ path = tmp("unix.sock", false)
+ # Check for too long unix socket path (max 108 bytes including \0 => 107)
+ # Note that Linux accepts not null-terminated paths but the man page advises against it.
+ if path.bytesize > 107
+ path = "/tmp/unix_server_spec.socket"
+ end
+ rm_socket(path)
+ path
+ end
+
+ def self.rm_socket(path)
+ File.delete(path) if File.exist?(path)
end
# TCPServer echo server accepting one connection
diff --git a/spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb b/spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb
index bad9139eea..b94e91e879 100644
--- a/spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb
+++ b/spec/rubyspec/library/socket/unixserver/accept_nonblock_spec.rb
@@ -6,8 +6,6 @@ describe "UNIXServer#accept_nonblock" do
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
- rm_r @path
-
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
@@ -19,7 +17,7 @@ describe "UNIXServer#accept_nonblock" do
@socket.close
@client.close
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "accepts a connection in a non-blocking way" do
diff --git a/spec/rubyspec/library/socket/unixserver/accept_spec.rb b/spec/rubyspec/library/socket/unixserver/accept_spec.rb
index 6ce1f2c6db..15459f5043 100644
--- a/spec/rubyspec/library/socket/unixserver/accept_spec.rb
+++ b/spec/rubyspec/library/socket/unixserver/accept_spec.rb
@@ -5,16 +5,15 @@ platform_is_not :windows do
describe "UNIXServer#accept" do
before :each do
@path = SocketSpecs.socket_path
- rm_r @path
end
after :each do
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "accepts what is written by the client" do
- server = UNIXServer.open(SocketSpecs.socket_path)
- client = UNIXSocket.open(SocketSpecs.socket_path)
+ server = UNIXServer.open(@path)
+ client = UNIXSocket.open(@path)
client.send('hello', 0)
diff --git a/spec/rubyspec/library/socket/unixserver/for_fd_spec.rb b/spec/rubyspec/library/socket/unixserver/for_fd_spec.rb
index bf8aa41d40..c3cfd86a1c 100644
--- a/spec/rubyspec/library/socket/unixserver/for_fd_spec.rb
+++ b/spec/rubyspec/library/socket/unixserver/for_fd_spec.rb
@@ -4,13 +4,13 @@ require File.expand_path('../../fixtures/classes', __FILE__)
platform_is_not :windows do
describe "UNIXServer#for_fd" do
before :each do
- @unix_path = tmp("unix_socket")
+ @unix_path = SocketSpecs.socket_path
@unix = UNIXServer.new(@unix_path)
end
after :each do
@unix.close if @unix
- rm_r @unix_path
+ SocketSpecs.rm_socket @unix_path
end
it "can calculate the path" do
diff --git a/spec/rubyspec/library/socket/unixserver/open_spec.rb b/spec/rubyspec/library/socket/unixserver/open_spec.rb
index 4401d9dda8..47c76eb9b4 100644
--- a/spec/rubyspec/library/socket/unixserver/open_spec.rb
+++ b/spec/rubyspec/library/socket/unixserver/open_spec.rb
@@ -6,14 +6,13 @@ describe "UNIXServer.open" do
platform_is_not :windows do
before :each do
- @path = tmp("unixserver_spec")
- rm_r @path
+ @path = SocketSpecs.socket_path
end
after :each do
@server.close if @server
@server = nil
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "yields the new UNIXServer object to the block, if given" do
diff --git a/spec/rubyspec/library/socket/unixserver/shared/new.rb b/spec/rubyspec/library/socket/unixserver/shared/new.rb
index 9b0798b828..2018140caa 100644
--- a/spec/rubyspec/library/socket/unixserver/shared/new.rb
+++ b/spec/rubyspec/library/socket/unixserver/shared/new.rb
@@ -5,14 +5,13 @@ require 'tempfile'
describe :unixserver_new, shared: true do
platform_is_not :windows do
before :each do
- @path = tmp("unixserver_spec")
- rm_r @path
+ @path = SocketSpecs.socket_path
end
after :each do
@server.close if @server
@server = nil
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "creates a new UNIXServer" do
diff --git a/spec/rubyspec/library/socket/unixsocket/addr_spec.rb b/spec/rubyspec/library/socket/unixsocket/addr_spec.rb
index 893a910e92..34c62e083f 100644
--- a/spec/rubyspec/library/socket/unixsocket/addr_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/addr_spec.rb
@@ -6,8 +6,6 @@ describe "UNIXSocket#addr" do
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
- rm_r @path
-
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
@@ -15,7 +13,7 @@ describe "UNIXSocket#addr" do
after :each do
@client.close
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "returns the address family of this socket in an array" do
diff --git a/spec/rubyspec/library/socket/unixsocket/open_spec.rb b/spec/rubyspec/library/socket/unixsocket/open_spec.rb
index eb8ffbaf22..5b9b19ee33 100644
--- a/spec/rubyspec/library/socket/unixsocket/open_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/open_spec.rb
@@ -14,7 +14,7 @@ describe "UNIXSocket.open" do
after :each do
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "opens a unix socket on the specified file and yields it to the block" do
diff --git a/spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb b/spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb
index 1123a23541..f43274db2e 100644
--- a/spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/partially_closable_spec.rb
@@ -7,7 +7,6 @@ platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
- rm_r @path
@server = UNIXServer.open(@path)
@s1 = UNIXSocket.new(@path)
@s2 = @server.accept
@@ -17,7 +16,7 @@ platform_is_not :windows do
@server.close
@s1.close
@s2.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it_should_behave_like "partially closable sockets"
diff --git a/spec/rubyspec/library/socket/unixsocket/path_spec.rb b/spec/rubyspec/library/socket/unixsocket/path_spec.rb
index a9186854da..a2beaffeea 100644
--- a/spec/rubyspec/library/socket/unixsocket/path_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/path_spec.rb
@@ -6,8 +6,6 @@ describe "UNIXSocket#path" do
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
- rm_r @path
-
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
@@ -15,7 +13,7 @@ describe "UNIXSocket#path" do
after :each do
@client.close
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "returns the path of the socket if it's a server" do
diff --git a/spec/rubyspec/library/socket/unixsocket/peeraddr_spec.rb b/spec/rubyspec/library/socket/unixsocket/peeraddr_spec.rb
index cd224540ef..14dccf7917 100644
--- a/spec/rubyspec/library/socket/unixsocket/peeraddr_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/peeraddr_spec.rb
@@ -6,8 +6,6 @@ describe "UNIXSocket#peeraddr" do
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
- rm_r @path
-
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
@@ -15,7 +13,7 @@ describe "UNIXSocket#peeraddr" do
after :each do
@client.close
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "returns the address familly and path of the server end of the connection" do
diff --git a/spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb b/spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb
index 9fc4470572..c7a8946ceb 100644
--- a/spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/recv_io_spec.rb
@@ -20,7 +20,7 @@ describe "UNIXSocket#recv_io" do
@file.close
@client.close
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "reads an IO object across the socket" do
diff --git a/spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb b/spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb
index 7ac002607c..78e272bfe2 100644
--- a/spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/recvfrom_spec.rb
@@ -6,8 +6,6 @@ describe "UNIXSocket#recvfrom" do
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
- rm_r @path
-
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
@@ -15,7 +13,7 @@ describe "UNIXSocket#recvfrom" do
after :each do
@client.close
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "receives len bytes from sock" do
diff --git a/spec/rubyspec/library/socket/unixsocket/send_io_spec.rb b/spec/rubyspec/library/socket/unixsocket/send_io_spec.rb
index fb6ce9ba17..ec8d6b2314 100644
--- a/spec/rubyspec/library/socket/unixsocket/send_io_spec.rb
+++ b/spec/rubyspec/library/socket/unixsocket/send_io_spec.rb
@@ -20,7 +20,7 @@ describe "UNIXSocket#send_io" do
@file.close
@client.close
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "sends the fd for an IO object across the socket" do
diff --git a/spec/rubyspec/library/socket/unixsocket/shared/new.rb b/spec/rubyspec/library/socket/unixsocket/shared/new.rb
index 9d8fb809d2..76c0d07b83 100644
--- a/spec/rubyspec/library/socket/unixsocket/shared/new.rb
+++ b/spec/rubyspec/library/socket/unixsocket/shared/new.rb
@@ -11,7 +11,7 @@ describe :unixsocket_new, shared: true do
after :each do
@client.close if @client
@server.close
- rm_r @path
+ SocketSpecs.rm_socket @path
end
it "opens a unix socket on the specified file" do
diff --git a/spec/rubyspec/optional/capi/bignum_spec.rb b/spec/rubyspec/optional/capi/bignum_spec.rb
index 84b5de95c2..59d867cc46 100644
--- a/spec/rubyspec/optional/capi/bignum_spec.rb
+++ b/spec/rubyspec/optional/capi/bignum_spec.rb
@@ -60,6 +60,7 @@ end
unless full_range_longs
it "wraps around if passed a negative bignum" do
@s.rb_big2ulong(ensure_bignum(@min_long + 1)).should == -(@min_long - 1)
+ @s.rb_big2ulong(ensure_bignum(@min_long)).should == -(@min_long)
end
end
@@ -67,12 +68,6 @@ end
lambda { @s.rb_big2ulong(ensure_bignum(@max_ulong + 1)) }.should raise_error(RangeError)
lambda { @s.rb_big2ulong(ensure_bignum(@min_long - 1)) }.should raise_error(RangeError)
end
-
- unless full_range_longs
- it "wraps around if passed a negative bignum" do
- @s.rb_big2ulong(ensure_bignum(@min_long)).should == -(@min_long)
- end
- end
end
describe "rb_big2dbl" do
diff --git a/spec/rubyspec/optional/capi/mutex_spec.rb b/spec/rubyspec/optional/capi/mutex_spec.rb
index dae300f002..9f0abe1115 100644
--- a/spec/rubyspec/optional/capi/mutex_spec.rb
+++ b/spec/rubyspec/optional/capi/mutex_spec.rb
@@ -15,7 +15,7 @@ describe "C-API Mutex functions" do
end
describe "rb_mutex_locked_p" do
- it "returns true if the mutex is locked" do
+ it "returns fakse if the mutex is not locked" do
@s.rb_mutex_locked_p(@m).should be_false
end
diff --git a/spec/rubyspec/optional/capi/spec_helper.rb b/spec/rubyspec/optional/capi/spec_helper.rb
index ca0685c9fe..d0534d8ce0 100644
--- a/spec/rubyspec/optional/capi/spec_helper.rb
+++ b/spec/rubyspec/optional/capi/spec_helper.rb
@@ -6,7 +6,7 @@ require 'fileutils'
require 'tmpdir'
OBJDIR ||= File.expand_path("../../../ext/#{RUBY_NAME}/#{RUBY_VERSION}", __FILE__)
-FileUtils.makedirs(OBJDIR)
+mkdir_p(OBJDIR)
def extension_path
File.expand_path("../ext", __FILE__)
@@ -111,24 +111,6 @@ ensure
ENV[preloadenv] = preload if preloadenv
end
-def compile_extension_truffleruby(name)
- sulong_config_file = File.join(extension_path, '.jruby-cext-build.yml')
- output_file = File.join(object_path, "#{name}_spec.#{RbConfig::CONFIG['DLEXT']}")
-
- File.open(sulong_config_file, 'w') do |f|
- f.puts "src: #{name}_spec.c"
- f.puts "out: #{output_file}"
- end
-
- command = ["#{RbConfig::CONFIG['bindir']}/../tool/jt.rb", 'cextc', extension_path]
- system(*command)
- raise "Compilation of #{extension_path} failed: #{$?}\n#{command.join(' ')}" unless $?.success?
-
- output_file
-ensure
- File.delete(sulong_config_file) if File.exist?(sulong_config_file)
-end
-
def compile_truffleruby_extconf_make(name, path, objdir)
ext = "#{name}_spec"
file = "#{ext}.c"
diff --git a/spec/rubyspec/shared/time/strftime_for_date.rb b/spec/rubyspec/shared/time/strftime_for_date.rb
index 8423a59774..f126c5a323 100644
--- a/spec/rubyspec/shared/time/strftime_for_date.rb
+++ b/spec/rubyspec/shared/time/strftime_for_date.rb
@@ -101,11 +101,7 @@ describe :strftime_date, shared: true do
@d2000_4_6.strftime("%S").should == "00"
end
- it "should be able to show the number of seconds with leading zeroes" do
- @d2000_4_6.strftime("%S").should == "00"
- end
-
- it "should be able to show the number of seconds since the unix epoch" do
+ it "should be able to show the number of seconds since the unix epoch for a date" do
@d2000_4_6.strftime("%s").should == "954979200"
end
@@ -171,7 +167,7 @@ describe :strftime_date, shared: true do
@d2000_4_10.strftime("%u").should == "1"
end
- it "should be able to show the commercial week" do
+ it "should be able to show the commercial week with %V" do
@d2000_4_9.strftime("%V").should == "14"
@d2000_4_10.strftime("%V").should == "15"
end
@@ -218,12 +214,12 @@ describe :strftime_date, shared: true do
@d2000_4_6.strftime("%F").should == @d2000_4_6.strftime('%Y-%m-%d')
end
- it "should be able to show HH:MM" do
+ it "should be able to show HH:MM for a date" do
@d2000_4_6.strftime("%R").should == "00:00"
@d2000_4_6.strftime("%R").should == @d2000_4_6.strftime('%H:%M')
end
- it "should be able to show HH:MM:SS AM/PM" do
+ it "should be able to show HH:MM:SS AM/PM for a date" do
@d2000_4_6.strftime("%r").should == "12:00:00 AM"
@d2000_4_6.strftime("%r").should == @d2000_4_6.strftime('%I:%M:%S %p')
end