1
0
Fork 0
mirror of synced 2024-11-18 14:55:34 -05:00
ultimate-vim/sources_non_forked/vim-elixir/spec/syntax/struct_spec.rb

65 lines
2.2 KiB
Ruby
Raw Normal View History

2022-05-18 13:31:41 -04:00
# frozen_string_literal: true
require 'spec_helper'
describe 'Struct syntax' do
it 'without defaults' do
expect(<<~EOF).to include_elixir_syntax('elixirAtom', ':name')
defstruct [:name, :age]
EOF
end
it 'with defaults' do
expect(<<~EOF).to include_elixir_syntax('elixirAtom', 'name:')
defstruct name: "john", age: 27
EOF
end
it 'structs' do
str = %q(%MyStruct{name: "one"})
expect(str).to include_elixir_syntax('elixirStructDelimiter', '%')
expect(str).to include_elixir_syntax('elixirStruct', '%')
expect(str).to include_elixir_syntax('elixirAlias', 'MyStruct')
expect(str).to include_elixir_syntax('elixirStruct', 'MyStruct')
expect(str).to include_elixir_syntax('elixirStructDelimiter', '{')
expect(str).to include_elixir_syntax('elixirStruct', '{')
expect(str).to include_elixir_syntax('elixirAtom', 'name:')
expect(str).to include_elixir_syntax('elixirStruct', 'name:')
expect(str).to include_elixir_syntax('elixirStructDelimiter', '}')
end
it 'properly closes strings in structs' do
str = <<~'EOF'
%MyStruct{url: "http://127.0.0.1:#{port}"} # anchor
# this should not be a string still
EOF
expect(str).to include_elixir_syntax('elixirStruct', '{url')
expect(str).to include_elixir_syntax('elixirStringDelimiter', '"http')
expect(str).to include_elixir_syntax('elixirStruct', '"http')
expect(str).to include_elixir_syntax('elixirInterpolationDelimiter', '#{')
expect(str).to include_elixir_syntax('elixirStruct', '#{')
expect(str).to include_elixir_syntax('elixirInterpolationDelimiter', '}"}')
expect(str).to include_elixir_syntax('elixirStruct', '}"}')
expect(str).not_to include_elixir_syntax('elixirStructDelimiter', '}"}')
expect(str).to include_elixir_syntax('elixirStringDelimiter', '"}')
expect(str).to include_elixir_syntax('elixirStruct', '"}')
expect(str).to include_elixir_syntax('elixirStringDelimiter', '"}')
expect(str).to include_elixir_syntax('elixirStruct', '"}')
expect(str).to include_elixir_syntax('elixirStructDelimiter', '} #')
expect(str).to include_elixir_syntax('elixirComment', '# this should not be a string still')
end
end