Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

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

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/test/string.rb

    r321 r331  
    33
    44UTF8STRING = ("\343\201\202".size == 1)
     5
     6assert('String.try_convert') do
     7  assert_nil String.try_convert(nil)
     8  assert_nil String.try_convert(:foo)
     9  assert_equal "", String.try_convert("")
     10  assert_equal "1,2,3", String.try_convert("1,2,3")
     11end
    512
    613assert('String#getbyte') do
     
    2229  assert_equal(h, str1.getbyte(0))
    2330  assert_equal("Hello", str1)
     31end
     32
     33assert("String#setbyte raises IndexError if arg conversion resizes String") do
     34  $s = "01234\n"
     35  class Tmp
     36      def to_i
     37          $s.chomp! ''
     38          95
     39      end
     40  end
     41  tmp = Tmp.new
     42  assert_raise(IndexError) { $s.setbyte(5, tmp) }
    2443end
    2544
     
    104123
    105124assert('String#concat') do
    106   s = "Hello "
    107   s.concat "World!"
    108   t = "Hello "
    109   t << "World!"
    110   assert_equal "Hello World!", t
    111   assert_equal "Hello World!", s
     125  assert_equal "Hello World!", "Hello " << "World" << 33
     126  assert_equal "Hello World!", "Hello ".concat("World").concat(33)
     127
     128  o = Object.new
     129  def o.to_str
     130    "to_str"
     131  end
     132  assert_equal "hi to_str", "hi " << o
     133
     134  assert_raise(TypeError) { "".concat(Object.new) }
    112135end
    113136
     
    400423  assert_raise(IndexError) { "abcd".insert(5, 'X') }
    401424  assert_raise(IndexError) { "abcd".insert(-6, 'X') }
     425
     426  a = "abcd"
     427  a.insert(0, 'X')
     428  assert_equal "Xabcd", a
    402429end
    403430
     
    411438  assert_equal "hello", "hello".ljust(4)
    412439  assert_equal "hello               ", "hello".ljust(20)
     440  assert_equal 20, "hello".ljust(20).length
    413441  assert_equal "hello123412341234123", "hello".ljust(20, '1234')
    414442  assert_equal "hello", "hello".ljust(-3)
    415443end
    416444
     445assert('String#rjust') do
     446  assert_equal "hello", "hello".rjust(4)
     447  assert_equal "               hello", "hello".rjust(20)
     448  assert_equal 20, "hello".rjust(20).length
     449  assert_equal "123412341234123hello", "hello".rjust(20, '1234')
     450  assert_equal "hello", "hello".rjust(-3)
     451end
     452
     453if UTF8STRING
     454  assert('String#ljust with UTF8') do
     455    assert_equal "helloん              ", "helloん".ljust(20)
     456    assert_equal "helloó                            ", "helloó".ljust(34)
     457    assert_equal 34, "helloó".ljust(34).length
     458    assert_equal "helloんんんんんんんんんんんんんん", "hello".ljust(19, 'ん')
     459    assert_equal "helloんんんんんんんんんんんんんんん", "hello".ljust(20, 'ん')
     460  end
     461
     462  assert('String#rjust with UTF8') do
     463    assert_equal "              helloん", "helloん".rjust(20)
     464    assert_equal "                            helloó", "helloó".rjust(34)
     465    # assert_equal 34, "helloó".rjust(34).length
     466    assert_equal "んんんんんんんんんんんんんんhello", "hello".rjust(19, 'ん')
     467    assert_equal "んんんんんんんんんんんんんんんhello", "hello".rjust(20, 'ん')
     468  end
     469
     470  assert('UTF8 byte counting') do
     471    ret = '                                  '
     472    ret[-6..-1] = "helloó"
     473    assert_equal 34, ret.length
     474  end
     475end
     476
     477assert('String#ljust should not change string') do
     478  a = "hello"
     479  a.ljust(20)
     480  assert_equal "hello", a
     481end
     482
     483assert('String#rjust should not change string') do
     484  a = "hello"
     485  a.rjust(20)
     486  assert_equal "hello", a
     487end
     488
     489assert('String#ljust should raise on zero width padding') do
     490  assert_raise(ArgumentError) { "foo".ljust(10, '') }
     491end
     492
     493assert('String#rjust should raise on zero width padding') do
     494  assert_raise(ArgumentError) { "foo".rjust(10, '') }
     495end
     496
    417497assert('String#upto') do
     498  assert_equal %w(a8 a9 b0 b1 b2 b3 b4 b5 b6), "a8".upto("b6").to_a
     499  assert_equal ["9", "10", "11"], "9".upto("11").to_a
     500  assert_equal [], "25".upto("5").to_a
     501  assert_equal ["07", "08", "09", "10", "11"], "07".upto("11").to_a
     502
     503if UTF8STRING
     504  assert_equal ["あ", "ぃ", "い", "ぅ", "う", "ぇ", "え", "ぉ", "お"], "あ".upto("お").to_a
     505end
     506
     507  assert_equal ["9", ":", ";", "<", "=", ">", "?", "@", "A"], "9".upto("A").to_a
     508
    418509  a     = "aa"
    419510  start = "aa"
     
    475566  })
    476567  assert_equal(2, count)
     568
     569  assert_raise(TypeError) { "a".upto(:c) {} }
    477570end
    478571
     
    480573  got = "hello!".split('').map {|x| x.ord}
    481574  expect = [104, 101, 108, 108, 111, 33]
     575  unless UTF8STRING
     576    got << "\xff".ord
     577    expect << 0xff
     578  end
    482579  assert_equal expect, got
    483580end
Note: See TracChangeset for help on using the changeset viewer.