1 require 'spec_helper_acceptance'
3 describe 'zip function' do
8 $output = zip($one,$two)
9 notice(inline_template('<%= @output.inspect %>'))
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\]\]})
16 $one = [1,2,"three",4]
17 $two = [true,true,false,false]
18 $output = zip($one,$two)
19 notice(inline_template('<%= @output.inspect %>'))
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\]\]})
25 # XXX This only tests the argument `true`, even though the following are valid:
32 $output = zip($one,$two,true)
33 notice(inline_template('<%= @output.inspect %>'))
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\]})
39 # XXX Is this expected behavior?
43 $output = zip($one,$two)
44 notice(inline_template('<%= @output.inspect %>'))
46 it 'handles unmatched length' do
47 expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\]\]})
55 notice(inline_template('<%= @output.inspect %>'))
57 it 'handles improper number of arguments' do
58 expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
64 $output = zip($one,$two)
65 notice(inline_template('<%= @output.inspect %>'))
67 it 'handles improper argument types' do
68 expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{Requires array})