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:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enumerator/mrblib/enumerator.rb

    r321 r331  
    154154  def with_index(offset=0)
    155155    return to_enum :with_index, offset unless block_given?
    156     raise TypeError, "no implicit conversion of #{offset.class} into Integer" unless offset.respond_to?(:to_int)
    157 
    158     n = offset.to_int - 1
    159     enumerator_block_call do |i|
     156    offset = if offset.nil?
     157      0
     158    elsif offset.respond_to?(:to_int)
     159      offset.to_int
     160    else
     161      raise TypeError, "no implicit conversion of #{offset.class} into Integer"
     162    end
     163
     164    n = offset - 1
     165    enumerator_block_call do |*i|
    160166      n += 1
    161       yield [i,n]
     167      yield i.__svalue, n
    162168    end
    163169  end
     
    172178  # If no block is given, a new Enumerator is returned that includes the index.
    173179  #
    174   def each_with_index
    175     with_index
     180  def each_with_index(&block)
     181    with_index(0, &block)
    176182  end
    177183
     
    517523  # just for internal
    518524  class Generator
     525    include Enumerable
    519526    def initialize(&block)
    520527      raise TypeError, "wrong argument type #{self.class} (expected Proc)" unless block.kind_of? Proc
  • EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enumerator/test/enumerator.rb

    r321 r331  
    5151  assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
    5252  assert_equal([[1,5],[2,6],[3,7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a)
     53  a = []
     54  @obj.to_enum(:foo, 1, 2, 3).with_index(10).with_index(20) { |*i| a << i }
     55  assert_equal [[[1, 10], 20], [[2, 11], 21], [[3, 12], 22]], a
    5356end
    5457
     
    6164assert 'Enumerator#with_index string offset' do
    6265  assert_raise(TypeError){ @obj.to_enum(:foo, 1, 2, 3).with_index('1').to_a }
     66end
     67
     68assert 'Enumerator#each_with_index' do
     69  assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).each_with_index.to_a)
     70  a = []
     71  @obj.to_enum(:foo, 1, 2, 3).each_with_index {|*i| a << i}
     72  assert_equal([[1, 0], [2, 1], [3, 2]], a)
    6373end
    6474
Note: See TracChangeset for help on using the changeset viewer.