Skip to content
Commits on Apr 23, 2012
  1. @ferrous26
Commits on Feb 1, 2012
  1. @Watson1978

    fix named argument

    Watson1978 committed
    Test Script:
    ----
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal(
      "foo, bar",
      "%{firstname}, %{lastname}" % {firstname: "foo", lastname: "bar"}
    )
    
    assert_equal(
      "10, 43.5",
      "%<integer>d, %<float>.1f" % { integer: 10, float: 43.476374 }
    )
    
    assert_equal(
      "10<float>",
      "%{integer}<float>" % { integer: 10, float: 43.476374 }
    )
    
    assert_raise(ArgumentError){ "%<foo><bar>" % { foo: 10, bar: 42 } }
    #----
    assert_equal(
      "01 : 02",
      "%<foo>02d : %<bar>02d" % { :foo => 1, :bar => 2 }
    )
    
    assert_equal(
      "01<foo>",
      "%02d<foo>" % [1, {:foo => 1}]
    )
    assert_raise(ArgumentError){ "%s %1$s" % "foo" }
    assert_raise(ArgumentError){ "%02d%<foo>" % [1, {:foo => 1}] }
    assert_raise(ArgumentError){ "%1$<key2>s" % {:key => "value"} }
Commits on Jan 30, 2012
  1. @Watson1978

    allow omitting width at precision

    Watson1978 committed
    Test Script:
    ----
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("42", "%.d" % [42.34])
    assert_equal("42", "%.*d" % [0, 42.34])
    
    assert_raise(ArgumentError){ "%. d" % 42 }
    assert_raise(ArgumentError){ "%.#d" % 42 }
    assert_raise(ArgumentError){ "%.+d" % 42 }
    assert_raise(ArgumentError){ "%.-d" % 42 }
    
    assert_raise(ArgumentError){ "%* d" % 42 }
    assert_raise(ArgumentError){ "%*#d" % 42 }
    assert_raise(ArgumentError){ "%*+d" % 42 }
    assert_raise(ArgumentError){ "%*-d" % 42 }
  2. @Watson1978

    check whether width is specified after precision

    Watson1978 committed
    Test Script:
    ----
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_raise(ArgumentError){ "%.4*d" % [42, 2] }
Commits on Jan 29, 2012
  1. @Watson1978

    allow multiple named argument in String#%. fix #1342

    Watson1978 committed
    Test Script:
    ----
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal(
      "foo, bar",
      "%{firstname}, %{lastname}" % {firstname: "foo", lastname: "bar"}
    )
    
    assert_equal(
      "10, 43.5",
      "%<integer>d, %<float>.1f" % { integer: 10, float: 43.476374 }
    )
    
    assert_equal(
      "10<float>",
      "%{integer}<float>" % { integer: 10, float: 43.476374 }
    )
    
    assert_raise(ArgumentError){ "%<foo><bar>" % { foo: 10, bar: 42 } }
Commits on Dec 19, 2011
  1. @Watson1978
Commits on Jan 16, 2011
  1. @Watson1978

    Fixed the bug of sprintf with format like a "%010.4u".

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("      000000000000000000000123", sprintf("%030.24u", 123))
    assert_equal("     -000000000000000000000123", sprintf("%030.24u", -123))
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5173 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Jan 15, 2011
  1. @Watson1978

    Fixed the bug of sprintf. "#" flag should be ignored with "dDiuU" for…

    Watson1978 committed
    …mat.
    
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("-0000123", sprintf("%#+08u", -123))
    assert_equal("-0000123", sprintf("%#+08d", -123))
    assert_equal("-0000123", sprintf("%#+08i", -123))
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5172 23306eb0-4c56-4727-a40e-e92c0eb68959
  2. @Watson1978

    Fixed the bug of sprintf with format like a "%010.4f".

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("00123.1000", sprintf("%010.4f", 123.1))
    assert_equal("  0000007b", sprintf("%010.8x", 123))
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5171 23306eb0-4c56-4727-a40e-e92c0eb68959
  3. @Watson1978

    Fixed the bug of sprintf with format "%# x".

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal(" 0x7b",   sprintf("%# x", 123))
    assert_equal("-0x7b",   sprintf("%# x", -123))
    assert_equal("0x..f85", sprintf("%#x", -123))
    
    assert_equal("7b",    sprintf("%x", 123))
    assert_equal("0x7b",  sprintf("%#x", 123))
    assert_equal(" 7b",   sprintf("% x", 123))
    assert_equal("..ffff85", sprintf("%08x", -123))
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5170 23306eb0-4c56-4727-a40e-e92c0eb68959
  4. update copyrights to 2011

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5168 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Jan 8, 2011
  1. include/ruby/macruby.h -> macruby_internal.h

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5137 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Jan 5, 2011
  1. introduce a better unichar API, which should be as fast as before the…

    Laurent Sansonetti committed
    … recent string datastore change, also fixing the rubygems crasher and also various memory leaks
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5114 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Dec 11, 2010
  1. @Watson1978

    sprintf("%c") will throw an exception when does not pass one character.

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_raise(ArgumentError) { sprintf("%c", "cc") }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5015 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Nov 26, 2010
  1. @Watson1978

    sprintf() will be given a format which is width's * and precision's *.

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("   1.00000", sprintf("%*.*f", 10, 5, 1))
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4950 23306eb0-4c56-4727-a40e-e92c0eb68959
  2. @Watson1978

    sprintf() will be given the positional arguments and precision tokens…

    Watson1978 committed
    … given for one format.
    
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("0", sprintf("%2$1d", 1, 0))
    assert_equal("001", sprintf("%2$03d", 0, 1))
    
    assert_equal("0.00", sprintf("%2$.2f", 1, 0))
    assert_equal("1.00", sprintf("%2$.2f", 0, 1))
    
    assert_raise(ArgumentError){ sprintf("%1$<key>s", :key => "value") }
    assert_raise(ArgumentError){ sprintf("%5d %<key>s", 10, :key => "value") }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4949 23306eb0-4c56-4727-a40e-e92c0eb68959
  3. @Watson1978

    fixed the bug of sprintf() within "%{named}" format.

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("value", sprintf("%{key}", :key => "value"))
    assert_equal("1234.56", sprintf("%{key}", :key => 1234.56))
    assert_equal("value{key2}", sprintf("%{key}{key2}", :key => "value"))
    assert_raise(ArgumentError) {sprintf("%1${key2}", :key => "value")}
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4948 23306eb0-4c56-4727-a40e-e92c0eb68959
  4. @Watson1978

    sprintf() will throw an exception when was given named format twice.

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_raise(ArgumentError) {sprintf("%<key><key2>s", { :key => "value", :key2 => "test" }) }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4947 23306eb0-4c56-4727-a40e-e92c0eb68959
  5. @Watson1978

    fixed the bug of sprintf() within "%<named>" format

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("value", sprintf("%<key>s", :key => "value"))
    assert_equal("12345", sprintf("%<test>d", :test=> 12345))
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4946 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Nov 23, 2010
  1. @Watson1978

    sprintf() will throw an exception when was given positional format tw…

    Watson1978 committed
    …ice.
    
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_raise(ArgumentError){ sprintf("%1$1$s", "foo") }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4939 23306eb0-4c56-4727-a40e-e92c0eb68959
  2. @Watson1978

    String#% will throw an ArgumentError when was given "*0$" format.

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_raise(ArgumentError){ "%*0$s" % [5, "x"] }
    assert_raise(ArgumentError){ "%*1$.*0$1$s" % [1, 2, 3] }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4938 23306eb0-4c56-4727-a40e-e92c0eb68959
  3. @Watson1978

    sprintf() will throw an exception when was given precision format twice.

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_raise(ArgumentError){ sprintf("%.5.5s", 5) }
    assert_raise(ArgumentError){ sprintf("%.5.*s", 5, 5) }
    assert_raise(ArgumentError){ sprintf("%.*.5s", 5, 5) }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4932 23306eb0-4c56-4727-a40e-e92c0eb68959
  4. @Watson1978

    sprintf() will throw an exception when was given width format twice.

    Watson1978 committed
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_raise(ArgumentError){ sprintf("%**s", 5, 5, 5) }
    assert_raise(ArgumentError){ sprintf("%5*s", 5, 5) }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4931 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Nov 22, 2010
  1. @Watson1978

    modified the style of r4928.

    Watson1978 committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4929 23306eb0-4c56-4727-a40e-e92c0eb68959
  2. @Watson1978

    sprintf() will not throw exception when passed the format of single %…

    Watson1978 committed
    … character before a '\n' or '\0'.
    
    Test Script:
    {{{
    require 'test/unit/assertions.rb'
    include Test::Unit::Assertions
    
    assert_equal("%", sprintf("%", ""))
    assert_equal("foo%", sprintf("foo%", ""))
    assert_equal("%\n", sprintf("%\n", ""))
    assert_equal("%\n.3f", sprintf("%\n.3f", 1.2))
    assert_equal("%\x00.3f", sprintf("%\0.3f", 1.2))
    assert_raise(ArgumentError){ sprintf("% ", "") }
    
    puts :ok
    }}}
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4928 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Aug 30, 2010
  1. #sprintf: don't try to mutate symbols

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4478 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Jul 8, 2010
  1. Move Obj-C related headers around.

    Thibault Martin-Lagardette committed
    Snything that is Obj-C related is now in a separate header. This will avoid "true" to already be defined for example.
    
     - Fixes <rdar://problem/7871199>
     - Fixes #728
    
    
    
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4330 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Mar 19, 2010
  1. fixed a few bugs in #sprintf

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3819 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Mar 18, 2010
  1. fixed some bugs in Numeric#chr

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3811 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Mar 6, 2010
  1. some sprintf fixes

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/icu@3711 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Mar 2, 2010
  1. unicode string formats (a work in progress)

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/icu@3663 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Feb 26, 2010
  1. added #%, added remaining NSString primitives

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/icu@3630 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on Feb 11, 2010
  1. sprintf can now be free of C++ evil

    Laurent Sansonetti committed
    git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3488 23306eb0-4c56-4727-a40e-e92c0eb68959
Commits on May 23, 2009
  1. the great schism, part I

    Laurent Sansonetti committed
Commits on Mar 11, 2009
  1. committing experimental branch content

    Laurent Sansonetti committed
Something went wrong with that request. Please try again.