Ignore:
Timestamp:
Jul 9, 2020, 8:51:43 AM (4 years ago)
Author:
coas-nagasima
Message:

mrubyを2.1.1に更新

Location:
EcnlProtoTool/trunk/mruby-2.1.1
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-2.1.1/mrbgems/mruby-sprintf/test/sprintf.rb

    r331 r439  
    44assert('String#%') do
    55  assert_equal "one=1", "one=%d" % 1
    6   assert_equal "1 one 1.0", "%d %s %3.1f" % [ 1, "one", 1.01 ]
     6  assert_equal "1 one", "%d %s" % [ 1, "one" ]
    77  assert_equal "123 < 456", "%{num} < %<str>s" % { num: 123, str: "456" }
    88  assert_equal 15, ("%b" % (1<<14)).size
     9  skip unless Object.const_defined?(:Float)
     10  assert_equal "1.0", "%3.1f" % 1.01
    911end
    1012
    1113assert('String#% with inf') do
     14  skip unless Object.const_defined?(:Float)
    1215  inf = Float::INFINITY
    1316
     
    3841
    3942assert('String#% with nan') do
     43  skip unless Object.const_defined?(:Float)
    4044  nan = Float::NAN
    4145
     
    7680
    7781    assert_raise TypeError do
    78       "%c" % 0
     82      "%c" % 0x80
    7983    end
    8084  ensure
     
    9296end
    9397
     98assert("String#% %d") do
     99  assert_equal("  10",   "%4d" % 10)
     100  assert_equal("1000",   "%4d" % 1000)
     101  assert_equal("10000",  "%4d" % 10000)
     102end
     103
    94104assert("String#% invalid format") do
    95105  assert_raise ArgumentError do
Note: See TracChangeset for help on using the changeset viewer.