|
5 | 5 |
|
6 | 6 | describe 'function syntax' do
|
7 | 7 | it 'doesnt treat underscored functions like unsued variables' do
|
8 |
| - expect(<<~EOF).to include_elixir_syntax('elixirId', '__ensure_defimpl__') |
| 8 | + expect(<<~EOF).to include_elixir_syntax('elixirFunctionCall', '__ensure_defimpl__') |
9 | 9 | defp derive(protocol, for, struct, opts, env) do
|
10 | 10 | # ... code ...
|
11 | 11 | __ensure_defimpl__(protocol, for, env)
|
|
17 | 17 | __ensure_defimpl__(protocol, for, env)
|
18 | 18 | EOF
|
19 | 19 | end
|
| 20 | + |
| 21 | + it 'matches top-level macros as elixirKeyword' do |
| 22 | + expect(<<~EOF).to include_elixir_syntax('elixirKeyword', 'quote') |
| 23 | + quote do |
| 24 | + # ... code ... |
| 25 | + end |
| 26 | + EOF |
| 27 | + |
| 28 | + expect(<<~EOF).to include_elixir_syntax('elixirKeyword', 'quote') |
| 29 | + quote(do: '') |
| 30 | + EOF |
| 31 | + end |
| 32 | + |
| 33 | + it 'detects higher order function calls' do |
| 34 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 35 | + func.() |
| 36 | + EOF |
| 37 | + end |
| 38 | + |
| 39 | + it 'detects function calls with parenthesis' do |
| 40 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 41 | + func() |
| 42 | + EOF |
| 43 | + end |
| 44 | + |
| 45 | + it 'detects function calls with bangs' do |
| 46 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func!') |
| 47 | + func!() |
| 48 | + EOF |
| 49 | + end |
| 50 | + |
| 51 | + it 'detects function calls with question marks' do |
| 52 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func?') |
| 53 | + func?() |
| 54 | + EOF |
| 55 | + end |
| 56 | + |
| 57 | + it 'detects function calls appended by module with parenthesis' do |
| 58 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 59 | + Mod.func() |
| 60 | + EOF |
| 61 | + end |
| 62 | + |
| 63 | + it 'detects function calls appended by atom with parenthesis' do |
| 64 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 65 | + :mod.func() |
| 66 | + EOF |
| 67 | + end |
| 68 | + |
| 69 | + it 'detects function calls appended by module without parenthesis' do |
| 70 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 71 | + Mod.func |
| 72 | + EOF |
| 73 | + end |
| 74 | + |
| 75 | + it 'detects function calls appended by atom without parenthesis' do |
| 76 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 77 | + :mod.func |
| 78 | + EOF |
| 79 | + end |
| 80 | + |
| 81 | + it 'detects function calls without parenthesis that contain paramenters' do |
| 82 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 83 | + func 1 |
| 84 | + EOF |
| 85 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 86 | + func [1] |
| 87 | + EOF |
| 88 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 89 | + func :atom |
| 90 | + EOF |
| 91 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 92 | + func "string" |
| 93 | + EOF |
| 94 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 95 | + func 'a' |
| 96 | + EOF |
| 97 | + end |
| 98 | + |
| 99 | + it 'does not highlight function calls without parenthesis that does not contain paramenters' do |
| 100 | + expect(<<~'EOF').not_to include_elixir_syntax('elixirFunctionCall', 'func') |
| 101 | + func |
| 102 | + EOF |
| 103 | + end |
| 104 | + |
| 105 | + it 'does not detect calls to function with invalid names' do |
| 106 | + expect(<<~'EOF').not_to include_elixir_syntax('elixirFunctionCall', '2fast2func') |
| 107 | + 2fast2func() |
| 108 | + EOF |
| 109 | + end |
| 110 | + |
| 111 | + it 'ignores spacing between module and function names' do |
| 112 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 113 | + Module . func |
| 114 | + EOF |
| 115 | + end |
| 116 | + |
| 117 | + it 'detects piped functions with parenthesis' do |
| 118 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 119 | + one_func() |
| 120 | + |> func() |
| 121 | + EOF |
| 122 | + end |
| 123 | + |
| 124 | + it 'detects piped functions without parenthesis' do |
| 125 | + expect(<<~'EOF').to include_elixir_syntax('elixirFunctionCall', 'func') |
| 126 | + one_func() |
| 127 | + |> func |
| 128 | + EOF |
| 129 | + end |
20 | 130 | end
|
0 commit comments