7171 @doc """
7272 doctest
7373
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]
7878
7979 """
8080 EOF
8484 expect ( ex ) . to include_elixir_syntax ( 'elixirDocTest' , '2, 4, 6' )
8585 end
8686
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
9192
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
100147 end
101148
102149 it 'doc with inline code' do
@@ -111,14 +158,15 @@ def some_fun(x), do: x
111158
112159 describe "use markdown for docs" do
113160 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" ) }
114162
115163 it 'doc with inline code' do
116164 ex = <<~'EOF'
117165 @doc """
118- doctest with inline code `List.wrap([])`
166+ doc with inline code `List.wrap([])`
119167 """
120168 EOF
121- expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'doctest ' )
169+ expect ( ex ) . to include_elixir_syntax ( 'elixirDocString' , 'inline ' )
122170 expect ( ex ) . to include_elixir_syntax ( 'markdownCode' , 'wrap' )
123171 end
124172 end
0 commit comments