summaryrefslogtreecommitdiff
path: root/spec/ruby/language
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-11-27 14:55:31 +0100
committerBenoit Daloze <eregontp@gmail.com>2020-11-27 14:55:31 +0100
commitf02d2f82bf10351f480ea312f40cb840e2437f93 (patch)
tree0b53098bffe6dacadb09880183ebcaea06e95153 /spec/ruby/language
parentf0bfa266d70651dc295a63b026938b246693499b (diff)
downloadruby-f02d2f82bf10351f480ea312f40cb840e2437f93.tar.gz
Update to ruby/spec@ac878ad
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/block_spec.rb8
-rw-r--r--spec/ruby/language/hash_spec.rb6
-rw-r--r--spec/ruby/language/regexp/character_classes_spec.rb6
3 files changed, 19 insertions, 1 deletions
diff --git a/spec/ruby/language/block_spec.rb b/spec/ruby/language/block_spec.rb
index 45a8ec5f9a..b2a3cc84c4 100644
--- a/spec/ruby/language/block_spec.rb
+++ b/spec/ruby/language/block_spec.rb
@@ -873,7 +873,7 @@ describe "Post-args" do
end.call(1, 2, 3).should == [[], 1, 2, 3]
end
- it "are required" do
+ it "are required for a lambda" do
-> {
-> *a, b do
[a, b]
@@ -881,6 +881,12 @@ describe "Post-args" do
}.should raise_error(ArgumentError)
end
+ it "are assigned to nil when not enough arguments are given to a proc" do
+ proc do |a, *b, c|
+ [a, b, c]
+ end.call.should == [nil, [], nil]
+ end
+
describe "with required args" do
it "gathers remaining args in the splat" do
diff --git a/spec/ruby/language/hash_spec.rb b/spec/ruby/language/hash_spec.rb
index 630c9d2364..d6600ddb4a 100644
--- a/spec/ruby/language/hash_spec.rb
+++ b/spec/ruby/language/hash_spec.rb
@@ -149,6 +149,12 @@ describe "Hash literal" do
-> { {**obj} }.should raise_error(TypeError)
end
+ it "raises a TypeError if the object does not respond to #to_hash" do
+ obj = 42
+ -> { {**obj} }.should raise_error(TypeError)
+ -> { {a: 1, **obj} }.should raise_error(TypeError)
+ end
+
it "does not change encoding of literal string keys during creation" do
binary_hash = HashStringsBinary.literal_hash
utf8_hash = HashStringsUTF8.literal_hash
diff --git a/spec/ruby/language/regexp/character_classes_spec.rb b/spec/ruby/language/regexp/character_classes_spec.rb
index 5f4221e213..0cf1e9b6f4 100644
--- a/spec/ruby/language/regexp/character_classes_spec.rb
+++ b/spec/ruby/language/regexp/character_classes_spec.rb
@@ -609,6 +609,12 @@ describe "Regexp with character classes" do
"루비(Ruby)".match(/\p{Hangul}+/u).to_a.should == ["루비"]
end
+ ruby_bug "#17340", ''...'3.0' do
+ it "raises a RegexpError for an unterminated unicode property" do
+ -> { Regexp.new('\p{') }.should raise_error(RegexpError)
+ end
+ end
+
it "supports \\X (unicode 9.0 with UTR #51 workarounds)" do
# simple emoji without any fancy modifier or ZWJ
/\X/.match("\u{1F98A}").to_a.should == ["🦊"]