+describe "vim when using python_pep8_indent_multiline_first=0" do
+ before {
+ vim.command("set sw=4 ts=4 sts=4 et")
+ vim.command("let g:python_pep8_indent_multiline_string=0")
+ }
+ it_behaves_like "multiline strings"
+end
+
+describe "vim when using python_pep8_indent_multiline_string=-1" do
+ before {
+ vim.command("set sw=4 ts=4 sts=4 et")
+ vim.command("let g:python_pep8_indent_multiline_string=-1")
+ }
+ it_behaves_like "multiline strings"
+end
+
+describe "vim when using python_pep8_indent_multiline_string=-2" do
+ before {
+ vim.command("set sw=4 ts=4 sts=4 et")
+ vim.command("let g:python_pep8_indent_multiline_string=-2")
+ }
+ it_behaves_like "multiline strings"
+end
+
+describe "vim for cython" do
+ before {
+ vim.command "enew"
+ vim.command "set ft=cython"
+ vim.command "runtime indent/python.vim"
+
+ # Insert two blank lines.
+ # The first line is a corner case in this plugin that would shadow the
+ # correct behaviour of other tests. Thus we explicitly jump to the first
+ # line when we require so.
+ vim.feedkeys 'i\<CR>\<CR>\<ESC>'
+ }
+
+ describe "when using a cdef function definition" do
+ it "indents shiftwidth spaces" do
+ vim.feedkeys 'icdef long_function_name(\<CR>arg'
+ indent.should == shiftwidth * 2
+ end
+ end
+
+ describe "when using a cpdef function definition" do
+ it "indents shiftwidth spaces" do
+ vim.feedkeys 'icpdef long_function_name(\<CR>arg'
+ indent.should == shiftwidth * 2
+ end
+ end
+end
+
+describe "Handles far away opening parens" do
+ before { vim.feedkeys '\<ESC>ggdGifrom foo import (' }
+
+ it "indents by one level" do
+ vim.feedkeys '\<CR>'
+ proposed_indent.should == shiftwidth
+ end
+
+ it "indents by one level for 10 lines" do
+ vim.command('set paste | exe "norm 9o" | set nopaste')
+ vim.feedkeys '\<Esc>o'
+ indent.should == shiftwidth
+ end
+
+ it "indents by one level for 50 lines" do
+ vim.command('set paste | exe "norm 49o" | set nopaste')
+ vim.feedkeys '\<Esc>o'
+ indent.should == shiftwidth
+ end
+end
+
+describe "Handles far away opening square brackets" do
+ before { vim.feedkeys '\<ESC>ggdGibar = [' }
+
+ it "indents by one level" do
+ vim.feedkeys '\<CR>'
+ proposed_indent.should == shiftwidth
+ end
+
+ it "indents by one level for 10 lines" do
+ vim.command('set paste | exe "norm 9o" | set nopaste')
+ vim.feedkeys '\<Esc>o'
+ indent.should == shiftwidth
+ end
+
+ it "indents by one level for 100 lines" do
+ vim.command('set paste | exe "norm 99o" | set nopaste')
+ vim.feedkeys '\<Esc>o'
+ indent.should == shiftwidth
+ end
+end
+
+describe "Handles far away opening curly brackets" do
+ before { vim.feedkeys '\<ESC>ggdGijson = {' }
+
+ it "indents by one level" do
+ vim.feedkeys '\<CR>'
+ vim.feedkeys '\<Esc>o'
+ proposed_indent.should == shiftwidth
+ end
+
+ it "indents by one level for 10 lines" do
+ vim.command('set paste | exe "norm 9o" | set nopaste')
+ vim.feedkeys '\<Esc>o'
+ indent.should == shiftwidth
+ end
+
+ it "indents by one level for 1000 lines" do
+ vim.command('set paste | exe "norm 999o" | set nopaste')
+ vim.feedkeys '\<Esc>o'
+ indent.should == shiftwidth
+ end
+end
+
+describe "Compact multiline dict" do
+ before { vim.feedkeys '\<ESC>ggdGid = {"one": 1,' }
+
+ it "gets indented correctly" do
+ vim.feedkeys '\<CR>'
+ proposed_indent.should == 5
+
+ vim.feedkeys '"two": 2}'
+ proposed_indent.should == 5
+
+ vim.feedkeys '\<CR>'
+ proposed_indent.should == 0
+ end