summaryrefslogtreecommitdiffhomepage
path: root/samples/10_advanced_debugging/03_unit_tests/suggest_autocompletion_tests.rb
blob: e286a6ce4b017fdd965fd461d54eff0a5be7e4ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def default_suggest_autocompletion args
  {
    index: 4,
    text: "args.",
    __meta__: {
      other_options: [
        {
          index: Fixnum,
          file: "app/main.rb"
        }
      ]
    }
  }
end

def assert_completion source, *expected
  results = suggest_autocompletion text:  (source.strip.gsub  ":cursor", ""),
                                   index: (source.strip.index ":cursor")

  puts results
end

def test_args_completion args, assert
  $gtk.write_file_root "autocomplete.txt", ($gtk.suggest_autocompletion text: <<-S, index: 128).join("\n")
require 'app/game.rb'

def tick args
  args.gtk.suppress_mailbox = false
  $game ||= Game.new
  $game.args = args
  $game.args.
  $game.tick
end
S

  puts "contents:"
  puts ($gtk.read_file "autocomplete.txt")
end