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
47
47
48
48
type = '..' # Use the simplest type of Range available in Ruby
49
49
50
- else # arguments.size == 0
50
+ else # arguments.size == 1
51
51
value = arguments [ 0 ]
52
52
53
53
if m = value . match ( /^(\w +)(\. \. \. ?|\- )(\w +)$/ )
54
54
start = m [ 1 ]
55
55
stop = m [ 3 ]
56
56
57
57
type = m [ 2 ]
58
-
58
+ step = 1
59
59
elsif value . match ( /^.+$/ )
60
60
raise ( Puppet ::ParseError , "range(): Unable to compute range " +
61
61
"from the value: #{ value } " )
@@ -78,7 +78,7 @@ module Puppet::Parser::Functions
78
78
when '...' then ( start ... stop ) # Exclusive of last element
79
79
end
80
80
81
- result = range . step ( step ) . collect { | i | i }
81
+ result = range . step ( step ) . to_a
82
82
83
83
return result
84
84
end
Original file line number Diff line number Diff line change 68
68
end
69
69
end
70
70
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
+
71
78
describe 'with a numeric range' do
72
79
it "returns a range of numbers" do
73
80
expected = ( 1 ..10 ) . to_a
You can’t perform that action at this time.
0 commit comments