71
71
@doc """
72
72
doctest
73
73
74
- iex> Enum.map [1, 2, 3], fn(x) ->
75
- ...> x * 2
76
- ...> end
77
- [2, 4, 6]
74
+ iex> Enum.map [1, 2, 3], fn(x) ->
75
+ ...> x * 2
76
+ ...> end
77
+ [2, 4, 6]
78
78
79
79
"""
80
80
EOF
84
84
expect ( ex ) . to include_elixir_syntax ( 'elixirDocTest' , '2, 4, 6' )
85
85
end
86
86
87
- it 'doctest finishes when not followed by blank line' do
88
- ex = <<~'EOF'
89
- @doc """
90
- doctest
87
+ describe 'doctest without newline after' do
88
+ it 'with heredoc' do
89
+ ex = <<~'EOF'
90
+ @doc """
91
+ doctest
91
92
92
- iex> 1 + 2
93
- 3
94
- """
95
- def some_fun(x), do: x
96
- EOF
97
- expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'doctest' )
98
- expect ( ex ) . to include_elixir_syntax ( 'elixirDocTest' , '1 + 2' )
99
- expect ( ex ) . to include_elixir_syntax ( 'elixirDefine' , 'def' )
93
+ iex> 1 + 2
94
+ 3
95
+ """
96
+ def some_fun(x), do: x
97
+ EOF
98
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'doctest' )
99
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocTest' , '1 + 2' )
100
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDefine' , 'def' )
101
+ end
102
+
103
+ it 'with double quote' do
104
+ ex = <<~'EOF'
105
+ @doc "
106
+ doctest
107
+
108
+ iex> \"bob\"
109
+ \"bob\"
110
+ "
111
+ def some_fun(x), do: x
112
+ EOF
113
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'doctest' )
114
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocTest' , 'bob' )
115
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDefine' , 'def' )
116
+ end
117
+
118
+ it 'with sigil_S' do
119
+ ex = <<~'EOF'
120
+ @doc ~S(
121
+ doctest
122
+
123
+ iex> to_string("bob"\)
124
+ "bob"
125
+ )
126
+ def some_fun(x), do: x
127
+ EOF
128
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'doctest' )
129
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocTest' , 'bob' )
130
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDefine' , 'def' )
131
+ end
132
+
133
+ it 'with sigil_s' do
134
+ ex = <<~'EOF'
135
+ @doc ~s(
136
+ doctest
137
+
138
+ iex> to_string("bob"\)
139
+ "bob"
140
+ )
141
+ def some_fun(x), do: x
142
+ EOF
143
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'doctest' )
144
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocTest' , 'bob' )
145
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDefine' , 'def' )
146
+ end
100
147
end
101
148
102
149
it 'doc with inline code' do
@@ -111,14 +158,15 @@ def some_fun(x), do: x
111
158
112
159
describe "use markdown for docs" do
113
160
before ( :each ) { VIM . command ( "let g:elixir_use_markdown_for_docs = 1" ) }
161
+ after ( :each ) { VIM . command ( "let g:elixir_use_markdown_for_docs = 0" ) }
114
162
115
163
it 'doc with inline code' do
116
164
ex = <<~'EOF'
117
165
@doc """
118
- doctest with inline code `List.wrap([])`
166
+ doc with inline code `List.wrap([])`
119
167
"""
120
168
EOF
121
- expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'doctest ' )
169
+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'inline ' )
122
170
expect ( ex ) . to include_elixir_syntax ( 'markdownCode' , 'wrap' )
123
171
end
124
172
end
0 commit comments