[macruby-changes] [1335] MacRuby/branches/experimental/spec/frozen

source_changes at macosforge.org source_changes at macosforge.org
Sat Apr 4 08:21:19 PDT 2009


Revision: 1335
          http://trac.macosforge.org/projects/ruby/changeset/1335
Author:   eloy.de.enige at gmail.com
Date:     2009-04-04 08:21:19 -0700 (Sat, 04 Apr 2009)
Log Message:
-----------
Encoding fixes and cleanups for 1.9.

Array#pack with 'p' and 'P' arguments is undefined by
RubySpec because it is too implementation-specific and
is a dangerous feature anyway.

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/core/array/pack_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/readline_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/rewind_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/seek_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/sysseek_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/inspect_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/complex/abs_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/rexml/element/attribute_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb
    MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec

Modified: MacRuby/branches/experimental/spec/frozen/core/array/pack_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/pack_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/array/pack_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -2357,179 +2357,6 @@
   end
 end
 
-
-
-describe "Array#pack with pointer format", :shared => true do
-  before(:all) { require 'dl' }
-  platform_is(:wordsize => 32){ before { @pointer_size = 4 } }
-  platform_is(:wordsize => 64){ before { @pointer_size = 8 } }
-
-  ruby_version_is '' ... '1.9' do
-    before do
-      def self.cstr(ptr)
-        ptr = ptr.unpack({ 4 => 'L', 8 => 'Q' }[@pointer_size]).first
-        ptr = DL::PtrData.new(ptr, 1)
-        def ptr.[](pos) super(pos,1)[0] end
-        ptr
-      end
-
-      def self.cbyte(byte)
-        byte.chr
-      end
-    end
-  end
-  ruby_version_is '1.9' do
-    before do
-      def self.cstr(ptr)
-        ptr = ptr.unpack({ 4 => 'L', 8 => 'Q' }[@pointer_size]).first
-        DL::CPtr.new(ptr, 1)
-      end
-      def self.cbyte(byte)
-        byte.ord
-      end
-    end
-  end
-
-  not_supported_on :jruby do
-    it "returns a pointer to internal byte sequence" do
-      ["abc"].pack('p').length.should == @pointer_size
-    end
-
-    it "returns a pointer which is able to dereferenced into NUL terminated byte sequence" do 
-      ptr = ["\x41\x42\x43"].pack('p')
-      cstr(ptr)[0].should == 0x41
-      cstr(ptr)[1].should == 0x42
-      cstr(ptr)[2].should == 0x43
-      cstr(ptr)[3].should == 0x00
-
-      ptr = [utf8("\xE3\x81\x82")].pack('p')  # Japanese Hiragana 'A' in UTF-8
-      (cstr(ptr)[0] & 0xFF).should == 0xE3
-      (cstr(ptr)[1] & 0xFF).should == 0x81
-      (cstr(ptr)[2] & 0xFF).should == 0x82
-      (cstr(ptr)[3] & 0xFF).should == 0x00
-    end
-
-    it "returns a pointer which is able to dereferenced into a right value" do
-      str = "Tim"
-      ptr = [str].pack('p')
-      cstr(ptr)[0] = cbyte(?J)
-      str.should == "Jim"
-    end
-
-    # TODO: Is there an architecture whose internal representation of NULL pointer is not zero and on which Ruby can work?
-    it "returns null pointer when passed nil" do
-      [nil].pack('p').should == "\x00" * @pointer_size
-    end
-  end
-end
-
-describe "Array#pack with format 'p'" do
-  not_supported_on :jruby do
-    it "consumes a String" do
-      lambda { ["abc"].pack('p') }.should_not raise_error
-      ["abc", 0x7E].pack('pC')[-1, 1].should == "\x7E"
-    end
-
-    it_behaves_like "Array#pack with pointer format", 'p'
-
-    it "tries to convert the pack argument to a String using #to_str" do
-      obj = mock('to_str')
-      obj.should_receive(:to_str).and_return("abc")
-      lambda{ [obj].pack('p') }.should_not raise_error
-    end
-
-    it "raises a TypeError if corresponding array item is not String" do
-      lambda { [123].pack('p') }.should raise_error(TypeError)
-      lambda { [:data].pack('p') }.should raise_error(TypeError)
-      lambda { [mock('not string')].pack('p') }.should raise_error(TypeError)
-    end
-
-    it "returns empty string if count = 0 with" do
-      ['abcde'].pack("p0").should == ''
-    end
-
-    it "only takes as many elements as specified after ('p')" do
-      ary = ["abc", "def", "ghi", "jkl"]
-      ary.pack('p').should == [ary[0]].pack('p')
-      ary.pack('p2').should == [ary[0]].pack('p') + [ary[1]].pack('p')
-      ary.pack('p2p').should == [ary[0]].pack('p') + [ary[1]].pack('p') + [ary[2]].pack('p')
-    end
-
-    it "consumes the whole argument string with star parameter" do
-      ary = ["abc", "def", "ghi", "jkl"]
-      ary.pack('p*').should == ary.pack('p4')
-    end
-
-    it "raises an ArgumentError if count is greater than array elements left" do
-      lambda { ["abc", "def"].pack("p3") }.should raise_error(ArgumentError)
-    end
-
-    ruby_version_is '1.9' do
-      it "returns an ASCII-8BIT string" do
-	["abcd"].pack('p').encoding.should == Encoding::ASCII_8BIT
-      end
-    end
-  end
-end
-
-describe "Array#pack with format 'P'" do
-  not_supported_on :jruby do
-    it "consumes a String" do
-      lambda { ["abc"].pack('P') }.should_not raise_error
-      ["abc", 0x7E].pack('PC')[-1, 1].should == "\x7E"
-    end
-
-    it_behaves_like "Array#pack with pointer format", 'P'
-
-    # TODO: Is there an architecture whose internal representation of NULL pointer is not zero and on which Ruby can work?
-    it "returns null pointer when passed nil" do
-      [nil].pack('P').should == "\x00" * @pointer_size
-    end
-
-    it "tries to convert the pack argument to a String using #to_str" do
-      obj = mock('to_str')
-      obj.should_receive(:to_str).any_number_of_times.and_return("abc")
-      lambda{ [obj].pack('P') }.should_not raise_error
-    end
-
-    it "raises a TypeError if corresponding array item is not String" do
-      lambda { [123].pack('P') }.should raise_error(TypeError)
-      lambda { [:data].pack('P') }.should raise_error(TypeError)
-      lambda { [mock('not string')].pack('P') }.should raise_error(TypeError)
-    end
-
-    it "consumes one array item per a format" do
-      ary = ["abc", "def", "ghi", "jkl"]
-      ary.pack('P').should == [ary[0]].pack('P')
-      ary.pack('P2').should == [ary[0]].pack('P')
-      ary.pack('P2P').should == [ary[0]].pack('P') + [ary[1]].pack('P')
-    end
-
-    ruby_bug("[ruby-dev:37289]", "1.8.7.73") do
-      it "ignores '*' parameter" do 
-	ary = ["abc", "def", "ghi", "jkl"]
-	ary.pack('P*').should == [ary[0]].pack('P')
-      end
-    end
-
-    it "returns a pointer to zero-length byte sequence if count = 0 with" do
-      str = 'abcde'
-      [str].pack('P0').should == [str].pack('P')
-    end
-
-    it "raises an ArgumentError if count is greater than the corresponding string in array" do
-      lambda { ["abc", "def"].pack("P3") }.should_not raise_error(ArgumentError)
-      lambda { ["ab", "def"].pack("P3") }.should raise_error(ArgumentError)
-    end
-
-    ruby_version_is '1.9' do
-      it "returns an ASCII-8BIT string" do
-	["abcd"].pack('P').encoding.should == Encoding::ASCII_8BIT
-      end
-    end
-  end
-end
-
 describe "String#unpack with 'w' directive" do
   it "produces a BER-compressed integer" do
     [88].pack('w').should == 'X'

Modified: MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -11,30 +11,35 @@
 #   #call             OK
 #   #[]               OK
 
+module ContinuationSpecs
+  def self.create_cc
+    Kernel.callcc { |cc| return cc }
+    :create_cc
+  end
+end
 
-describe "Creating a Continuation object" do
-  not_supported_on :ironruby do
+not_supported_on :ironruby do
+  describe "Creating a Continuation object" do
     it "must be done through Kernel.callcc, no .new" do
       lambda { Continuation.new }.should raise_error(NoMethodError)
 
-      Kernel.callcc {|@cc|}
-      c = @cc
-      c.class.should == Continuation
+      cont = ContinuationSpecs.create_cc
+      cont.class.should == Continuation
     end
   end
 end
 
 
-describe "Executing a Continuation" do
-  not_supported_on :ironruby do
+not_supported_on :ironruby do
+  describe "Executing a Continuation" do
     it "using #call transfers execution to right after the Kernel.callcc block" do
       array = [:reached, :not_reached]
 
-      Kernel.callcc {|@cc|}
+      cont = ContinuationSpecs.create_cc
 
       unless array.first == :not_reached
         array.shift
-        @cc.call
+        cont.call
       end
 
       array.should == [:not_reached]

Modified: MacRuby/branches/experimental/spec/frozen/core/io/readline_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/readline_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/io/readline_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 

Modified: MacRuby/branches/experimental/spec/frozen/core/io/rewind_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/rewind_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/io/rewind_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 

Modified: MacRuby/branches/experimental/spec/frozen/core/io/seek_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/seek_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/io/seek_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 

Modified: MacRuby/branches/experimental/spec/frozen/core/io/sysseek_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/sysseek_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/io/sysseek_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 

Modified: MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes.rb'
 

Modified: MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes.rb'
 

Modified: MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes.rb'
 
@@ -3,5 +4,5 @@
 describe "String#dump" do
   # Older versions of MRI wrongly print \b as \010
-  it "produces a version of self with all nonprinting charaters replaced by \\nnn notation" do
+  it "returns a string with nonprinting charaters replaced by escaped-numeric notation" do
     ("\000".."A").to_a.to_s.dump.should == "\"\\000\\001\\002\\003\\004\\005\\006\\a\\b\\t\\n\\v\\f\\r\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\e\\034\\035\\036\\037 !\\\"\\\#$%&'()*+,-./0123456789\""
   end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/inspect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/inspect_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/string/inspect_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes.rb'
 
@@ -3,5 +4,5 @@
 describe "String#inspect" do
   # Older versions of MRI wrongly print \b as \010
-  it "produces a version of self with all nonprinting charaters replaced by \\nnn notation" do
+  it "returns a string with nonprinting charaters replaced by escaped-numeric notation" do
     ("\000".."A").to_a.to_s.inspect.should == "\"\\000\\001\\002\\003\\004\\005\\006\\a\\b\\t\\n\\v\\f\\r\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\e\\034\\035\\036\\037 !\\\"\\\#$%&'()*+,-./0123456789\""
   end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes.rb'
 

Modified: MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes.rb'
 

Modified: MacRuby/branches/experimental/spec/frozen/library/complex/abs_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/complex/abs_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/library/complex/abs_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -2,7 +2,7 @@
 require 'complex'
 
 describe "Complex#abs" do
-  it "returns the modulus: |a + bi| = \xC3((a ^ 2) + (b ^ 2))" do
+  it "returns the modulus: |a + bi| = sqrt((a ^ 2) + (b ^ 2))" do
     Complex(0, 0).abs.should == 0
     Complex(3, 4).abs.should == 5 # well-known integer case
     Complex(-3, 4).abs.should == 5

Modified: MacRuby/branches/experimental/spec/frozen/library/rexml/element/attribute_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rexml/element/attribute_spec.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/library/rexml/element/attribute_spec.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -11,7 +11,7 @@
 
   it "supports attributes inside namespaces" do
     e = REXML::Element.new("element")
-    e.add_attributes({"xmlns:ns", "http://some_uri"})
+    e.add_attributes({"xmlns:ns" => "http://some_uri"})
     e.attribute("ns", "ns").to_s.should == "http://some_uri"
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb	2009-04-04 15:21:19 UTC (rev 1335)
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 describe :stringio_each_char, :shared => true do
   before(:each) do
     old_kcode, $KCODE = "UTF-8", $KCODE

Modified: MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec
===================================================================
--- MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec	2009-04-04 15:20:46 UTC (rev 1334)
+++ MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec	2009-04-04 15:21:19 UTC (rev 1335)
@@ -3,8 +3,12 @@
   set :language, [ 'language' ]
 
   # Core library specs
-  set :core, [ 'core' ]
+  set :core, [
+    'core',
 
+    '^core/continuation'
+  ]
+
   # Standard library specs
   set :library, [
     'library',
@@ -52,16 +56,18 @@
   # MacRuby TODO: For now we run the macruby tags.
   #
   # set :tags_patterns, [
-  #                       [%r(language/), 'tags/1.9/language/'],
-  #                       [%r(core/),     'tags/1.9/core/'],
-  #                       [%r(library/),  'tags/1.9/library/'],
-  #                       [/_spec.rb$/,   '_tags.txt']
+  #                       [%r(language/),     'tags/1.9/language/'],
+  #                       [%r(core/),         'tags/1.9/core/'],
+  #                       [%r(command_line/), 'tags/1.9/command_line/'],
+  #                       [%r(library/),      'tags/1.9/library/'],
+  #                       [/_spec.rb$/,       '_tags.txt']
   #                     ]
 
   set :tags_patterns, [
-                        [%r(language/), 'tags/macruby/language/'],
-                        [%r(core/),     'tags/macruby/core/'],
-                        [%r(library/),  'tags/macruby/library/'],
-                        [/_spec.rb$/,   '_tags.txt']
+                        [%r(language/),     'tags/macruby/language/'],
+                        [%r(core/),         'tags/macruby/core/'],
+                        [%r(command_line/), 'tags/macruby/command_line/'],
+                        [%r(library/),      'tags/macruby/library/'],
+                        [/_spec.rb$/,       '_tags.txt']
                       ]
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090404/6567061f/attachment-0001.html>


More information about the macruby-changes mailing list