Skip to content

Commit

Permalink
Merge pull request #902 from ruby/minor-fixes-after-reviewing-breakin…
Browse files Browse the repository at this point in the history
…g-changes

Minor fixes of wording and formatting
  • Loading branch information
andrykonchin committed Dec 13, 2021
2 parents d29a31f + e5e8c81 commit d3cbd3a
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 50 deletions.
10 changes: 10 additions & 0 deletions core/hash/to_a_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@
{}.untrust.to_a.untrusted?.should be_true
end
end

ruby_version_is '2.7' do
it "returns a not tainted array if self is tainted" do
{}.taint.to_a.tainted?.should be_false
end

it "returns a trusted array if self is untrusted" do
{}.untrust.to_a.untrusted?.should be_false
end
end
end
4 changes: 2 additions & 2 deletions core/hash/transform_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
end

ruby_version_is ""..."3.0.2" do # https://bugs.ruby-lang.org/issues/17735
it "returns the processed keys if we broke from the block" do
it "returns the processed keys if we break from the block" do
@hash.transform_keys! do |v|
break if v == :c
v.succ
Expand All @@ -90,7 +90,7 @@
end

ruby_version_is "3.0.2" do
it "returns the processed keys and non evaluated keys if we broke from the block" do
it "returns the processed keys and non evaluated keys if we break from the block" do
@hash.transform_keys! do |v|
break if v == :c
v.succ
Expand Down
2 changes: 1 addition & 1 deletion core/io/ungetc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
-> { @io.sysread(1) }.should raise_error(IOError)
end

ruby_version_is "0"..."3.0" do
ruby_version_is ""..."3.0" do
it "does not affect the stream and returns nil when passed nil" do
@io.getc.should == ?V
@io.ungetc(nil)
Expand Down
2 changes: 1 addition & 1 deletion core/module/prepend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ module M
c.dup.new.should be_kind_of(m)
end

ruby_version_is '0'...'3.0' do
ruby_version_is ''...'3.0' do
it "keeps the module in the chain when dupping an intermediate module" do
m1 = Module.new { def calc(x) x end }
m2 = Module.new { prepend(m1) }
Expand Down
1 change: 0 additions & 1 deletion core/numeric/shared/step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
end

describe "when no block is given" do
step_enum_class = Enumerator
step_enum_class = Enumerator::ArithmeticSequence

ruby_version_is ""..."3.0" do
Expand Down
2 changes: 0 additions & 2 deletions core/numeric/step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
it_behaves_like :numeric_step, :step

describe "when no block is given" do
step_enum_class = Enumerator
step_enum_class = Enumerator::ArithmeticSequence

ruby_version_is ""..."3.0" do
Expand Down Expand Up @@ -61,7 +60,6 @@
end
end
end

end

describe 'with keyword arguments' do
Expand Down
8 changes: 8 additions & 0 deletions core/proc/compose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ def double.call(n); n * 2; end
g = proc { |x| x + x }
lambda_proc = -> x { x }

# lambda << proc
(f << g).is_a?(Proc).should == true
(f << g).should_not.lambda?

# lambda << lambda
(f << lambda_proc).is_a?(Proc).should == true
(f << lambda_proc).should.lambda?

# proc << lambda
(g << f).is_a?(Proc).should == true
(g << f).should.lambda?
end
end

Expand Down
2 changes: 1 addition & 1 deletion core/proc/eql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require_relative 'shared/equal'

describe "Proc#eql?" do
ruby_version_is "0"..."3.0" do
ruby_version_is ""..."3.0" do
it_behaves_like :proc_equal_undefined, :eql?
end

Expand Down
2 changes: 1 addition & 1 deletion core/proc/equal_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require_relative 'shared/equal'

describe "Proc#==" do
ruby_version_is "0"..."3.0" do
ruby_version_is ""..."3.0" do
it_behaves_like :proc_equal_undefined, :==
end

Expand Down
6 changes: 0 additions & 6 deletions core/random/raw_seed_spec.rb

This file was deleted.

23 changes: 0 additions & 23 deletions core/random/shared/urandom.rb

This file was deleted.

25 changes: 25 additions & 0 deletions core/random/urandom_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative '../../spec_helper'

describe "Random.urandom" do
it "returns a String" do
Random.urandom(1).should be_an_instance_of(String)
end

it "returns a String of the length given as argument" do
Random.urandom(15).length.should == 15
end

it "raises an ArgumentError on a negative size" do
-> {
Random.urandom(-1)
}.should raise_error(ArgumentError)
end

it "returns a binary String" do
Random.urandom(15).encoding.should == Encoding::BINARY
end

it "returns a random binary String" do
Random.urandom(12).should_not == Random.urandom(12)
end
end
14 changes: 14 additions & 0 deletions language/constants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,17 @@ class PrivateClass
eval("mod::ἍBB").should == 1
end
end

describe 'Assignment' do
context 'dynamic assignment' do
it 'raises SyntaxError' do
-> do
eval <<-CODE
def test
B = 1
end
CODE
end.should raise_error(SyntaxError, /dynamic constant assignment/)
end
end
end
2 changes: 1 addition & 1 deletion language/def_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def bar
end

ruby_version_is '2.7' do
it "raises a syntaxError an existing method with the same name as the local variable" do
it "raises a SyntaxError when there is an existing method with the same name as the local variable" do
def bar
1
end
Expand Down
21 changes: 10 additions & 11 deletions language/variables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -797,17 +797,6 @@ module VariableSpecs
end

describe 'Allowed characters' do
# new feature in 2.6 -- https://bugs.ruby-lang.org/issues/13770
it 'does not allow non-ASCII upcased characters at the beginning' do
-> do
eval <<-CODE
def test
ἍBB = 1
end
CODE
end.should raise_error(SyntaxError, /dynamic constant assignment/)
end

it 'allows non-ASCII lowercased characters at the beginning' do
result = nil

Expand All @@ -821,6 +810,16 @@ def test

result.should == 1
end

it 'parses a non-ASCII upcased character as a constant identifier' do
-> do
eval <<-CODE
def test
ἍBB = 1
end
CODE
end.should raise_error(SyntaxError, /dynamic constant assignment/)
end
end

describe "Instance variables" do
Expand Down

0 comments on commit d3cbd3a

Please sign in to comment.