-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for variables in python for-loops
- Loading branch information
1 parent
f66a98c
commit 6babbee
Showing
5 changed files
with
171 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
require 'spec_helper' | ||
|
||
describe "python" do | ||
let(:filename) { 'test.py' } | ||
|
||
describe "functions" do | ||
before :each do | ||
set_file_contents <<-EOF | ||
def function(one, two, three): | ||
pass | ||
EOF | ||
|
||
vim.search('one') | ||
end | ||
|
||
specify "to the left" do | ||
vim.left | ||
assert_file_contents <<-EOF | ||
def function(three, two, one): | ||
pass | ||
EOF | ||
|
||
vim.left | ||
assert_file_contents <<-EOF | ||
def function(three, one, two): | ||
pass | ||
EOF | ||
|
||
vim.left | ||
assert_file_contents <<-EOF | ||
def function(one, three, two): | ||
pass | ||
EOF | ||
end | ||
|
||
specify "to the right" do | ||
vim.right | ||
assert_file_contents <<-EOF | ||
def function(two, one, three): | ||
pass | ||
EOF | ||
|
||
vim.right | ||
assert_file_contents <<-EOF | ||
def function(two, three, one): | ||
pass | ||
EOF | ||
|
||
vim.right | ||
assert_file_contents <<-EOF | ||
def function(one, three, two): | ||
pass | ||
EOF | ||
end | ||
|
||
specify "incomplete function call" do | ||
set_file_contents <<-EOF | ||
def function(one, two, three | ||
pass | ||
EOF | ||
|
||
vim.search('one') | ||
vim.right | ||
assert_file_contents <<-EOF | ||
def function(two, one, three | ||
pass | ||
EOF | ||
end | ||
|
||
specify "extra whitespace" do | ||
set_file_contents <<-EOF | ||
def function( one, two, three ): | ||
pass | ||
EOF | ||
|
||
vim.search('one') | ||
vim.right | ||
assert_file_contents <<-EOF | ||
def function( two, one, three ): | ||
pass | ||
EOF | ||
end | ||
|
||
specify "complicated function call" do | ||
set_file_contents <<-EOF | ||
foo(bar, baz(foobar(), foobaz)) | ||
EOF | ||
|
||
vim.search('bar') | ||
vim.right | ||
|
||
assert_file_contents <<-EOF | ||
foo(baz(foobar(), foobaz), bar) | ||
EOF | ||
end | ||
end | ||
|
||
describe "imports" do | ||
specify "basic import" do | ||
set_file_contents <<-EOF | ||
import foo, bar as b, baz | ||
EOF | ||
|
||
vim.search('foo') | ||
|
||
vim.left | ||
assert_file_contents <<-EOF | ||
import baz, bar as b, foo | ||
EOF | ||
|
||
vim.right | ||
assert_file_contents <<-EOF | ||
import foo, bar as b, baz | ||
EOF | ||
end | ||
|
||
specify "import with from" do | ||
set_file_contents <<-EOF | ||
from some_package import Foo, Bar | ||
EOF | ||
|
||
vim.search('Foo') | ||
|
||
vim.left | ||
assert_file_contents <<-EOF | ||
from some_package import Bar, Foo | ||
EOF | ||
|
||
vim.right | ||
assert_file_contents <<-EOF | ||
from some_package import Foo, Bar | ||
EOF | ||
end | ||
end | ||
|
||
describe "for loops" do | ||
specify "basic for loop" do | ||
set_file_contents <<-EOF | ||
for index, value in enumerate(items): | ||
pass | ||
EOF | ||
|
||
vim.search('index') | ||
|
||
vim.left | ||
assert_file_contents <<-EOF | ||
for value, index in enumerate(items): | ||
pass | ||
EOF | ||
|
||
vim.right | ||
assert_file_contents <<-EOF | ||
for index, value in enumerate(items): | ||
pass | ||
EOF | ||
end | ||
end | ||
end |