Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 95 lines (75 sloc) 2.347 kb
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
Code.require_file "../../test_helper.exs", __FILE__

defmodule IEx.AutocompleteTest do
  use ExUnit.Case, async: true

  def expand(expr) do
    IEx.Autocomplete.expand(Enum.reverse expr)
  end

  test :erlang_module_simple_completion do
    assert expand(':z') == {:yes, 'lib.', []}
  end

  test :erlang_module_no_completion do
    assert expand(':x') == {:no, '', []}
    assert expand('x.Foo') == {:no, '', []}
  end

  test :erlang_module_common_prefix_completion do
    assert expand(':us') == {:yes, 'er', []}
  end

  test :erlang_module_multiple_values_completion do
    {:yes, '', list} = expand(':user')
    assert length(list) > 1
  end

  test :elixir_simple_completion do
    assert expand('En') == {:yes, 'um.', []}
  end

  test :elixir_auto_completion_with_self do
    assert expand('Enum') == {:yes, '.', []}
  end

  test :elixir_no_completion do
    assert expand('Xyz') == {:no, '', []}
  end

  test :elixir_root_submodule_completion do
    _ = [foo: 1][:foo]
    assert expand('Elixir.Acce') == {:yes, 'ss.', []}
  end

  test :elixir_submodule_completion do
    assert expand('Binary.Cha') == {:yes, 'rs.', []}
  end

  test :elixir_submodule_no_completion do
    assert expand('IEx.Xyz') == {:no, '', []}
  end

  test :elixir_function_completion do
    assert expand('System.ve') == {:yes, 'rsion', []}
  end

  test :elixir_function_completion_with_arity do
    assert expand('Enum.all?') == {:yes, '', ['all?/2']}
    assert expand('Enum.all?/') == {:yes, '', ['all?/2']}
  end

  test :elixir_macro_completion do
    {:yes, '', list} = expand('Kernel.is_')
    assert is_list(list)
  end

  test :elixir_root_completion do
    {:yes, '', list} = expand('')
    assert is_list(list)
    assert 'h/1' in list
    assert 'Elixir' in list
  end

  test :elixir_kernel_completion do
    assert expand('defreco') == {:yes, 'rd', []}
  end

  test :elixir_proxy do
    {:yes, '', list} = expand('E')
    assert 'Elixir' in list
  end

  test :elixir_erlang_module_root_completion do
    {:yes, '', list} = expand(':')
    assert is_list(list)
    assert 'lists' in list
  end

  test :completion_inside_expression do
    assert expand('1+En') == {:yes, 'um.', []}
    assert expand('Test(En') == {:yes, 'um.', []}
    assert expand('Test :z') == {:yes, 'lib.', []}
    assert expand('[:z') == {:yes, 'lib.', []}
  end
end
Something went wrong with that request. Please try again.