Skip to content

Commit cfc79e9

Browse files
committed
Merge pull request #344 from cyberious/TestCaseFixes
Fix testcases for Future Parser and resolve issue with values_at in assuming that it was dealing with a string
2 parents 759cbde + 51f1d57 commit cfc79e9

File tree

12 files changed

+55
-26
lines changed

12 files changed

+55
-26
lines changed

lib/puppet/parser/functions/values_at.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module Puppet::Parser::Functions
4949
indices_list = []
5050

5151
indices.each do |i|
52+
i = i.to_s
5253
if m = i.match(/^(\d+)(\.\.\.?|\-)(\d+)$/)
5354
start = m[1].to_i
5455
stop = m[3].to_i

spec/acceptance/abs_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
pp = <<-EOS
88
$input = '-34.56'
99
$output = abs($input)
10-
notify { $output: }
10+
notify { "$output": }
1111
EOS
1212

1313
apply_manifest(pp, :catch_failures => true) do |r|
@@ -19,7 +19,7 @@
1919
pp = <<-EOS
2020
$input = -34.56
2121
$output = abs($input)
22-
notify { $output: }
22+
notify { "$output": }
2323
EOS
2424

2525
apply_manifest(pp, :catch_failures => true) do |r|

spec/acceptance/any2array_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
EOS
2626

2727
apply_manifest(pp, :catch_failures => true) do |r|
28-
expect(r.stdout).to match(/Notice: Output: testarray/)
28+
expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
2929
end
3030
end
3131

@@ -42,7 +42,7 @@
4242
EOS
4343

4444
apply_manifest(pp, :catch_failures => true) do |r|
45-
expect(r.stdout).to match(/Notice: Output: testarray/)
45+
expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
4646
end
4747
end
4848
end

spec/acceptance/bool2num_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
55
describe 'success' do
66
['false', 'f', '0', 'n', 'no'].each do |bool|
7-
it 'should convert a given boolean, #{bool}, to 0' do
7+
it "should convert a given boolean, #{bool}, to 0" do
88
pp = <<-EOS
9-
$input = #{bool}
9+
$input = "#{bool}"
1010
$output = bool2num($input)
11-
notify { $output: }
11+
notify { "$output": }
1212
EOS
1313

1414
apply_manifest(pp, :catch_failures => true) do |r|
@@ -18,11 +18,11 @@
1818
end
1919

2020
['true', 't', '1', 'y', 'yes'].each do |bool|
21-
it 'should convert a given boolean, #{bool}, to 1' do
21+
it "should convert a given boolean, #{bool}, to 1" do
2222
pp = <<-EOS
23-
$input = #{bool}
23+
$input = "#{bool}"
2424
$output = bool2num($input)
25-
notify { $output: }
25+
notify { "$output": }
2626
EOS
2727

2828
apply_manifest(pp, :catch_failures => true) do |r|

spec/acceptance/count_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
pp = <<-EOS
88
$input = [1,2,3,4]
99
$output = count($input)
10-
notify { $output: }
10+
notify { "$output": }
1111
EOS
1212

1313
apply_manifest(pp, :catch_failures => true) do |r|
@@ -19,7 +19,7 @@
1919
pp = <<-EOS
2020
$input = [1,1,1,2]
2121
$output = count($input, 1)
22-
notify { $output: }
22+
notify { "$output": }
2323
EOS
2424

2525
apply_manifest(pp, :catch_failures => true) do |r|

spec/acceptance/ensure_packages_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper_acceptance'
33

4-
describe 'ensure_packages function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4+
describe 'ensure_packages function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || fact('operatingsystem') != 'windows') do
55
describe 'success' do
66
it 'ensure_packages a package' do
77
apply_manifest('package { "rake": ensure => absent, provider => "gem", }')

spec/acceptance/merge_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
EOS
1515

1616
apply_manifest(pp, :catch_failures => true) do |r|
17-
expect(r.stdout).to match(/merge\[one\] is "1"/)
17+
expect(r.stdout).to match(/merge\[one\] is ("1"|1)/)
1818
expect(r.stdout).to match(/merge\[two\] is "dos"/)
19-
expect(r.stdout).to match(/merge\[three\] is {"five"=>"5"}/)
19+
expect(r.stdout).to match(/merge\[three\] is {"five"=>("5"|5)}/)
2020
end
2121
end
2222
end

spec/acceptance/type_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper_acceptance'
33

4-
describe 'type function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4+
describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || !(is_future_parser_enabled?)) do
55
describe 'success' do
66
it 'types arrays' do
77
pp = <<-EOS

spec/acceptance/validate_cmd_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
} else {
3838
$two = '/bin/aoeu'
3939
}
40-
validate_cmd($one,$two,"aoeu is dvorak)
40+
validate_cmd($one,$two,"aoeu is dvorak")
4141
EOS
4242

4343
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/aoeu is dvorak/)

spec/acceptance/values_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
$output = values($arg)
1414
notice(inline_template('<%= @output.sort.inspect %>'))
1515
EOS
16+
if is_future_parser_enabled?
17+
expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
18+
else
19+
expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
20+
end
1621

17-
expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
1822
end
1923
end
2024
describe 'failure' do

0 commit comments

Comments
 (0)