summaryrefslogtreecommitdiff
path: root/spec/ruby/language
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/encoding_spec.rb8
-rw-r--r--spec/ruby/language/fixtures/hash_strings_binary.rb (renamed from spec/ruby/language/fixtures/hash_strings_ascii8bit.rb)4
-rw-r--r--spec/ruby/language/hash_spec.rb8
-rw-r--r--spec/ruby/language/regexp/encoding_spec.rb8
-rw-r--r--spec/ruby/language/string_spec.rb8
-rw-r--r--spec/ruby/language/super_spec.rb19
-rw-r--r--spec/ruby/language/symbol_spec.rb2
7 files changed, 38 insertions, 19 deletions
diff --git a/spec/ruby/language/encoding_spec.rb b/spec/ruby/language/encoding_spec.rb
index 31b403a704..fb36a9618e 100644
--- a/spec/ruby/language/encoding_spec.rb
+++ b/spec/ruby/language/encoding_spec.rb
@@ -14,14 +14,14 @@ describe "The __ENCODING__ pseudo-variable" do
it "is the evaluated strings's one inside an eval" do
eval("__ENCODING__".force_encoding("US-ASCII")).should == Encoding::US_ASCII
- eval("__ENCODING__".force_encoding("ASCII-8BIT")).should == Encoding::ASCII_8BIT
+ eval("__ENCODING__".force_encoding("BINARY")).should == Encoding::BINARY
end
it "is the encoding specified by a magic comment inside an eval" do
- code = "# encoding: ASCII-8BIT\n__ENCODING__".force_encoding("US-ASCII")
- eval(code).should == Encoding::ASCII_8BIT
+ code = "# encoding: BINARY\n__ENCODING__".force_encoding("US-ASCII")
+ eval(code).should == Encoding::BINARY
- code = "# encoding: us-ascii\n__ENCODING__".force_encoding("ASCII-8BIT")
+ code = "# encoding: us-ascii\n__ENCODING__".force_encoding("BINARY")
eval(code).should == Encoding::US_ASCII
end
diff --git a/spec/ruby/language/fixtures/hash_strings_ascii8bit.rb b/spec/ruby/language/fixtures/hash_strings_binary.rb
index 4ac11b9930..44b99cbf80 100644
--- a/spec/ruby/language/fixtures/hash_strings_ascii8bit.rb
+++ b/spec/ruby/language/fixtures/hash_strings_binary.rb
@@ -1,6 +1,6 @@
-# encoding: ascii-8bit
+# encoding: binary
-module HashStringsASCII8BIT
+module HashStringsBinary
def self.literal_hash
{"foo" => "bar"}
end
diff --git a/spec/ruby/language/hash_spec.rb b/spec/ruby/language/hash_spec.rb
index 475b1094ab..3d29f4bc72 100644
--- a/spec/ruby/language/hash_spec.rb
+++ b/spec/ruby/language/hash_spec.rb
@@ -1,5 +1,5 @@
require_relative '../spec_helper'
-require_relative 'fixtures/hash_strings_ascii8bit'
+require_relative 'fixtures/hash_strings_binary'
require_relative 'fixtures/hash_strings_utf8'
require_relative 'fixtures/hash_strings_usascii'
@@ -141,12 +141,12 @@ describe "Hash literal" do
end
it "does not change encoding of literal string keys during creation" do
- ascii8bit_hash = HashStringsASCII8BIT.literal_hash
+ binary_hash = HashStringsBinary.literal_hash
utf8_hash = HashStringsUTF8.literal_hash
usascii_hash = HashStringsUSASCII.literal_hash
- ascii8bit_hash.keys.first.encoding.should == Encoding::ASCII_8BIT
- ascii8bit_hash.keys.first.should == utf8_hash.keys.first
+ binary_hash.keys.first.encoding.should == Encoding::BINARY
+ binary_hash.keys.first.should == utf8_hash.keys.first
utf8_hash.keys.first.encoding.should == Encoding::UTF_8
utf8_hash.keys.first.should == usascii_hash.keys.first
usascii_hash.keys.first.encoding.should == Encoding::US_ASCII
diff --git a/spec/ruby/language/regexp/encoding_spec.rb b/spec/ruby/language/regexp/encoding_spec.rb
index f9979e7ea3..dce64a4753 100644
--- a/spec/ruby/language/regexp/encoding_spec.rb
+++ b/spec/ruby/language/regexp/encoding_spec.rb
@@ -42,16 +42,16 @@ describe "Regexps with encoding modifiers" do
/./n.encoding.should == Encoding::US_ASCII
end
- it 'uses ASCII-8BIT as /n encoding if not all chars are 7-bit' do
- /\xFF/n.encoding.should == Encoding::ASCII_8BIT
+ it 'uses BINARY as /n encoding if not all chars are 7-bit' do
+ /\xFF/n.encoding.should == Encoding::BINARY
end
it 'preserves US-ASCII as /n encoding through interpolation if all chars are 7-bit' do
/.#{/./}/n.encoding.should == Encoding::US_ASCII
end
- it 'preserves ASCII-8BIT as /n encoding through interpolation if all chars are 7-bit' do
- /\xFF#{/./}/n.encoding.should == Encoding::ASCII_8BIT
+ it 'preserves BINARY as /n encoding through interpolation if all chars are 7-bit' do
+ /\xFF#{/./}/n.encoding.should == Encoding::BINARY
end
it "supports /s (Windows_31J encoding)" do
diff --git a/spec/ruby/language/string_spec.rb b/spec/ruby/language/string_spec.rb
index 78ee5ff2c4..308485d546 100644
--- a/spec/ruby/language/string_spec.rb
+++ b/spec/ruby/language/string_spec.rb
@@ -195,11 +195,11 @@ describe "Ruby character strings" do
# TODO: spec other source encodings
describe "with ASCII_8BIT source encoding" do
it "produces an ASCII string when escaping ASCII characters via \\u" do
- "\u0000".encoding.should == Encoding::ASCII_8BIT
+ "\u0000".encoding.should == Encoding::BINARY
end
it "produces an ASCII string when escaping ASCII characters via \\u{}" do
- "\u{0000}".encoding.should == Encoding::ASCII_8BIT
+ "\u{0000}".encoding.should == Encoding::BINARY
end
it "produces a UTF-8-encoded string when escaping non-ASCII characters via \\u" do
@@ -260,7 +260,7 @@ end
describe "Ruby String interpolation" do
it "creates a String having an Encoding compatible with all components" do
a = "\u3042"
- b = "abc".encode("ascii-8bit")
+ b = "abc".encode("binary")
str = "#{a} x #{b}"
@@ -280,7 +280,7 @@ describe "Ruby String interpolation" do
it "raises an Encoding::CompatibilityError if the Encodings are not compatible" do
a = "\u3042"
- b = "\xff".force_encoding "ascii-8bit"
+ b = "\xff".force_encoding "binary"
lambda { "#{a} #{b}" }.should raise_error(Encoding::CompatibilityError)
end
diff --git a/spec/ruby/language/super_spec.rb b/spec/ruby/language/super_spec.rb
index ba5300bb99..5aff5e8eea 100644
--- a/spec/ruby/language/super_spec.rb
+++ b/spec/ruby/language/super_spec.rb
@@ -102,6 +102,25 @@ describe "The super keyword" do
c2.new.m(:dump) { :value }.should == :value
end
+ it "uses block argument given to method when used in a block" do
+ c1 = Class.new do
+ def m
+ yield
+ end
+ end
+ c2 = Class.new(c1) do
+ def m(v)
+ ary = []
+ 1.times do
+ ary << super()
+ end
+ ary
+ end
+ end
+
+ c2.new.m(:dump) { :value }.should == [ :value ]
+ end
+
it "calls the superclass method when in a block" do
SuperSpecs::S6.new.here.should == :good
end
diff --git a/spec/ruby/language/symbol_spec.rb b/spec/ruby/language/symbol_spec.rb
index 9ecb44ba87..d6a41d3059 100644
--- a/spec/ruby/language/symbol_spec.rb
+++ b/spec/ruby/language/symbol_spec.rb
@@ -38,7 +38,7 @@ describe "A Symbol literal" do
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"
+ .should == "[105, 108, 95, 195, 169, 116, 97, 105, 116]\n#{Encoding::BINARY.name}\n"
end
it "may contain '::' in the string" do