Permalink
Browse files

Introduce tests

  • Loading branch information...
1 parent e95b8c8 commit ef12106da91fd9d71d5737a48c141c3f125e77f9 @AndrewRadev AndrewRadev committed May 18, 2012
View
@@ -0,0 +1 @@
+--color
View
@@ -0,0 +1,4 @@
+source 'http://rubygems.org'
+
+gem 'rspec'
+gem 'vimrunner'
View
@@ -0,0 +1,20 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.3)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.2)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.2)
+ vimrunner (0.1.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rspec
+ vimrunner
@@ -1,47 +0,0 @@
-do
- something
-end
-
-def foo
- a_hash = {:do => 'bar'}
-end
-
-def foo(job)
- job.do!
-end
-
-proc do |(a, b)|
- puts a
- puts b
-end
-
-proc do |foo, (a, b), bar|
- puts a
- puts b
-end
-
-proc do |(a, (b, c)), d|
- puts a, b
- puts c, d
-end
-
-define_method "something" do |param|
- if param == 42
- do_something
- else
- do_something_else
- end
-end
-
-def foo
- opts.on('--coordinator host=HOST[,port=PORT]',
- 'Specify the HOST and the PORT of the coordinator') do |str|
- h = sub_opts_to_hash(str)
- puts h
- end
-end
-
-module X
- Class.new do
- end
-end
@@ -1,39 +0,0 @@
-# See https://github.com/vim-ruby/vim-ruby/issues/75 for details
-puts %{#{}}
-puts "OK"
-
-while true
- begin
- puts %{#{x}}
- rescue ArgumentError
- end
-end
-
-variable =
- if condition?
- 1
- else
- 2
- end
-
-variable = # evil comment
- case something
- when 'something'
- something_else
- else
- other
- end
-
-array = [
- :one,
-].each do |x|
- puts x.to_s
-end
-
-x { y >>
- z }
-w
-
-x { y >>
- [z] }
-w
@@ -1,19 +0,0 @@
-module Foo
- class Bar
- f do
- g { def h; end }
- end
-
- if foo
- bar ; end
-
- if bar ; end
-
- foo do
- foo = 3 . class
- foo = lambda { class One; end }
- foo = lambda { |args| class One; end }
- foo = bar; class One; end
- end
- end
-end
@@ -1,53 +0,0 @@
-class Foo
- # nested do ... end blocks:
- var.func1(:param => 'value') do
- var.func2(:param => 'value') do
- puts "test"
- end
- end
-
- # nested { ... } blocks
- var.func1(:param => 'value') {
- var.func2(:param => 'value') {
- foo({ bar => baz })
- puts "test one"
- puts "test two"
- }
- }
-
- # nested hash
- foo, bar = {
- :bar => {
- :one => 'two',
- :five => 'six'
- }
- }
-
- # nested { ... } blocks with a continued first line
- var.
- func1(:param => 'value') {
- var.func2(:param => 'value') {
- puts "test"
- }
- }
-
- # nested hashes with a continued first line
- foo,
- bar = {
- :bar => {
- :foo => { 'bar' => 'baz' },
- :one => 'two',
- :three => 'four'
- }
- }
-
- # TODO nested { ... } blocks with a continued first line and a function call
- # inbetween
- var.
- func1(:param => 'value') {
- func1_5(:param => 'value')
- var.func2(:param => 'value') {
- puts "test"
- }
- }
-end
@@ -1,30 +0,0 @@
-x = Foo[*
- y do
- z
- end
-]
-
-x = Foo[* # with a comment
- y do
- z
- end
-]
-
-x = *
- array.map do
- 3
-end
-
-x = Foo[*
- y {
- z
- }
-]
-
-x = Foo(*y do
- z
-end)
-
-foo(1,
- 2,
- *)
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe "Indenting" do
+ specify "multi-line arguments" do
+ assert_correct_indenting <<-EOF
+ User.new(
+ :first_name => 'Some',
+ :second_name => 'Guy'
+ )
+ EOF
+
+ assert_correct_indenting <<-EOF
+ User.new(:first_name => 'Some',
+ :second_name => 'Guy')
+ EOF
+
+ assert_correct_indenting <<-EOF
+ User.new(
+ :first_name => 'Some',
+ :second_name => 'Guy'
+ )
+ EOF
+ end
+end
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe "Indenting" do
+ specify "if-clauses" do
+ assert_correct_indenting <<-EOF
+ if foo
+ bar
+ end
+ EOF
+
+ assert_correct_indenting <<-EOF
+ if foo
+ bar
+ else
+ baz
+ end
+ EOF
+
+ assert_correct_indenting <<-EOF
+ bar if foo
+ something_else
+ EOF
+ end
+end
@@ -0,0 +1,69 @@
+require 'spec_helper'
+
+describe "Indenting" do
+ specify "'do' indenting" do
+ assert_correct_indenting <<-EOF
+ do
+ something
+ end
+ EOF
+
+ assert_correct_indenting <<-EOF
+ def foo
+ a_hash = {:do => 'bar'}
+ end
+ EOF
+
+ assert_correct_indenting <<-EOF
+ def foo(job)
+ job.do!
+ end
+ EOF
+ end
+
+ specify "blocks with multiline parameters" do
+ assert_correct_indenting <<-EOF
+ def foo
+ opts.on('--coordinator host=HOST[,port=PORT]',
+ 'Specify the HOST and the PORT of the coordinator') do |str|
+ h = sub_opts_to_hash(str)
+ puts h
+ end
+ end
+ EOF
+ end
+
+ specify "case-insensitive matching" do
+ @vim.set 'ignorecase'
+ assert_correct_indenting <<-EOF
+ module X
+ Class.new do
+ end
+ end
+ EOF
+ @vim.set 'ignorecase&'
+ end
+
+ specify "blocks with tuple arguments" do
+ assert_correct_indenting <<-EOF
+ proc do |(a, b)|
+ puts a
+ puts b
+ end
+ EOF
+
+ assert_correct_indenting <<-EOF
+ proc do |foo, (a, b), bar|
+ puts a
+ puts b
+ end
+ EOF
+
+ assert_correct_indenting <<-EOF
+ proc do |(a, (b, c)), d|
+ puts a, b
+ puts c, d
+ end
+ EOF
+ end
+end
Oops, something went wrong.

0 comments on commit ef12106

Please sign in to comment.