aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/language/symbol_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/symbol_spec.rb')
-rw-r--r--spec/ruby/language/symbol_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/ruby/language/symbol_spec.rb b/spec/ruby/language/symbol_spec.rb
index 41be5b2236..90540f7d1d 100644
--- a/spec/ruby/language/symbol_spec.rb
+++ b/spec/ruby/language/symbol_spec.rb
@@ -36,6 +36,11 @@ describe "A Symbol literal" do
}
end
+ it 'inherits the encoding of the magic comment and can have a binary encoding' do
+ ruby_exe(fixture(__FILE__, "binary_symbol.rb"))
+ .should == "[105, 108, 95, 195, 169, 116, 97, 105, 116]\nASCII-8BIT\n"
+ end
+
it "may contain '::' in the string" do
:'Some::Class'.should be_kind_of(Symbol)
end
@@ -90,4 +95,12 @@ describe "A Symbol literal" do
it "can be created from list syntax %I{a b c} with interpolation" do
%I{a b #{"c"}}.should == [:a, :b, :c]
end
+
+ it "with invalid bytes raises an EncodingError at parse time" do
+ ScratchPad.record []
+ -> {
+ eval 'ScratchPad << 1; :"\xC3"'
+ }.should raise_error(EncodingError, /invalid/)
+ ScratchPad.recorded.should == []
+ end
end