Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1695da35e9fa
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 18d2fdc3d13e
Choose a head ref
  • 2 commits
  • 40 files changed
  • 1 contributor

Commits on Mar 30, 2015

  1. Squashed 'spec/ruby/' changes from 19ff319..a34895b

    a34895b Merge pull request #59 from anthonycrumley/sizedqueue
    c49f8f6 Added specification for SizedQueue
    93a95cd No longer using our pure-Java crypt.
    
    git-subtree-dir: spec/ruby
    git-subtree-split: a34895b7f7c147a9756a8f229331e112c4118107
    eregon committed Mar 30, 2015
    Copy the full SHA
    a03f447 View commit details
  2. Copy the full SHA
    18d2fdc View commit details
Showing with 315 additions and 89 deletions.
  1. +0 −8 spec/ruby/core/string/crypt_spec.rb
  2. +0 −7 spec/ruby/library/queue/append_spec.rb
  3. +0 −7 spec/ruby/library/queue/deq_spec.rb
  4. +0 −7 spec/ruby/library/queue/enq_spec.rb
  5. +0 −7 spec/ruby/library/queue/length_spec.rb
  6. +0 −7 spec/ruby/library/queue/pop_spec.rb
  7. +0 −7 spec/ruby/library/queue/push_spec.rb
  8. +0 −7 spec/ruby/library/queue/shift_spec.rb
  9. +0 −7 spec/ruby/library/queue/size_spec.rb
  10. +7 −0 spec/ruby/library/thread/queue/append_spec.rb
  11. +9 −0 spec/ruby/library/thread/queue/clear_spec.rb
  12. +7 −0 spec/ruby/library/thread/queue/deq_spec.rb
  13. +7 −0 spec/ruby/library/thread/queue/empty_spec.rb
  14. +7 −0 spec/ruby/library/thread/queue/enq_spec.rb
  15. +7 −0 spec/ruby/library/thread/queue/length_spec.rb
  16. +7 −0 spec/ruby/library/thread/queue/num_waiting_spec.rb
  17. +7 −0 spec/ruby/library/thread/queue/pop_spec.rb
  18. +7 −0 spec/ruby/library/thread/queue/push_spec.rb
  19. +7 −0 spec/ruby/library/thread/queue/shift_spec.rb
  20. +7 −0 spec/ruby/library/thread/queue/size_spec.rb
  21. +2 −7 spec/ruby/library/{queue/clear_spec.rb → thread/shared/queue/clear.rb}
  22. +4 −4 spec/ruby/library/{queue/shared → thread/shared/queue}/deque.rb
  23. +3 −6 spec/ruby/library/{queue/empty_spec.rb → thread/shared/queue/empty.rb}
  24. +1 −1 spec/ruby/library/{queue/shared → thread/shared/queue}/enque.rb
  25. +1 −1 spec/ruby/library/{queue/shared → thread/shared/queue}/length.rb
  26. +3 −6 spec/ruby/library/{queue/num_waiting_spec.rb → thread/shared/queue/num_waiting.rb}
  27. +12 −0 spec/ruby/library/thread/sizedqueue/append_spec.rb
  28. +9 −0 spec/ruby/library/thread/sizedqueue/clear_spec.rb
  29. +7 −0 spec/ruby/library/thread/sizedqueue/deq_spec.rb
  30. +7 −0 spec/ruby/library/thread/sizedqueue/empty_spec.rb
  31. +12 −0 spec/ruby/library/thread/sizedqueue/enq_spec.rb
  32. +7 −0 spec/ruby/library/thread/sizedqueue/length_spec.rb
  33. +53 −0 spec/ruby/library/thread/sizedqueue/max_spec.rb
  34. +37 −0 spec/ruby/library/thread/sizedqueue/new_spec.rb
  35. +7 −0 spec/ruby/library/thread/sizedqueue/num_waiting_spec.rb
  36. +7 −0 spec/ruby/library/thread/sizedqueue/pop_spec.rb
  37. +12 −0 spec/ruby/library/thread/sizedqueue/push_spec.rb
  38. +38 −0 spec/ruby/library/thread/sizedqueue/shared/enque.rb
  39. +7 −0 spec/ruby/library/thread/sizedqueue/shift_spec.rb
  40. +7 −0 spec/ruby/library/thread/sizedqueue/size_spec.rb
8 changes: 0 additions & 8 deletions spec/ruby/core/string/crypt_spec.rb
Original file line number Diff line number Diff line change
@@ -28,14 +28,6 @@
"hello world".crypt("aabc").should == "aayPz4hyPS1wI"
end

platform_is :java do
it "returns NULL bytes prepended to the string when the salt contains NULL bytes" do
"hello".crypt("\x00\x00").should == "\x00\x00dR0/E99ehpU"
"hello".crypt("\x00a").should == "\x00aeipc4xPxhGY"
"hello".crypt("a\x00").should == "a\x00GJVggM8eWwo"
end
end

it "raises an ArgumentError when the salt is shorter than two characters" do
lambda { "hello".crypt("") }.should raise_error(ArgumentError)
lambda { "hello".crypt("f") }.should raise_error(ArgumentError)
7 changes: 0 additions & 7 deletions spec/ruby/library/queue/append_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/library/queue/deq_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/library/queue/enq_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/library/queue/length_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/library/queue/pop_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/library/queue/push_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/library/queue/shift_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/library/queue/size_spec.rb

This file was deleted.

7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/append_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/enque', __FILE__)

describe "Thread::Queue#<<" do
it_behaves_like :queue_enq, :<<, Queue.new
end
9 changes: 9 additions & 0 deletions spec/ruby/library/thread/queue/clear_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/clear', __FILE__)

describe "Thread::Queue#clear" do
it_behaves_like :queue_clear, :clear, Queue.new

# TODO: test for atomicity of Queue#clear
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/deq_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/deque', __FILE__)

describe "Thread::Queue#deq" do
it_behaves_like :queue_deq, :deq, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/empty_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/empty', __FILE__)

describe "Thread::Queue#empty?" do
it_behaves_like :queue_empty?, :empty?, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/enq_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/enque', __FILE__)

describe "Thread::Queue#enq" do
it_behaves_like :queue_enq, :enq, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/length_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/length', __FILE__)

describe "Thread::Queue#length" do
it_behaves_like :queue_length, :length, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/num_waiting_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/num_waiting', __FILE__)

describe "Thread::Queue#num_waiting" do
it_behaves_like :queue_num_waiting, :num_waiting, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/pop_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/deque', __FILE__)

describe "Thread::Queue#pop" do
it_behaves_like :queue_deq, :pop, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/push_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/enque', __FILE__)

describe "Thread::Queue#push" do
it_behaves_like :queue_enq, :push, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/shift_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/deque', __FILE__)

describe "Thread::Queue#shift" do
it_behaves_like :queue_deq, :shift, Queue.new
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/queue/size_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/length', __FILE__)

describe "Thread::Queue#size" do
it_behaves_like :queue_length, :size, Queue.new
end
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'thread'

describe "Queue#clear" do
describe :queue_clear, :shared => true do
it "removes all objects from the queue" do
queue = Queue.new
queue = @object
queue << Object.new
queue << 1
queue.empty?.should be_false
queue.clear
queue.empty?.should be_true
end

# TODO: test for atomicity of Queue#clear
end
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
describe :queue_deq, :shared => true do
it "removes an item from the Queue" do
q = Queue.new
q = @object
q << Object.new
q.size.should == 1
q.send(@method)
q.size.should == 0
end

it "returns items in the order they were added" do
q = Queue.new
q = @object
q << 1
q << 2
q.send(@method).should == 1
q.send(@method).should == 2
end

it "blocks the thread until there are items in the queue" do
q = Queue.new
q = @object
v = 0

th = Thread.new do
@@ -31,7 +31,7 @@
end

it "raises a ThreadError if Queue is empty" do
q = Queue.new
q = @object
lambda { q.send(@method,true) }.should raise_error(ThreadError)
end
end
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'thread'

describe "Queue#empty?" do
describe :queue_empty?, :shared => true do
it "returns true on an empty Queue" do
queue = Queue.new
queue = @object
queue.empty?.should be_true
end

it "returns false when Queue is not empty" do
queue = Queue.new
queue = @object
queue << Object.new
queue.empty?.should be_false
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe :queue_enq, :shared => true do
it "adds an element to the Queue" do
q = Queue.new
q = @object
q.size.should == 0
q.send(@method, Object.new)
q.size.should == 1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe :queue_length, :shared => true do
it "returns the number of elements" do
q = Queue.new
q = @object
q.send(@method).should == 0
q << Object.new
q << Object.new
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'thread'

describe "Queue#num_waiting" do
it "reports the number of threads waiting on the Queue" do
q = Queue.new
describe :queue_num_waiting, :shared => true do
it "reports the number of threads waiting on the queue" do
q = @object
threads = []

5.times do |i|
12 changes: 12 additions & 0 deletions spec/ruby/library/thread/sizedqueue/append_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/enque', __FILE__)
require File.expand_path('../shared/enque', __FILE__)

describe "Thread::SizedQueue#<<" do
it_behaves_like :queue_enq, :<<, SizedQueue.new(10)
end

describe "Thread::SizedQueue#<<" do
it_behaves_like :sizedqueue_enq, :<<, SizedQueue
end
9 changes: 9 additions & 0 deletions spec/ruby/library/thread/sizedqueue/clear_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/clear', __FILE__)

describe "Thread::SizedQueue#clear" do
it_behaves_like :queue_clear, :clear, SizedQueue.new(10)

# TODO: test for atomicity of Queue#clear
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/sizedqueue/deq_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/deque', __FILE__)

describe "Thread::SizedQueue#deq" do
it_behaves_like :queue_deq, :deq, SizedQueue.new(10)
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/sizedqueue/empty_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/empty', __FILE__)

describe "Thread::SizedQueue#empty?" do
it_behaves_like :queue_empty?, :empty?, SizedQueue.new(10)
end
12 changes: 12 additions & 0 deletions spec/ruby/library/thread/sizedqueue/enq_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/enque', __FILE__)
require File.expand_path('../shared/enque', __FILE__)

describe "Thread::SizedQueue#enq" do
it_behaves_like :queue_enq, :enq, SizedQueue.new(10)
end

describe "Thread::SizedQueue#enq" do
it_behaves_like :sizedqueue_enq, :enq, SizedQueue
end
7 changes: 7 additions & 0 deletions spec/ruby/library/thread/sizedqueue/length_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'
require File.expand_path('../../shared/queue/length', __FILE__)

describe "Thread::SizedQueue#length" do
it_behaves_like :queue_length, :length, SizedQueue.new(10)
end
53 changes: 53 additions & 0 deletions spec/ruby/library/thread/sizedqueue/max_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'thread'

describe "Thread::SizedQueue#max" do
before :each do
@sized_queue = SizedQueue.new(5)
end

it "returns the size of the queue" do
@sized_queue.max.should == 5
end
end

describe "Thread::SizedQueue#max=" do
before :each do
@sized_queue = SizedQueue.new(5)
end

it "sets the size of the queue" do
@sized_queue.max.should == 5
@sized_queue.max = 10
@sized_queue.max.should == 10
end

ruby_version_is ""..."2.1" do
it "raises a NoMethodError when a value without #>" do
lambda { @sized_queue.max = Object.new }.should raise_error(NoMethodError)
end

it "raises an ArgumentError for values not comparable to a number" do
lambda { @sized_queue.max = "foo" }.should raise_error(ArgumentError)
end
end

ruby_version_is "2.1" do
it "raises a TypeError when given a non-numeric value" do
lambda { @sized_queue.max = "foo" }.should raise_error(TypeError)
lambda { @sized_queue.max = Object.new }.should raise_error(TypeError)
end
end

it "raises an argument error when set to zero" do
@sized_queue.max.should == 5
lambda { @sized_queue.max = 0 }.should raise_error(ArgumentError)
@sized_queue.max.should == 5
end

it "raises an argument error when set to a negative number" do
@sized_queue.max.should == 5
lambda { @sized_queue.max = -1 }.should raise_error(ArgumentError)
@sized_queue.max.should == 5
end
end
Loading