test/extra/test_autoindent.rb in rib-1.5.4 vs test/extra/test_autoindent.rb in rib-1.6.0

- old
+ new

@@ -37,11 +37,11 @@ @indent.eval_input(input) expect(@indent.stack_size).eq size end - would 'begin rescue else end' do + would 'begin rescue else ensure end' do ri('begin' , 1) ri( '1' , 1) le('rescue' , 1) ri( '1' , 1) le('rescue=>e' , 1) @@ -51,13 +51,37 @@ le('rescue E' , 1) le('rescue E => e ', 1) le('rescue E=> e' , 1) le('rescue E =>e ' , 1) le('else' , 1) + ri( '1' , 1) + le('ensure' , 1) + ri( '1' , 1) le('end while nil' , 0) end + would 'def rescue else ensure end' do + ri('def f a' , 1) + ri( 'if a' , 2) + le( 'end' , 1) + le('rescue' , 1) + ri( '1' , 1) + le('rescue=>e' , 1) + le('rescue => e' , 1) + le('rescue =>e' , 1) + le('rescue E=>e ' , 1) + le('rescue E' , 1) + le('rescue E => e ', 1) + le('rescue E=> e' , 1) + le('rescue E =>e ' , 1) + le('else' , 1) + ri( '1' , 1) + le('ensure' , 1) + ri( '1' , 1) + le('end while nil' , 0) + end + would 'if elsif else end' do ri('if true' , 1) ri( 'if false' , 2) ri( '1' , 2) le( 'end' , 1) @@ -94,17 +118,10 @@ le('else' , 1) ri( '1' , 1) le('end' , 0) end - would 'def end' do - ri('def f a' , 1) - ri( 'if a' , 2) - le( 'end' , 1) - le('end' , 0) - end - would 'class Object end' do ri('class Object' , 1) ri( 'if true' , 2) le( 'end' , 1) le('end' , 0) @@ -123,10 +140,17 @@ ri( 'if true' , 2) le( 'end' , 1) le('end' , 0) end + would 'for end' do + ri('for x in 1..2' , 1) + ri( 'if true' , 2) + le( 'end' , 1) + le('end' , 0) + end + would 'until end' do ri('until true' , 1) ri( 'if true' , 2) le( 'end' , 1) le('end' , 0) @@ -139,7 +163,44 @@ ri( 'to_s "" do' , 2) le( 'end' , 1) ri( 'to_s // do' , 2) le( 'end' , 1) le('end' , 0) + end + + would '{}' do + ri('{' , 1) + ri( ':a => :b' , 1) + le('}' , 0) + end + + would '[].each{}' do + ri('[].each{' , 1) + ri( '0' , 1) + ri( '[].each {' , 2) + le( '}' , 1) + le('}' , 0) + end + + would '()' do + ri('(' , 1) + ri( '0' , 1) + le(')' , 0) + end + + would '{}.dig()' do + ri('{}.dig(' , 1) + ri( '0,' , 1) + ri( '1' , 1) + le(')' , 0) + end + + would '[]' do + ri('[' , 1) + ri( '0,' , 1) + ri( '1,' , 1) + ri( '[' , 2) + ri( '2' , 2) + le( ']' , 1) + le(']' , 0) end end