Skip to content
Myr

lint: test code

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 28747e5 · Browse files · 3 files+13 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+13 added−13 removed

  • tests:+13 added−13 removed

3 files+13 added−13 removed

modified:test/test_core.rb+8 added-8 removed
1189 unmodified lines
1190 tmux.until { |lines| assert lines.any_include?('9999␊10000') }1191 end11921193 def test_freeze_left_keep_right1194 tmux.send_keys %[seq 10000 | #{FZF} --read0 --delimiter "\n" --freeze-left 3 --keep-right --ellipsis XX --no-multi-line --bind space:toggle-multi-line], :Enter1194 tmux.send_keys %(seq 10000 | #{FZF} --read0 --delimiter "\n" --freeze-left 3 --keep-right --ellipsis XX --no-multi-line --bind space:toggle-multi-line), :Enter1195 tmux.until { |lines| assert_match(/^> 1␊2␊3XX.*10000␊$/, lines[-3]) }1196 tmux.send_keys '5'1197 tmux.until { |lines| assert_match(/^> 1␊2␊3␊4␊5␊.*XX$/, lines[-3]) }1198 tmux.send_keys :Space
2 unmodified lines
1201 tmux.until { |lines| assert lines.any_include?('1␊2␊3␊4␊5␊') }1202 end12031204 def test_freeze_left_and_right1205 tmux.send_keys %[seq 10000 | tr "\n" ' ' | #{FZF} --freeze-left 3 --freeze-right 3 --ellipsis XX], :Enter1205 tmux.send_keys %(seq 10000 | tr "\n" ' ' | #{FZF} --freeze-left 3 --freeze-right 3 --ellipsis XX), :Enter1206 tmux.until { |lines| assert_match(/XX9998 9999 10000$/, lines[-3]) }1207 tmux.send_keys "'1000"1208 tmux.until { |lines| assert_match(/^> 1 2 3XX.*XX9998 9999 10000$/,lines[-3]) }1208 tmux.until { |lines| assert_match(/^> 1 2 3XX.*XX9998 9999 10000$/, lines[-3]) }1209 end12101211 def test_freeze_left_and_right_delimiter1212 tmux.send_keys %[seq 10000 | tr "\n" ' ' | sed 's/ / , /g' | #{FZF} --freeze-left 3 --freeze-right 3 --ellipsis XX --delimiter ' , '], :Enter1212 tmux.send_keys %(seq 10000 | tr "\n" ' ' | sed 's/ / , /g' | #{FZF} --freeze-left 3 --freeze-right 3 --ellipsis XX --delimiter ' , '), :Enter1213 tmux.until { |lines| assert_match(/XX, 9999 , 10000 ,$/, lines[-3]) }1214 tmux.send_keys "'1000"1215 tmux.until { |lines| assert_match(/^> 1 , 2 , 3 ,XX.*XX, 9999 , 10000 ,$/,lines[-3]) }1215 tmux.until { |lines| assert_match(/^> 1 , 2 , 3 ,XX.*XX, 9999 , 10000 ,$/, lines[-3]) }1216 end12171218 def test_freeze_right_exceed_range1219 tmux.send_keys %[seq 10000 | tr "\n" ' ' | #{FZF} --freeze-right 100000 --ellipsis XX], :Enter1219 tmux.send_keys %(seq 10000 | tr "\n" ' ' | #{FZF} --freeze-right 100000 --ellipsis XX), :Enter1220 ['', "'1000"].each do |query|1221 tmux.send_keys query1222 tmux.until { |lines| assert lines.any_include?("> #{query}".strip) }1223 tmux.until do |lines|
3 unmodified lines
1227 end1228 end12291230 def test_freeze_right_exceed_range_with_freeze_left1231 tmux.send_keys %[seq 10000 | tr "\n" ' ' | #{FZF} --freeze-left 3 --freeze-right 100000 --ellipsis XX], :Enter1231 tmux.send_keys %(seq 10000 | tr "\n" ' ' | #{FZF} --freeze-left 3 --freeze-right 100000 --ellipsis XX), :Enter1232 tmux.until do |lines|1233 assert_match(/^> 1 2 3XX.*9998 9999 10000$/, lines[-3])1234 assert_equal(1, lines[-3].scan('XX').size)1235 end
4 unmodified lines
1240 tmux.until { |lines| assert_equal ' 100/100', lines[-2] }1241 tmux.send_keys(*Array.new(6) { :a })1242 tmux.until do |lines|1243 assert_match(/> 777g+$/, lines[-3])1244 assert_equal 1, lines.count { |l| l.end_with?('g') }1244 assert_equal(1, lines.count { |l| l.end_with?('g') })1245 end1246 end12471248 def test_backward_eof
930 unmodified lines
modified:test/test_filter.rb+1 added-1 removed
318 unmodified lines
319320 # Multiple field selection321 writelines(['ID001:John:Developer', 'ID002:Jane:Manager', 'ID003:Bob:Designer'])322 assert_equal 'ID001', `#{FZF} -d: --with-nth 2 --accept-nth 1 -f John < #{tempname}`.chomp323 assert_equal "ID002:Manager", `#{FZF} -d: --with-nth 2 --accept-nth 1,3 -f Jane < #{tempname}`.chomp323 assert_equal 'ID002:Manager', `#{FZF} -d: --with-nth 2 --accept-nth 1,3 -f Jane < #{tempname}`.chomp324325 # Test with different delimiters326 writelines(['emp001 Alice Engineering', 'emp002 Bob Marketing'])327 assert_equal 'emp001', `#{FZF} -d' ' --with-nth 2 --accept-nth 1 -f Alice < #{tempname}`.chomp
2 unmodified lines
modified:test/test_shell_integration.rb+4 added-4 removed
463 unmodified lines
464 end465466 # Helper function to run test with Perl and again with Awk467 def self.test_perl_and_awk(name, &block)468 define_method("test_#{name}") do468 define_method(:"test_#{name}") do469 instance_eval(&block)470 end471472 define_method("test_#{name}_awk") do472 define_method(:"test_#{name}_awk") do473 tmux.send_keys "unset 'commands[perl]'", :Enter474 tmux.prepare475 # Verify perl is actually unset (0 = not found)476 tmux.send_keys 'echo ${+commands[perl]}', :Enter
81 unmodified lines
558 tmux.send_keys "echo ': 0:0;fzf_cmd_foreign' >> $HISTFILE", :Enter559 tmux.prepare560 # Verify fc shows foreign command with asterisk561 tmux.send_keys 'fc -rl -1', :Enter562 tmux.until { |lines| assert lines.any? { |l| l.match?(/^\s*\d+\* fzf_cmd_foreign/) } }562 tmux.until { |lines| assert(lines.any? { |l| l.match?(/^\s*\d+\* fzf_cmd_foreign/) }) }563 tmux.prepare564 # Test ctrl-r correctly extracts the foreign command565 tmux.send_keys 'C-r'566 tmux.until { |lines| assert_operator lines.match_count, :>, 0 }
2 unmodified lines
569 tmux.send_keys :BTab, :BTab570 tmux.until { |lines| assert_includes lines[-2], '(2)' }571 tmux.send_keys :Enter572 tmux.until do |lines|573 assert_equal ['fzf_cmd_foreign', 'fzf_cmd_local'], lines[-2..]573 assert_equal %w[fzf_cmd_foreign fzf_cmd_local], lines[-2..]574 end575 ensure576 FileUtils.rm_f(histfile)577 end
53 unmodified lines