aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/kernel
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-10-26 20:53:01 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-10-26 20:53:01 +0200
commit664e96b1de816c813c29f61e16a2031a7af7ba86 (patch)
tree7f4691847cd6b3282812eea7e2be3758e08d1433 /spec/ruby/core/kernel
parent3eb0d50c0baae916f4486c264605b18e77bee0dc (diff)
downloadruby-664e96b1de816c813c29f61e16a2031a7af7ba86.tar.gz
Update to ruby/spec@28a728b
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r--spec/ruby/core/kernel/eval_spec.rb17
-rw-r--r--spec/ruby/core/kernel/local_variables_spec.rb11
2 files changed, 28 insertions, 0 deletions
diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb
index 02f7ae87e9..340ba23f2a 100644
--- a/spec/ruby/core/kernel/eval_spec.rb
+++ b/spec/ruby/core/kernel/eval_spec.rb
@@ -341,5 +341,22 @@ CODE
value.encoding.should == Encoding::BINARY
value.frozen?.should be_true
end
+
+ it "ignores the frozen_string_literal magic comment if it appears after a token and warns if $VERBOSE is true" do
+ code = <<CODE
+some_token_before_magic_comment = :anything
+# frozen_string_literal: true
+class EvalSpecs
+ Vπstring_not_frozen = "not frozen"
+end
+CODE
+ -> { eval(code) }.should complain(/warning: `frozen_string_literal' is ignored after any tokens/, verbose: true)
+ EvalSpecs::Vπstring_not_frozen.frozen?.should be_false
+ EvalSpecs.send :remove_const, :Vπstring_not_frozen
+
+ -> { eval(code) }.should_not complain(verbose: false)
+ EvalSpecs::Vπstring_not_frozen.frozen?.should be_false
+ EvalSpecs.send :remove_const, :Vπstring_not_frozen
+ end
end
end
diff --git a/spec/ruby/core/kernel/local_variables_spec.rb b/spec/ruby/core/kernel/local_variables_spec.rb
index d0f09943bd..f6f1e15f52 100644
--- a/spec/ruby/core/kernel/local_variables_spec.rb
+++ b/spec/ruby/core/kernel/local_variables_spec.rb
@@ -34,4 +34,15 @@ describe "Kernel#local_variables" do
ScratchPad.recorded.should include(:a, :b)
ScratchPad.recorded.length.should == 2
end
+
+ it "includes only unique variable names" do
+ def local_var_method
+ a = 1
+ 1.times do |;a|
+ return local_variables
+ end
+ end
+
+ local_var_method.should == [:a]
+ end
end