mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@b65d01f
This commit is contained in:
parent
15d05f8120
commit
6998d75824
186 changed files with 3956 additions and 3339 deletions
|
@ -715,6 +715,18 @@ describe "Multiple assignment" do
|
|||
x.should == [1, 2, 3, 4, 5]
|
||||
end
|
||||
|
||||
it "can be used to swap array elements" do
|
||||
a = [1, 2]
|
||||
a[0], a[1] = a[1], a[0]
|
||||
a.should == [2, 1]
|
||||
end
|
||||
|
||||
it "can be used to swap range of array elements" do
|
||||
a = [1, 2, 3, 4]
|
||||
a[0, 2], a[2, 2] = a[2, 2], a[0, 2]
|
||||
a.should == [3, 4, 1, 2]
|
||||
end
|
||||
|
||||
it "assigns RHS values to LHS constants" do
|
||||
module VariableSpecs
|
||||
MRHS_VALUES_1, MRHS_VALUES_2 = 1, 2
|
||||
|
@ -770,45 +782,30 @@ describe "A local variable assigned only within a conditional block" do
|
|||
end
|
||||
|
||||
describe 'Local variable shadowing' do
|
||||
ruby_version_is ""..."2.6" do
|
||||
it "leads to warning in verbose mode" do
|
||||
-> do
|
||||
eval <<-CODE
|
||||
a = [1, 2, 3]
|
||||
a.each { |a| a = 3 }
|
||||
CODE
|
||||
end.should complain(/shadowing outer local variable/, verbose: true)
|
||||
end
|
||||
end
|
||||
it "does not warn in verbose mode" do
|
||||
result = nil
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
it "does not warn in verbose mode" do
|
||||
result = nil
|
||||
-> do
|
||||
eval <<-CODE
|
||||
a = [1, 2, 3]
|
||||
result = a.map { |a| a = 3 }
|
||||
CODE
|
||||
end.should_not complain(verbose: true)
|
||||
|
||||
-> do
|
||||
eval <<-CODE
|
||||
a = [1, 2, 3]
|
||||
result = a.map { |a| a = 3 }
|
||||
CODE
|
||||
end.should_not complain(verbose: true)
|
||||
|
||||
result.should == [3, 3, 3]
|
||||
end
|
||||
result.should == [3, 3, 3]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Allowed characters' do
|
||||
ruby_version_is "2.6" 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
|
||||
# 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue