[macruby-changes] [MacRuby/MacRuby] b78d2b: allow multiple named argument in String#%. fix #13...

GitHub noreply at github.com
Sat Jan 28 17:49:45 PST 2012


  Branch: refs/heads/master
  Home:   https://github.com/MacRuby/MacRuby
  Commit: b78d2b6130ff7d2460572025b68434c0fbbf93c3
      https://github.com/MacRuby/MacRuby/commit/b78d2b6130ff7d2460572025b68434c0fbbf93c3
  Author: Watson <watson1978 at gmail.com>
  Date:   2012-01-28 (Sat, 28 Jan 2012)

  Changed paths:
    M sprintf.c

  Log Message:
  -----------
  allow multiple named argument in String#%. fix #1342

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 } }





More information about the macruby-changes mailing list