Sha256: 8661e30db28e14f7498be0115ce0454bc1fb920b1435df118b229ea333427d7b

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require_relative '../../app/complete'

class TestAppUtil < Test::Unit::TestCase
  include Trepan::Complete
  def test_complete
    hash = {'ab' => 1, 'aac' => 2, 'aa' => 3, 'a' => 4}
    ary = hash.keys.sort
    [[[], 'b'], [ary, 'a'], [%w(aa aac), 'aa'], 
     [ary, ''], [['ab'], 'ab'], [[], 'abc']].each do |result, prefix|
      assert_equal(result, complete_token(ary, prefix),
                   "Trouble matching #{ary}.inspect on #{prefix.inspect}")
    end
    [[ary, 'a'], [%w(aa aac), 'aa'], 
     [['ab'], 'ab'], [[], 'abc']].each do |result_keys, prefix|
      result = result_keys.map {|key| [key, hash[key]]}
      assert_equal(result, complete_token_with_next(hash, prefix),
                   "Trouble matching #{hash}.inspect on #{prefix.inspect}")
    end
    
  end

  def test_next_token
    x = '  now is  the  time'
    [[0, [ 5, 'now']], 
     [2, [ 5, 'now']],
     [5, [ 8, 'is']], 
     [8, [13, 'the']],
     [9, [13, 'the']],
     [13, [19, 'time']],
     [19, [19, '']],
    ].each do |pos, expect|
      assert_equal(expect, next_token(x, pos),
                   "Trouble with next_token(#{x}, #{pos})")

    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trepanning-2.15.35 test/unit/test-app-complete.rb
trepanning-1.93.35 test/unit/test-app-complete.rb
trepanning-2.15.33 test/unit/test-app-complete.rb
trepanning-1.93.32 test/unit/test-app-complete.rb