Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / zip_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'zip function' do
4   describe 'success' do
5     pp1 = <<-DOC
6       $one = [1,2,3,4]
7       $two = [5,6,7,8]
8       $output = zip($one,$two)
9       notice(inline_template('<%= @output.inspect %>'))
10     DOC
11     it 'zips two arrays of numbers together' do
12       expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]})
13     end
14
15     pp2 = <<-DOC
16       $one = [1,2,"three",4]
17       $two = [true,true,false,false]
18       $output = zip($one,$two)
19       notice(inline_template('<%= @output.inspect %>'))
20     DOC
21     it 'zips two arrays of numbers & bools together' do
22       expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]})
23     end
24
25     # XXX This only tests the argument `true`, even though the following are valid:
26     # 1 t y true yes
27     # 0 f n false no
28     # undef undefined
29     pp3 = <<-DOC
30       $one = [1,2,3,4]
31       $two = [5,6,7,8]
32       $output = zip($one,$two,true)
33       notice(inline_template('<%= @output.inspect %>'))
34     DOC
35     it 'zips two arrays of numbers together and flattens them' do
36       expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\[1, 5, 2, 6, 3, 7, 4, 8\]})
37     end
38
39     # XXX Is this expected behavior?
40     pp4 = <<-DOC
41       $one = [1,2]
42       $two = [5,6,7,8]
43       $output = zip($one,$two)
44       notice(inline_template('<%= @output.inspect %>'))
45     DOC
46     it 'handles unmatched length' do
47       expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\]\]})
48     end
49   end
50
51   describe 'failure' do
52     pp5 = <<-DOC
53       $one = [1,2]
54       $output = zip($one)
55       notice(inline_template('<%= @output.inspect %>'))
56     DOC
57     it 'handles improper number of arguments' do
58       expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
59     end
60
61     pp6 = <<-DOC
62       $one = "a string"
63       $two = [5,6,7,8]
64       $output = zip($one,$two)
65       notice(inline_template('<%= @output.inspect %>'))
66     DOC
67     it 'handles improper argument types' do
68       expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{Requires array})
69     end
70   end
71 end