Skip to content
Browse files

Rewrote some encoding specs a bit to use a set of encodings which eve…

…ry implementation probably has.

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/experimental@1529 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent d3801ae commit 857515b70f3312e7501f485a44ad4d4e5291fc6a @alloy alloy committed May 4, 2009
View
3 spec/TODO
@@ -1,3 +1,6 @@
+* For IO: internal_encoding returns nil when none is given and
+ Encoding.default_internal is nil or when Encoding.default_internal and
+ Encoding.default_external are the same.
* Merge eigenclass spec into metaclass spec
* Cleanup MacRuby specs
* Write more 1.9/MacRuby encoding specs
View
5 spec/frozen/core/encoding/aliases_spec.rb
@@ -1,8 +1,11 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe "Encoding.aliases" do
- it "returns a hash where the keys are the aliases and the values the real encoding name" do
+ it "returns a hash" do
Encoding.aliases.should be_kind_of(Hash)
+ end
+
+ it "returns an encoding name for a given alias" do
Encoding.aliases["BINARY"].should == "ASCII-8BIT"
end
end
View
24 spec/frozen/core/encoding/default_external_spec.rb
@@ -16,20 +16,30 @@
end
it "takes an Encoding instance" do
- encoding = Encoding.find('macRoman')
- Encoding.default_external = encoding
- Encoding.default_external.name.should == 'macRoman'
+ Encoding.default_external = Encoding.find('UTF-8')
+ Encoding.default_external.name.should == 'UTF-8'
+
+ Encoding.default_external = Encoding.find('US-ASCII')
+ Encoding.default_external.name.should == 'US-ASCII'
end
it "takes a string name of an encoding" do
- Encoding.default_external = 'macRoman'
- Encoding.default_external.name.should == 'macRoman'
+ Encoding.default_external = 'UTF-8'
+ Encoding.default_external.name.should == 'UTF-8'
+
+ Encoding.default_external = 'US-ASCII'
+ Encoding.default_external.name.should == 'US-ASCII'
end
it "assigns the default external encoding to be used for IO" do
- Encoding.default_external = 'macRoman'
+ Encoding.default_external = 'UTF-8'
+ open(__FILE__) do |file|
+ file.external_encoding.name.should == 'UTF-8'
+ end
+
+ Encoding.default_external = 'US-ASCII'
open(__FILE__) do |file|
- file.external_encoding.name.should == 'macRoman'
+ file.external_encoding.name.should == 'US-ASCII'
end
end
end
View
35 spec/frozen/core/encoding/default_internal_spec.rb
@@ -7,25 +7,44 @@
end
describe "Encoding.default_internal=" do
+ before :all do
+ @before = Encoding.default_external
+ Encoding.default_external = 'ISO-8859-1'
+ end
+
+ after :all do
+ Encoding.default_external = @before
+ end
+
after :each do
Encoding.default_internal = nil
end
it "takes an Encoding instance" do
- encoding = Encoding.find('macRoman')
- Encoding.default_internal = encoding
- Encoding.default_internal.name.should == 'macRoman'
+ Encoding.default_internal = Encoding.find('UTF-8')
+ Encoding.default_internal.name.should == 'UTF-8'
+
+ Encoding.default_internal = Encoding.find('US-ASCII')
+ Encoding.default_internal.name.should == 'US-ASCII'
end
it "takes a string name of an encoding" do
- Encoding.default_internal = 'macRoman'
- Encoding.default_internal.name.should == 'macRoman'
+ Encoding.default_internal = 'UTF-8'
+ Encoding.default_internal.name.should == 'UTF-8'
+
+ Encoding.default_internal = 'US-ASCII'
+ Encoding.default_internal.name.should == 'US-ASCII'
end
- it "assigns the default internal encoding to be used for IO" do
- Encoding.default_internal = 'macRoman'
+ it "assigns the default external encoding to be used for IO" do
+ Encoding.default_internal = 'UTF-8'
+ open(__FILE__) do |file|
+ file.internal_encoding.name.should == 'UTF-8'
+ end
+
+ Encoding.default_internal = 'US-ASCII'
open(__FILE__) do |file|
- file.internal_encoding.name.should == 'macRoman'
+ file.internal_encoding.name.should == 'US-ASCII'
end
end
end

0 comments on commit 857515b

Please sign in to comment.
Something went wrong with that request. Please try again.