Skip to content

Commit

Permalink
adjusted eval/printf calls in .value()
Browse files Browse the repository at this point in the history
  • Loading branch information
dahu committed Apr 5, 2013
1 parent 544aa45 commit 532ab0c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.asciidoc
Expand Up @@ -103,6 +103,7 @@ The Series constructor has the following signatures:
* +Series(7, 2)+ -> 7, 9, 11, ...
* +Series(2, 7)+ -> 2, 9, 16, ...
* +Series('nexus#alpha')+ -> 'a', 'b', 'c', ...
* +Series('(%d) ')+ -> (0)

Nexus's Series Objects provide the following methods:

Expand Down
4 changes: 2 additions & 2 deletions plugin/nexus.vim
Expand Up @@ -139,8 +139,8 @@ function! Series(...)
let index = a:0 ? a:1 : (self.index - 1)
let value = (index <= 0 ? self.values[0] : self.values[index])
return self.use_printf
\ ? eval(printf(self.format, "'" . value . "'"))
\ : eval(substitute(self.format, '\C\<x:nexus\>', 'value', 'g'))
\ ? printf(self.format, eval('"' . escape(value, '"') . '"'))
\ : eval('"' . escape(substitute(self.format, '\C\<x:nexus\>', value, 'g'), '"') . '"')
endfunc

call call(incrementor.init, a:000, incrementor)
Expand Down
33 changes: 33 additions & 0 deletions test/003_linear_format.vim
@@ -0,0 +1,33 @@
call vimtest#StartTap()
call vimtap#Plan(20) " <== XXX Keep plan number updated. XXX

let s1_1 = Series('%d,')
let s1_2 = Series('"%d,"')
let s2_1 = Series('x:nexus,')
let s2_2 = Series('"x:nexus,"')

call vimtap#Is(s1_1.value(), '0,', '.value() == initial_value')
call vimtap#Is(s1_1.next(), '0,', '.next() steps correctly')
call vimtap#Is(s1_1.next(), '1,', '.next() steps correctly')
call vimtap#Is(s1_1.next(), '2,', '.next() steps correctly')
call vimtap#Is(s1_1.next(), '3,', '.next() steps correctly')

call vimtap#Is(s1_2.value(), '"0,"', '.value() == initial_value')
call vimtap#Is(s1_2.next(), '"0,"', '.next() steps correctly')
call vimtap#Is(s1_2.next(), '"1,"', '.next() steps correctly')
call vimtap#Is(s1_2.next(), '"2,"', '.next() steps correctly')
call vimtap#Is(s1_2.next(), '"3,"', '.next() steps correctly')

call vimtap#Is(s2_1.value(), '0,', '.value() == initial_value')
call vimtap#Is(s2_1.next(), '0,', '.next() steps correctly')
call vimtap#Is(s2_1.next(), '1,', '.next() steps correctly')
call vimtap#Is(s2_1.next(), '2,', '.next() steps correctly')
call vimtap#Is(s2_1.next(), '3,', '.next() steps correctly')

call vimtap#Is(s2_2.value(), '"0,"', '.value() == initial_value')
call vimtap#Is(s2_2.next(), '"0,"', '.next() steps correctly')
call vimtap#Is(s2_2.next(), '"1,"', '.next() steps correctly')
call vimtap#Is(s2_2.next(), '"2,"', '.next() steps correctly')
call vimtap#Is(s2_2.next(), '"3,"', '.next() steps correctly')

call vimtest#Quit()

0 comments on commit 532ab0c

Please sign in to comment.