File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
lib/puppet/parser/functions Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,15 @@ module Puppet::Parser::Functions
4747
4848 type = '..' # Use the simplest type of Range available in Ruby
4949
50- else # arguments.size == 0
50+ else # arguments.size == 1
5151 value = arguments [ 0 ]
5252
5353 if m = value . match ( /^(\w +)(\. \. \. ?|\- )(\w +)$/ )
5454 start = m [ 1 ]
5555 stop = m [ 3 ]
5656
5757 type = m [ 2 ]
58-
58+ step = 1
5959 elsif value . match ( /^.+$/ )
6060 raise ( Puppet ::ParseError , "range(): Unable to compute range " +
6161 "from the value: #{ value } " )
@@ -78,7 +78,7 @@ module Puppet::Parser::Functions
7878 when '...' then ( start ... stop ) # Exclusive of last element
7979 end
8080
81- result = range . step ( step ) . collect { | i | i }
81+ result = range . step ( step ) . to_a
8282
8383 return result
8484 end
Original file line number Diff line number Diff line change 6868 end
6969 end
7070
71+ describe 'with a ruby-like range' do
72+ it "returns a number range" do
73+ result = scope . function_range ( [ "1..4" ] )
74+ expect ( result ) . to eq [ 1 , 2 , 3 , 4 ]
75+ end
76+ end
77+
7178 describe 'with a numeric range' do
7279 it "returns a range of numbers" do
7380 expected = ( 1 ..10 ) . to_a
You can’t perform that action at this time.
0 commit comments