Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/abs_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/abs_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/abs_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,30 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should accept a string' do
+      pp = <<-EOS
+      $input  = '-34.56'
+      $output = abs($input)
+      notify { "$output": }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: 34.56/)
+      end
+    end
+
+    it 'should accept a float' do
+      pp = <<-EOS
+      $input  = -34.56
+      $output = abs($input)
+      notify { "$output": }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: 34.56/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/anchor_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/anchor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/anchor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+require 'spec_helper_acceptance'
+
+describe 'anchor type', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should effect proper chaining of resources' do
+      pp = <<-EOS
+      class anchored {
+        anchor { 'anchored::begin': }
+        ~> anchor { 'anchored::end': }
+      }
+
+      class anchorrefresh {
+        notify { 'first': }
+        ~> class { 'anchored': }
+        ~> anchor { 'final': }
+      }
+
+      include anchorrefresh
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Anchor\[final\]: Triggered 'refresh'/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/any2array_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/any2array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/any2array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,49 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should create an empty array' do
+      pp = <<-EOS
+      $input = ''
+      $output = any2array($input)
+      validate_array($output)
+      notify { "Output: ${output}": }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: Output: /)
+      end
+    end
+
+    it 'should leave arrays modified' do
+      pp = <<-EOS
+      $input = ['test', 'array']
+      $output = any2array($input)
+      validate_array($output)
+      notify { "Output: ${output}": }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
+      end
+    end
+
+    it 'should turn a hash into an array' do
+      pp = <<-EOS
+      $input = {'test' => 'array'}
+      $output = any2array($input)
+
+      validate_array($output)
+      # Check each element of the array is a plain string.
+      validate_string($output[0])
+      validate_string($output[1])
+      notify { "Output: ${output}": }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/base64_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/base64_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/base64_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,18 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should encode then decode a string' do
+      pp = <<-EOS
+      $encodestring = base64('encode', 'thestring')
+      $decodestring = base64('decode', $encodestring)
+      notify { $decodestring: }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/thestring/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/bool2num_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/bool2num_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/bool2num_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    ['false', 'f', '0', 'n', 'no'].each do |bool|
+      it "should convert a given boolean, #{bool}, to 0" do
+        pp = <<-EOS
+        $input = "#{bool}"
+        $output = bool2num($input)
+        notify { "$output": }
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/Notice: 0/)
+        end
+      end
+    end
+
+    ['true', 't', '1', 'y', 'yes'].each do |bool|
+      it "should convert a given boolean, #{bool}, to 1" do
+        pp = <<-EOS
+        $input = "#{bool}"
+        $output = bool2num($input)
+        notify { "$output": }
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/Notice: 1/)
+        end
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/build_csv.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/build_csv.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/build_csv.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,83 @@
+#!/usr/bin/env ruby
+# vim: set sw=2 sts=2 et tw=80 :
+require 'rspec'
+
+#XXX Super ugly hack to keep from starting beaker nodes
+module Kernel
+  # make an alias of the original require
+  alias_method :original_require, :require
+  # rewrite require
+  def require name
+    original_require name if name != 'spec_helper_acceptance'
+  end
+end
+UNSUPPORTED_PLATFORMS = []
+def fact(*args) [] end
+#XXX End hax
+
+# Get a list of functions for test coverage
+function_list = Dir[File.join(File.dirname(__FILE__),"..","..","lib","puppet","parser","functions","*.rb")].collect do |function_rb|
+  File.basename(function_rb,".rb")
+end
+
+## Configure rspec to parse tests
+options = RSpec::Core::ConfigurationOptions.new(['spec/acceptance'])
+configuration = RSpec::configuration
+world = RSpec::world
+options.parse_options
+options.configure(configuration)
+configuration.load_spec_files
+
+## Collect up tests and example groups into a hash
+def get_tests(children)
+  children.inject({}) do |memo,c|
+    memo[c.description] = Hash.new
+    memo[c.description]["groups"] = get_tests(c.children) unless c.children.empty?
+    memo[c.description]["tests"] = c.examples.collect { |e|
+      e.description unless e.pending?
+    }.compact unless c.examples.empty?
+    memo[c.description]["pending_tests"] = c.examples.collect { |e|
+      e.description if e.pending?
+    }.compact unless c.examples.empty?
+    memo
+  end
+end
+
+def count_test_types_in(type,group)
+  return 0 if group.nil?
+  group.inject(0) do |m,(k,v)|
+    m += v.length if k == type
+    m += count_tests_in(v) if v.is_a?(Hash)
+    m
+  end
+end
+def count_tests_in(group)
+  count_test_types_in('tests',group)
+end
+def count_pending_tests_in(group)
+  count_test_types_in('pending_tests',group)
+end
+
+# Convert tests hash to csv format
+def to_csv(function_list,tests)
+  function_list.collect do |function_name|
+    if v = tests["#{function_name} function"]
+      positive_tests = count_tests_in(v["groups"]["success"])
+      negative_tests = count_tests_in(v["groups"]["failure"])
+      pending_tests  =
+        count_pending_tests_in(v["groups"]["failure"]) +
+        count_pending_tests_in(v["groups"]["failure"])
+    else
+      positive_tests = 0
+      negative_tests = 0
+      pending_tests  = 0
+    end
+    sprintf("%-25s, %-9d, %-9d, %-9d", function_name,positive_tests,negative_tests,pending_tests)
+  end.compact
+end
+
+tests = get_tests(world.example_groups)
+csv = to_csv(function_list,tests)
+percentage_tested = "#{tests.count*100/function_list.count}%"
+printf("%-25s,  %-9s, %-9s, %-9s\n","#{percentage_tested} have tests.","Positive","Negative","Pending")
+puts csv
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/capitalize_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/capitalize_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/capitalize_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,33 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should capitalize the first letter of a string' do
+      pp = <<-EOS
+      $input = 'this is a string'
+      $output = capitalize($input)
+      notify { $output: }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: This is a string/)
+      end
+    end
+
+    it 'should capitalize the first letter of an array of strings' do
+      pp = <<-EOS
+      $input = ['this', 'is', 'a', 'string']
+      $output = capitalize($input)
+      notify { $output: }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: This/)
+        expect(r.stdout).to match(/Notice: Is/)
+        expect(r.stdout).to match(/Notice: A/)
+        expect(r.stdout).to match(/Notice: String/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/ceiling_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/ceiling_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/ceiling_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,39 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'ceiling function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'ceilings floats' do
+      pp = <<-EOS
+      $a = 12.8
+      $b = 13
+      $o = ceiling($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'ceilings integers' do
+      pp = <<-EOS
+      $a = 7
+      $b = 7
+      $o = ceiling($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-numbers'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/chomp_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/chomp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/chomp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should eat the newline' do
+      pp = <<-EOS
+      $input = "test\n"
+      if size($input) != 5 {
+        fail("Size of ${input} is not 5.")
+      }
+      $output = chomp($input)
+      if size($output) != 4 {
+        fail("Size of ${input} is not 4.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/chop_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/chop_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/chop_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,45 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should eat the last character' do
+      pp = <<-EOS
+      $input = "test"
+      if size($input) != 4 {
+        fail("Size of ${input} is not 4.")
+      }
+      $output = chop($input)
+      if size($output) != 3 {
+        fail("Size of ${input} is not 3.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    it 'should eat the last two characters of \r\n' do
+      pp = <<-'EOS'
+      $input = "test\r\n"
+      if size($input) != 6 {
+        fail("Size of ${input} is not 6.")
+      }
+      $output = chop($input)
+      if size($output) != 4 {
+        fail("Size of ${input} is not 4.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    it 'should not fail on empty strings' do
+      pp = <<-EOS
+      $input = ""
+      $output = chop($input)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/clamp_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/clamp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/clamp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,40 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'clamp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'clamps list of values' do
+      pp = <<-EOS
+      $x = 17
+      $y = 225
+      $z = 155
+      $o = clamp($x, $y, $z)
+      if $o == $z {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'clamps array of values' do
+      pp = <<-EOS
+      $a = [7, 19, 66]
+      $b = 19
+      $o = clamp($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/concat_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/concat_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/concat_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,54 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should concat one array to another' do
+      pp = <<-EOS
+      $output = concat(['1','2','3'],['4','5','6'])
+      validate_array($output)
+      if size($output) != 6 {
+        fail("${output} should have 6 elements.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'should concat arrays and primitives to array' do
+      pp = <<-EOS
+      $output = concat(['1','2','3'],'4','5','6',['7','8','9'])
+      validate_array($output)
+      if size($output) != 9 {
+        fail("${output} should have 9 elements.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'should concat multiple arrays to one' do
+      pp = <<-EOS
+      $output = concat(['1','2','3'],['4','5','6'],['7','8','9'])
+      validate_array($output)
+      if size($output) != 9 {
+        fail("${output} should have 9 elements.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'should concat hash arguments' do
+      pp = <<-EOS
+      $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
+      validate_array($output)
+      if size($output) != 2 {
+        fail("${output} should have 2 elements.")
+      }
+      if $output[1] != {"c" => "d", "e" => "f"} {
+        fail("${output} does not have the expected hash for the second element.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/count_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/count_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/count_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,30 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should count elements in an array' do
+      pp = <<-EOS
+      $input = [1,2,3,4]
+      $output = count($input)
+      notify { "$output": }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: 4/)
+      end
+    end
+
+    it 'should count elements in an array that match a second argument' do
+      pp = <<-EOS
+      $input = [1,1,1,2]
+      $output = count($input, 1)
+      notify { "$output": }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: 3/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/deep_merge_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/deep_merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/deep_merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,20 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should deep merge two hashes' do
+      pp = <<-EOS
+      $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
+      $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
+      $merged_hash = deep_merge($hash1, $hash2)
+
+      if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } {
+        fail("Hash was incorrectly merged.")
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/defined_with_params_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/defined_with_params_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/defined_with_params_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should successfully notify' do
+      pp = <<-EOS
+      user { 'dan':
+        ensure => present,
+      }
+
+      if defined_with_params(User[dan], {'ensure' => 'present' }) {
+        notify { 'User defined with ensure=>present': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: User defined with ensure=>present/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_at_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should delete elements of the array' do
+      pp = <<-EOS
+      $output = delete_at(['a','b','c','b'], 1)
+      if $output == ['a','c','b'] {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should delete elements of the array' do
+      pp = <<-EOS
+      $output = delete(['a','b','c','b'], 'b')
+      if $output == ['a','c'] {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should delete elements of the array' do
+      pp = <<-EOS
+      $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
+      if $output == { a => 'A', b => '', d => false } {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/delete_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should delete elements of the hash' do
+      pp = <<-EOS
+      $a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' }
+      $b = { 'a' => 'A', 'B' => 'C' }
+      $o = delete_values($a, 'B')
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles non-hash arguments'
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/difference_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/difference_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/difference_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'returns non-duplicates in the first array' do
+      pp = <<-EOS
+      $a = ['a','b','c']
+      $b = ['b','c','d']
+      $c = ['a']
+      $o = difference($a, $b)
+      if $o == $c {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles non-array arguments'
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/dirname_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/dirname_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/dirname_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,42 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'dirname function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    context 'absolute path' do
+      it 'returns the dirname' do
+        pp = <<-EOS
+        $a = '/path/to/a/file.txt'
+        $b = '/path/to/a'
+        $o = dirname($a)
+        if $o == $b {
+          notify { 'output correct': }
+        }
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/Notice: output correct/)
+        end
+      end
+    end
+    context 'relative path' do
+      it 'returns the dirname' do
+        pp = <<-EOS
+        $a = 'path/to/a/file.txt'
+        $b = 'path/to/a'
+        $o = dirname($a)
+        if $o == $b {
+          notify { 'output correct': }
+        }
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/Notice: output correct/)
+        end
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/downcase_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/downcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/downcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,39 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'downcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'returns the downcase' do
+      pp = <<-EOS
+      $a = 'AOEU'
+      $b = 'aoeu'
+      $o = downcase($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'doesn\'t affect lowercase words' do
+      pp = <<-EOS
+      $a = 'aoeu aoeu'
+      $b = 'aoeu aoeu'
+      $o = downcase($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/empty_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/empty_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/empty_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,53 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'recognizes empty strings' do
+      pp = <<-EOS
+      $a = ''
+      $b = true
+      $o = empty($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'recognizes non-empty strings' do
+      pp = <<-EOS
+      $a = 'aoeu'
+      $b = false
+      $o = empty($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'handles numerical values' do
+      pp = <<-EOS
+      $a = 7
+      $b = false
+      $o = empty($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/ensure_resource_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/ensure_resource_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/ensure_resource_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,30 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'ensure_resource function' do
+  describe 'success' do
+    it 'ensures a resource already declared' do
+      apply_manifest('')
+      pp = <<-EOS
+      notify { "test": loglevel => 'err' }
+      ensure_resource('notify', 'test', { 'loglevel' => 'err' })
+      EOS
+
+      apply_manifest(pp, :expect_changes => true)
+    end
+
+    it 'ensures a undeclared resource' do
+      apply_manifest('')
+      pp = <<-EOS
+      ensure_resource('notify', 'test', { 'loglevel' => 'err' })
+      EOS
+
+      apply_manifest(pp, :expect_changes => true)
+    end
+    it 'takes defaults arguments'
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/flatten_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/flatten_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/flatten_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,39 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'flatten function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'flattens arrays' do
+      pp = <<-EOS
+      $a = ["a","b",["c",["d","e"],"f","g"]]
+      $b = ["a","b","c","d","e","f","g"]
+      $o = flatten($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'does not affect flat arrays' do
+      pp = <<-EOS
+      $a = ["a","b","c","d","e","f","g"]
+      $b = ["a","b","c","d","e","f","g"]
+      $o = flatten($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/floor_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/floor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/floor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,39 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'floor function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'floors floats' do
+      pp = <<-EOS
+      $a = 12.8
+      $b = 12
+      $o = floor($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'floors integers' do
+      pp = <<-EOS
+      $a = 7
+      $b = 7
+      $o = floor($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-numbers'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,66 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    include_context "with faked facts"
+    context "when the FQDN is 'fakehost.localdomain'" do
+      before :each do
+        fake_fact("fqdn", "fakehost.localdomain")
+      end
+
+      it 'generates random alphanumeric strings' do
+        pp = <<-eos
+        $l = 10
+        $o = fqdn_rand_string($l)
+        notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+        eos
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"/)
+        end
+      end
+      it 'generates random alphanumeric strings with custom charsets' do
+        pp = <<-eos
+        $l = 10
+        $c = '0123456789'
+        $o = fqdn_rand_string($l, $c)
+        notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+        eos
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rand_string is "(7203048515|2383756694)"/)
+        end
+      end
+      it 'generates random alphanumeric strings with custom seeds' do
+        pp = <<-eos
+        $l = 10
+        $s = 'seed'
+        $o = fqdn_rand_string($l, undef, $s)
+        notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+        eos
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"/)
+        end
+      end
+      it 'generates random alphanumeric strings with custom charsets and seeds' do
+        pp = <<-eos
+        $l = 10
+        $c = '0123456789'
+        $s = 'seed'
+        $o = fqdn_rand_string($l, $c, $s)
+        notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+        eos
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rand_string is "(3104058232|7100592312)"/)
+        end
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-numbers for length argument'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,64 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    include_context "with faked facts"
+    context "when the FQDN is 'fakehost.localdomain'" do
+      before :each do
+        fake_fact("fqdn", "fakehost.localdomain")
+      end
+
+      it 'rotates arrays' do
+        pp = <<-EOS
+        $a = ['a','b','c','d']
+        $o = fqdn_rotate($a)
+        notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rotate is \["d", "a", "b", "c"\]/)
+        end
+      end
+      it 'rotates arrays with custom seeds' do
+        pp = <<-EOS
+        $a = ['a','b','c','d']
+        $s = 'seed'
+        $o = fqdn_rotate($a, $s)
+        notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
+        end
+      end
+      it 'rotates strings' do
+        pp = <<-EOS
+        $a = 'abcd'
+        $o = fqdn_rotate($a)
+        notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rotate is "dabc"/)
+        end
+      end
+      it 'rotates strings with custom seeds' do
+        pp = <<-EOS
+        $a = 'abcd'
+        $s = 'seed'
+        $o = fqdn_rotate($a, $s)
+        notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/fqdn_rotate is "cdab"/)
+        end
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles invalid arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/get_module_path_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/get_module_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/get_module_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,27 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'get_module_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'get_module_paths dne' do
+      pp = <<-EOS
+      $a = $::is_pe ? {
+        'true'  => '/etc/puppetlabs/puppet/modules/dne',
+        'false' => '/etc/puppet/modules/dne',
+      }
+      $o = get_module_path('dne')
+      if $o == $a {
+        notify { 'output correct': }
+      } else {
+        notify { "failed; module path is '$o'": }
+      }
+      EOS
+
+      apply_manifest(pp, :expect_failures => true)
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-numbers'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/getparam_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/getparam_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/getparam_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'getparam function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'getparam a notify' do
+      pp = <<-EOS
+      notify { 'rspec':
+        message => 'custom rspec message',
+      }
+      $o = getparam(Notify['rspec'], 'message')
+      notice(inline_template('getparam is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/getparam is "custom rspec message"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/getvar_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/getvar_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/getvar_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'getvars from classes' do
+      pp = <<-EOS
+      class a::data { $foo = 'aoeu' }
+      include a::data
+      $b = 'aoeu'
+      $o = getvar("a::data::foo")
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-numbers'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/grep_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/grep_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/grep_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'greps arrays' do
+      pp = <<-EOS
+      $a = ['aaabbb','bbbccc','dddeee']
+      $b = 'bbb'
+      $c = ['aaabbb','bbbccc']
+      $o = grep($a,$b)
+      if $o == $c {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_interface_with_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_interface_with_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_interface_with_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,54 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'has_interface_with function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+  describe 'success' do
+    it 'has_interface_with existing ipaddress' do
+      pp = <<-EOS
+      $a = $::ipaddress
+      $o = has_interface_with('ipaddress', $a)
+      notice(inline_template('has_interface_with is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/has_interface_with is true/)
+      end
+    end
+    it 'has_interface_with absent ipaddress' do
+      pp = <<-EOS
+      $a = '128.0.0.1'
+      $o = has_interface_with('ipaddress', $a)
+      notice(inline_template('has_interface_with is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/has_interface_with is false/)
+      end
+    end
+    it 'has_interface_with existing interface' do
+      pp = <<-EOS
+      if $osfamily == 'Solaris' or $osfamily == 'Darwin' {
+        $a = 'lo0'
+      }elsif $osfamily == 'windows' {
+        $a = $::kernelmajversion ? {
+          /6\.(2|3|4)/ => 'Ethernet0',
+          /6\.(0|1)/ => 'Local_Area_Connection',
+          /5\.(1|2)/  => undef, #Broken current in facter
+        }
+      }else {
+        $a = 'lo'
+      }
+      $o = has_interface_with($a)
+      notice(inline_template('has_interface_with is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/has_interface_with is true/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_ip_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,33 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'has_ip_address function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+  describe 'success' do
+    it 'has_ip_address existing ipaddress' do
+      pp = <<-EOS
+      $a = '127.0.0.1'
+      $o = has_ip_address($a)
+      notice(inline_template('has_ip_address is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/has_ip_address is true/)
+      end
+    end
+    it 'has_ip_address absent ipaddress' do
+      pp = <<-EOS
+      $a = '128.0.0.1'
+      $o = has_ip_address($a)
+      notice(inline_template('has_ip_address is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/has_ip_address is false/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_ip_network_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_ip_network_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_ip_network_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,33 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'has_ip_network function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
+  describe 'success' do
+    it 'has_ip_network existing ipaddress' do
+      pp = <<-EOS
+      $a = '127.0.0.0'
+      $o = has_ip_network($a)
+      notice(inline_template('has_ip_network is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/has_ip_network is true/)
+      end
+    end
+    it 'has_ip_network absent ipaddress' do
+      pp = <<-EOS
+      $a = '128.0.0.0'
+      $o = has_ip_network($a)
+      notice(inline_template('has_ip_network is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/has_ip_network is false/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_key_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_key_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/has_key_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,41 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'has_key function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'has_keys in hashes' do
+      pp = <<-EOS
+      $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
+      $b = 'bbb'
+      $c = true
+      $o = has_key($a,$b)
+      if $o == $c {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'has_keys not in hashes' do
+      pp = <<-EOS
+      $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
+      $b = 'ccc'
+      $c = false
+      $o = has_key($a,$b)
+      if $o == $c {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-hashes'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'hashs arrays' do
+      pp = <<-EOS
+      $a = ['aaa','bbb','bbb','ccc','ddd','eee']
+      $b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' }
+      $o = hash($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'handles odd-length arrays'
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/intersection_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/intersection_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/intersection_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,27 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'intersection function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'intersections arrays' do
+      pp = <<-EOS
+      $a = ['aaa','bbb','ccc']
+      $b = ['bbb','ccc','ddd','eee']
+      $c = ['bbb','ccc']
+      $o = intersection($a,$b)
+      if $o == $c {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'intersections empty arrays'
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_a_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_a_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_a_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,30 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+if get_puppet_version =~ /^4/
+  describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+    it 'should match a string' do
+      pp = <<-EOS
+      if 'hello world'.is_a(String) {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+
+    it 'should not match a integer as string' do
+      pp = <<-EOS
+      if 5.is_a(String) {
+        notify { 'output wrong': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).not_to match(/Notice: output wrong/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_array_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,67 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_arrays arrays' do
+      pp = <<-EOS
+      $a = ['aaa','bbb','ccc']
+      $b = true
+      $o = is_array($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_arrays empty arrays' do
+      pp = <<-EOS
+      $a = []
+      $b = true
+      $o = is_array($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_arrays strings' do
+      pp = <<-EOS
+      $a = "aoeu"
+      $b = false
+      $o = is_array($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_arrays hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'bbb'}
+      $b = false
+      $o = is_array($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,81 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_bools arrays' do
+      pp = <<-EOS
+      $a = ['aaa','bbb','ccc']
+      $b = false
+      $o = is_bool($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_bools true' do
+      pp = <<-EOS
+      $a = true
+      $b = true
+      $o = is_bool($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_bools false' do
+      pp = <<-EOS
+      $a = false
+      $b = true
+      $o = is_bool($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_bools strings' do
+      pp = <<-EOS
+      $a = "true"
+      $b = false
+      $o = is_bool($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_bools hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'bbb'}
+      $b = false
+      $o = is_bool($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_domain_name_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_domain_name_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_domain_name_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,83 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_domain_name function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_domain_names arrays' do
+      pp = <<-EOS
+      $a = ['aaa.com','bbb','ccc']
+      $o = is_domain_name($a)
+      notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_domain_name is false/)
+      end
+    end
+    it 'is_domain_names true' do
+      pp = <<-EOS
+      $a = true
+      $o = is_domain_name($a)
+      notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_domain_name is false/)
+      end
+    end
+    it 'is_domain_names false' do
+      pp = <<-EOS
+      $a = false
+      $o = is_domain_name($a)
+      notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_domain_name is false/)
+      end
+    end
+    it 'is_domain_names strings with hyphens' do
+      pp = <<-EOS
+      $a = "3foo-bar.2bar-fuzz.com"
+      $b = true
+      $o = is_domain_name($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_domain_names strings beginning with hyphens' do
+      pp = <<-EOS
+      $a = "-bar.2bar-fuzz.com"
+      $b = false
+      $o = is_domain_name($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_domain_names hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'www.com'}
+      $o = is_domain_name($a)
+      notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_domain_name is false/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_float_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_float_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_float_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,86 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_float function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_floats arrays' do
+      pp = <<-EOS
+      $a = ['aaa.com','bbb','ccc']
+      $o = is_float($a)
+      notice(inline_template('is_float is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_float is false/)
+      end
+    end
+    it 'is_floats true' do
+      pp = <<-EOS
+      $a = true
+      $o = is_float($a)
+      notice(inline_template('is_float is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_float is false/)
+      end
+    end
+    it 'is_floats strings' do
+      pp = <<-EOS
+      $a = "3.5"
+      $b = true
+      $o = is_float($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_floats floats' do
+      pp = <<-EOS
+      $a = 3.5
+      $b = true
+      $o = is_float($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_floats integers' do
+      pp = <<-EOS
+      $a = 3
+      $b = false
+      $o = is_float($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_floats hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'www.com'}
+      $o = is_float($a)
+      notice(inline_template('is_float is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_float is false/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_function_available_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_function_available_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_function_available_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,58 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_function_available function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_function_availables arrays' do
+      pp = <<-EOS
+      $a = ['fail','include','require']
+      $o = is_function_available($a)
+      notice(inline_template('is_function_available is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_function_available is false/)
+      end
+    end
+    it 'is_function_availables true' do
+      pp = <<-EOS
+      $a = true
+      $o = is_function_available($a)
+      notice(inline_template('is_function_available is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_function_available is false/)
+      end
+    end
+    it 'is_function_availables strings' do
+      pp = <<-EOS
+      $a = "fail"
+      $b = true
+      $o = is_function_available($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_function_availables function_availables' do
+      pp = <<-EOS
+      $a = "is_function_available"
+      $o = is_function_available($a)
+      notice(inline_template('is_function_available is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_function_available is true/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,63 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_hashs arrays' do
+      pp = <<-EOS
+      $a = ['aaa','bbb','ccc']
+      $o = is_hash($a)
+      notice(inline_template('is_hash is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_hash is false/)
+      end
+    end
+    it 'is_hashs empty hashs' do
+      pp = <<-EOS
+      $a = {}
+      $b = true
+      $o = is_hash($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_hashs strings' do
+      pp = <<-EOS
+      $a = "aoeu"
+      $b = false
+      $o = is_hash($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_hashs hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'bbb'}
+      $b = true
+      $o = is_hash($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_integer_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_integer_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_integer_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,95 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_integer function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_integers arrays' do
+      pp = <<-EOS
+      $a = ['aaa.com','bbb','ccc']
+      $b = false
+      $o = is_integer($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_integers true' do
+      pp = <<-EOS
+      $a = true
+      $b = false
+      $o = is_integer($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_integers strings' do
+      pp = <<-EOS
+      $a = "3"
+      $b = true
+      $o = is_integer($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_integers floats' do
+      pp = <<-EOS
+      $a = 3.5
+      $b = false
+      $o = is_integer($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_integers integers' do
+      pp = <<-EOS
+      $a = 3
+      $b = true
+      $o = is_integer($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_integers hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'www.com'}
+      $b = false
+      $o = is_integer($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ip_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,80 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_ip_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_ip_addresss ipv4' do
+      pp = <<-EOS
+      $a = '1.2.3.4'
+      $b = true
+      $o = is_ip_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ip_addresss ipv6' do
+      pp = <<-EOS
+      $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
+      $b = true
+      $o = is_ip_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ip_addresss ipv6 compressed' do
+      pp = <<-EOS
+      $a = "fe00::1"
+      $b = true
+      $o = is_ip_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ip_addresss strings' do
+      pp = <<-EOS
+      $a = "aoeu"
+      $b = false
+      $o = is_ip_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ip_addresss ipv4 out of range' do
+      pp = <<-EOS
+      $a = '1.2.3.400'
+      $b = false
+      $o = is_ip_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,52 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_ipv4_addresss' do
+      pp = <<-EOS
+      $a = '1.2.3.4'
+      $b = true
+      $o = is_ipv4_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ipv4_addresss strings' do
+      pp = <<-EOS
+      $a = "aoeu"
+      $b = false
+      $o = is_ipv4_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ipv4_addresss ipv4 out of range' do
+      pp = <<-EOS
+      $a = '1.2.3.400'
+      $b = false
+      $o = is_ipv4_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,66 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_ipv6_addresss' do
+      pp = <<-EOS
+      $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
+      $b = true
+      $o = is_ipv6_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ipv6_addresss ipv6 compressed' do
+      pp = <<-EOS
+      $a = "fe00::1"
+      $b = true
+      $o = is_ipv6_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ipv6_addresss strings' do
+      pp = <<-EOS
+      $a = "aoeu"
+      $b = false
+      $o = is_ipv6_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_ipv6_addresss ip out of range' do
+      pp = <<-EOS
+      $a = 'fe80:0000:cd12:d123:e2f8:47ff:fe09:gggg'
+      $b = false
+      $o = is_ipv6_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_mac_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_mac_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_mac_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,38 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_mac_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_mac_addresss a mac' do
+      pp = <<-EOS
+      $a = '00:a0:1f:12:7f:a0'
+      $b = true
+      $o = is_mac_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_mac_addresss a mac out of range' do
+      pp = <<-EOS
+      $a = '00:a0:1f:12:7f:g0'
+      $b = false
+      $o = is_mac_address($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_numeric_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_numeric_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_numeric_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,95 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_numeric function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_numerics arrays' do
+      pp = <<-EOS
+      $a = ['aaa.com','bbb','ccc']
+      $b = false
+      $o = is_numeric($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_numerics true' do
+      pp = <<-EOS
+      $a = true
+      $b = false
+      $o = is_numeric($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_numerics strings' do
+      pp = <<-EOS
+      $a = "3"
+      $b = true
+      $o = is_numeric($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_numerics floats' do
+      pp = <<-EOS
+      $a = 3.5
+      $b = true
+      $o = is_numeric($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_numerics integers' do
+      pp = <<-EOS
+      $a = 3
+      $b = true
+      $o = is_numeric($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_numerics hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'www.com'}
+      $b = false
+      $o = is_numeric($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+    it 'handles non-arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_string_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/is_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,102 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'is_strings arrays' do
+      pp = <<-EOS
+      $a = ['aaa.com','bbb','ccc']
+      $b = false
+      $o = is_string($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_strings true' do
+      pp = <<-EOS
+      $a = true
+      $b = false
+      $o = is_string($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_strings strings' do
+      pp = <<-EOS
+      $a = "aoeu"
+      $o = is_string($a)
+      notice(inline_template('is_string is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_string is true/)
+      end
+    end
+    it 'is_strings number strings' do
+      pp = <<-EOS
+      $a = "3"
+      $o = is_string($a)
+      notice(inline_template('is_string is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/is_string is false/)
+      end
+    end
+    it 'is_strings floats' do
+      pp = <<-EOS
+      $a = 3.5
+      $b = false
+      $o = is_string($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_strings integers' do
+      pp = <<-EOS
+      $a = 3
+      $b = false
+      $o = is_string($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'is_strings hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'www.com'}
+      $b = false
+      $o = is_string($a)
+      if $o == $b {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'join_keys_to_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'join_keys_to_valuess hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'bbb','ccc'=>'ddd'}
+      $b = ':'
+      $o = join_keys_to_values($a,$b)
+      notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]/)
+      end
+    end
+    it 'handles non hashes'
+    it 'handles empty hashes'
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/join_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/join_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/join_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'joins arrays' do
+      pp = <<-EOS
+      $a = ['aaa','bbb','ccc']
+      $b = ':'
+      $c = 'aaa:bbb:ccc'
+      $o = join($a,$b)
+      if $o == $c {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    it 'handles non arrays'
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/keys_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/keys_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/keys_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,23 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'keyss hashes' do
+      pp = <<-EOS
+      $a = {'aaa'=>'bbb','ccc'=>'ddd'}
+      $o = keys($a)
+      notice(inline_template('keys is <%= @o.sort.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/keys is \["aaa", "ccc"\]/)
+      end
+    end
+    it 'handles non hashes'
+    it 'handles empty hashes'
+  end
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/loadyaml_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/loadyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/loadyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,33 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+tmpdir = default.tmpdir('stdlib')
+
+describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'loadyamls array of values' do
+      shell("echo '---
+      aaa: 1
+      bbb: 2
+      ccc: 3
+      ddd: 4' > #{tmpdir}/testyaml.yaml")
+      pp = <<-EOS
+      $o = loadyaml('#{tmpdir}/testyaml.yaml')
+      notice(inline_template('loadyaml[aaa] is <%= @o["aaa"].inspect %>'))
+      notice(inline_template('loadyaml[bbb] is <%= @o["bbb"].inspect %>'))
+      notice(inline_template('loadyaml[ccc] is <%= @o["ccc"].inspect %>'))
+      notice(inline_template('loadyaml[ddd] is <%= @o["ddd"].inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/loadyaml\[aaa\] is 1/)
+        expect(r.stdout).to match(/loadyaml\[bbb\] is 2/)
+        expect(r.stdout).to match(/loadyaml\[ccc\] is 3/)
+        expect(r.stdout).to match(/loadyaml\[ddd\] is 4/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'fails with no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/lstrip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/lstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/lstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'lstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'lstrips arrays' do
+      pp = <<-EOS
+      $a = ["  the   ","   public   ","   art","galleries   "]
+      # Anagram: Large picture halls, I bet
+      $o = lstrip($a)
+      notice(inline_template('lstrip is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/lstrip is \["the   ", "public   ", "art", "galleries   "\]/)
+      end
+    end
+    it 'lstrips strings' do
+      pp = <<-EOS
+      $a = "   blowzy night-frumps vex'd jack q   "
+      $o = lstrip($a)
+      notice(inline_template('lstrip is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/lstrip is "blowzy night-frumps vex'd jack q   "/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/max_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/max_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/max_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,20 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'maxs arrays' do
+      pp = <<-EOS
+      $o = max("the","public","art","galleries")
+      notice(inline_template('max is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/max is "the"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/member_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/member_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/member_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,54 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  shared_examples 'item found' do
+    it 'should output correctly' do
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+  end
+  describe 'success' do
+    it 'members arrays' do
+      pp = <<-EOS
+      $a = ['aaa','bbb','ccc']
+      $b = 'ccc'
+      $c = true
+      $o = member($a,$b)
+      if $o == $c {
+        notify { 'output correct': }
+      }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/Notice: output correct/)
+      end
+    end
+    describe 'members array of integers' do
+      it_should_behave_like 'item found' do
+        let(:pp) { <<-EOS
+      if member( [1,2,3,4], 4 ){
+        notify { 'output correct': }
+      }
+        EOS
+        }
+      end
+    end
+    describe 'members of mixed array' do
+      it_should_behave_like 'item found' do
+        let(:pp) { <<-EOS
+      if member( ['a','4',3], 'a' ){
+        notify { 'output correct': }
+}
+        EOS
+        }
+      end
+    end
+    it 'members arrays without members'
+  end
+
+  describe 'failure' do
+    it 'handles improper argument counts'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/merge_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,23 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'should merge two hashes' do
+      pp = <<-EOS
+      $a = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
+      $b = {'two' => 'dos', 'three' => { 'five' => 5 } }
+      $o = merge($a, $b)
+      notice(inline_template('merge[one]   is <%= @o["one"].inspect %>'))
+      notice(inline_template('merge[two]   is <%= @o["two"].inspect %>'))
+      notice(inline_template('merge[three] is <%= @o["three"].inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/merge\[one\]   is ("1"|1)/)
+        expect(r.stdout).to match(/merge\[two\]   is "dos"/)
+        expect(r.stdout).to match(/merge\[three\] is {"five"=>("5"|5)}/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/min_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/min_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/min_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,20 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'mins arrays' do
+      pp = <<-EOS
+      $o = min("the","public","art","galleries")
+      notice(inline_template('min is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/min is "art"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-59-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  centos-59-x64:
+    roles:
+      - master
+    platform: el-5-x86_64
+    box : centos-59-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: git
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,15 @@
+HOSTS:
+  'centos-6-vcloud':
+    roles:
+      - master
+    platform: el-6-x86_64
+    hypervisor: vcloud
+    template: centos-6-x86_64
+CONFIG:
+  type: foss
+  ssh:
+    keys: "~/.ssh/id_rsa-acceptance"
+  datastore: instance0
+  folder: Delivery/Quality Assurance/Enterprise/Dynamic
+  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
+  pooling_api: http://vcloud.delivery.puppetlabs.net/
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,12 @@
+HOSTS:
+  centos-64-x64:
+    roles:
+      - master
+      - database
+      - dashboard
+    platform: el-6-x86_64
+    box : centos-64-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: pe
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  centos-64-x64:
+    roles:
+      - master
+    platform: el-6-x86_64
+    box : centos-64-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: foss
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/centos-65-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  centos-65-x64:
+    roles:
+      - master
+    platform: el-6-x86_64
+    box : centos-65-x64-vbox436-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: foss
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/default.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/default.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/default.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  centos-65-x64:
+    roles:
+      - master
+    platform: el-6-x86_64
+    box : centos-65-x64-vbox436-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: foss
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  fedora-18-x64:
+    roles:
+      - master
+    platform: fedora-18-x86_64
+    box : fedora-18-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: foss
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  sles-11-x64.local:
+    roles:
+      - master
+    platform: sles-11-x64
+    box : sles-11sp1-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box
+    hypervisor : vagrant
+CONFIG:
+    type: foss
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  ubuntu-server-10044-x64:
+    roles:
+      - master
+    platform: ubuntu-10.04-amd64
+    box : ubuntu-server-10044-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: foss
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,10 @@
+HOSTS:
+  ubuntu-server-12042-x64:
+    roles:
+      - master
+    platform: ubuntu-12.04-amd64
+    box : ubuntu-server-12042-x64-vbox4210-nocm
+    box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
+    hypervisor : vagrant
+CONFIG:
+  type: foss
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,11 @@
+HOSTS:
+  ubuntu-server-1404-x64:
+    roles:
+      - master
+    platform: ubuntu-14.04-amd64
+    box : puppetlabs/ubuntu-14.04-64-nocm
+    box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
+    hypervisor : vagrant
+CONFIG:
+  log_level   : debug
+  type: git
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2003-i386.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+HOSTS:
+  ubuntu1204:
+    roles:
+      - master
+      - database
+      - dashboard
+    platform: ubuntu-12.04-amd64
+    template: ubuntu-1204-x86_64
+    hypervisor: vcloud
+  win2003_i386:
+    roles:
+      - agent
+      - default
+    platform: windows-2003-i386
+    template: win-2003-i386
+    hypervisor: vcloud
+CONFIG:
+  nfs_server: none
+  ssh:
+    keys: "~/.ssh/id_rsa-acceptance"
+  consoleport: 443
+  datastore: instance0
+  folder: Delivery/Quality Assurance/Enterprise/Dynamic
+  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
+  pooling_api: http://vcloud.delivery.puppetlabs.net/
+  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2003-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+HOSTS:
+  ubuntu1204:
+    roles:
+      - master
+      - database
+      - dashboard
+    platform: ubuntu-12.04-amd64
+    template: ubuntu-1204-x86_64
+    hypervisor: vcloud
+  win2003_x86_64:
+    roles:
+      - agent
+      - default
+    platform: windows-2003-x86_64
+    template: win-2003-x86_64
+    hypervisor: vcloud
+CONFIG:
+  nfs_server: none
+  ssh:
+    keys: "~/.ssh/id_rsa-acceptance"
+  consoleport: 443
+  datastore: instance0
+  folder: Delivery/Quality Assurance/Enterprise/Dynamic
+  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
+  pooling_api: http://vcloud.delivery.puppetlabs.net/
+  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2008-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+HOSTS:
+  ubuntu1204:
+    roles:
+      - master
+      - database
+      - dashboard
+    platform: ubuntu-12.04-amd64
+    template: ubuntu-1204-x86_64
+    hypervisor: vcloud
+  win2008_x86_64:
+    roles:
+      - agent
+      - default
+    platform: windows-2008-x86_64
+    template: win-2008-x86_64
+    hypervisor: vcloud
+CONFIG:
+  nfs_server: none
+  ssh:
+    keys: "~/.ssh/id_rsa-acceptance"
+  consoleport: 443
+  datastore: instance0
+  folder: Delivery/Quality Assurance/Enterprise/Dynamic
+  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
+  pooling_api: http://vcloud.delivery.puppetlabs.net/
+  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2008r2-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+HOSTS:
+  ubuntu1204:
+    roles:
+      - master
+      - database
+      - dashboard
+    platform: ubuntu-12.04-amd64
+    template: ubuntu-1204-x86_64
+    hypervisor: vcloud
+  win2008r2:
+    roles:
+      - agent
+      - default
+    platform: windows-2008r2-x86_64
+    template: win-2008r2-x86_64
+    hypervisor: vcloud
+CONFIG:
+  nfs_server: none
+  ssh:
+    keys: "~/.ssh/id_rsa-acceptance"
+  consoleport: 443
+  datastore: instance0
+  folder: Delivery/Quality Assurance/Enterprise/Dynamic
+  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
+  pooling_api: http://vcloud.delivery.puppetlabs.net/
+  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2012-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+HOSTS:
+  ubuntu1204:
+    roles:
+      - master
+      - database
+      - dashboard
+    platform: ubuntu-12.04-amd64
+    template: ubuntu-1204-x86_64
+    hypervisor: vcloud
+  win2012:
+    roles:
+      - agent
+      - default
+    platform: windows-2012-x86_64
+    template: win-2012-x86_64
+    hypervisor: vcloud
+CONFIG:
+  nfs_server: none
+  ssh:
+    keys: "~/.ssh/id_rsa-acceptance"
+  consoleport: 443
+  datastore: instance0
+  folder: Delivery/Quality Assurance/Enterprise/Dynamic
+  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
+  pooling_api: http://vcloud.delivery.puppetlabs.net/
+  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/nodesets/windows-2012r2-x86_64.yml	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+HOSTS:
+  ubuntu1204:
+    roles:
+      - master
+      - database
+      - dashboard
+    platform: ubuntu-12.04-amd64
+    template: ubuntu-1204-x86_64
+    hypervisor: vcloud
+  win2012r2:
+    roles:
+      - agent
+      - default
+    platform: windows-2012r2-x86_64
+    template: win-2012r2-x86_64
+    hypervisor: vcloud
+CONFIG:
+  nfs_server: none
+  ssh:
+    keys: "~/.ssh/id_rsa-acceptance"
+  consoleport: 443
+  datastore: instance0
+  folder: Delivery/Quality Assurance/Enterprise/Dynamic
+  resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
+  pooling_api: http://vcloud.delivery.puppetlabs.net/
+  pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/num2bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/num2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/num2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,76 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'num2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'bools positive numbers and numeric strings as true' do
+      pp = <<-EOS
+      $a = 1
+      $b = "1"
+      $c = "50"
+      $ao = num2bool($a)
+      $bo = num2bool($b)
+      $co = num2bool($c)
+      notice(inline_template('a is <%= @ao.inspect %>'))
+      notice(inline_template('b is <%= @bo.inspect %>'))
+      notice(inline_template('c is <%= @co.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/a is true/)
+        expect(r.stdout).to match(/b is true/)
+        expect(r.stdout).to match(/c is true/)
+      end
+    end
+    it 'bools negative numbers as false' do
+      pp = <<-EOS
+      $a = 0
+      $b = -0.1
+      $c = ["-50","1"]
+      $ao = num2bool($a)
+      $bo = num2bool($b)
+      $co = num2bool($c)
+      notice(inline_template('a is <%= @ao.inspect %>'))
+      notice(inline_template('b is <%= @bo.inspect %>'))
+      notice(inline_template('c is <%= @co.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/a is false/)
+        expect(r.stdout).to match(/b is false/)
+        expect(r.stdout).to match(/c is false/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'fails on words' do
+      pp = <<-EOS
+      $a = "a"
+      $ao = num2bool($a)
+      notice(inline_template('a is <%= @ao.inspect %>'))
+      EOS
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/)
+    end
+
+    it 'fails on numberwords' do
+      pp = <<-EOS
+      $b = "1b"
+      $bo = num2bool($b)
+      notice(inline_template('b is <%= @bo.inspect %>'))
+      EOS
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/)
+
+    end
+
+    it 'fails on non-numeric/strings' do
+      pending "The function will call .to_s.to_i on anything not a Numeric or
+      String, and results in 0. Is this intended?"
+      pp = <<-EOS
+      $c = {"c" => "-50"}
+      $co = num2bool($c)
+      notice(inline_template('c is <%= @co.inspect %>'))
+      EOS
+      expect(apply_manifest(ppc :expect_failures => true).stderr).to match(/Unable to parse/)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/parsejson_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/parsejson_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/parsejson_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,55 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'parses valid json' do
+      pp = <<-EOS
+      $a = '{"hunter": "washere", "tests": "passing"}'
+      $ao = parsejson($a)
+      $tests = $ao['tests']
+      notice(inline_template('tests are <%= @tests.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/tests are "passing"/)
+      end
+    end
+  end
+
+  describe 'failure' do
+    it 'raises error on incorrect json' do
+      pp = <<-EOS
+      $a = '{"hunter": "washere", "tests": "passing",}'
+      $ao = parsejson($a, 'tests are using the default value')
+      notice(inline_template('a is <%= @ao.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/tests are using the default value/)
+      end
+    end
+
+    it 'raises error on incorrect json' do
+      pp = <<-EOS
+      $a = '{"hunter": "washere", "tests": "passing",}'
+      $ao = parsejson($a)
+      notice(inline_template('a is <%= @ao.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/expected next name/)
+      end
+    end
+
+    it 'raises error on incorrect number of arguments' do
+      pp = <<-EOS
+      $o = parsejson()
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/wrong number of arguments/i)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/parseyaml_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/parseyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/parseyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,58 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'parses valid yaml' do
+      pp = <<-EOS
+      $a = "---\nhunter: washere\ntests: passing\n"
+      $o = parseyaml($a)
+      $tests = $o['tests']
+      notice(inline_template('tests are <%= @tests.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/tests are "passing"/)
+      end
+    end
+  end
+
+  describe 'failure' do
+    it 'returns the default value on incorrect yaml' do
+      pp = <<-EOS
+      $a = "---\nhunter: washere\ntests: passing\n:"
+      $o = parseyaml($a, {'tests' => 'using the default value'})
+      $tests = $o['tests']
+      notice(inline_template('tests are <%= @tests.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/tests are "using the default value"/)
+      end
+    end
+
+    it 'raises error on incorrect yaml' do
+      pp = <<-EOS
+      $a = "---\nhunter: washere\ntests: passing\n:"
+      $o = parseyaml($a)
+      $tests = $o['tests']
+      notice(inline_template('tests are <%= @tests.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/(syntax error|did not find expected key)/)
+      end
+    end
+
+
+    it 'raises error on incorrect number of arguments' do
+      pp = <<-EOS
+      $o = parseyaml()
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/wrong number of arguments/i)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pick_default_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pick_default_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pick_default_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,54 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'pick_defaults a default value' do
+      pp = <<-EOS
+      $a = undef
+      $o = pick_default($a, 'default')
+      notice(inline_template('picked is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/picked is "default"/)
+      end
+    end
+    it 'pick_defaults with no value' do
+      pp = <<-EOS
+      $a = undef
+      $b = undef
+      $o = pick_default($a,$b)
+      notice(inline_template('picked is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/picked is ""/)
+      end
+    end
+    it 'pick_defaults the first set value' do
+      pp = <<-EOS
+      $a = "something"
+      $b = "long"
+      $o = pick_default($a, $b, 'default')
+      notice(inline_template('picked is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/picked is "something"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'raises error with no values' do
+      pp = <<-EOS
+      $o = pick_default()
+      notice(inline_template('picked is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/Must receive at least one argument/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pick_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pick_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pick_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,44 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'pick function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'picks a default value' do
+      pp = <<-EOS
+      $a = undef
+      $o = pick($a, 'default')
+      notice(inline_template('picked is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/picked is "default"/)
+      end
+    end
+    it 'picks the first set value' do
+      pp = <<-EOS
+      $a = "something"
+      $b = "long"
+      $o = pick($a, $b, 'default')
+      notice(inline_template('picked is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/picked is "something"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'raises error with all undef values' do
+      pp = <<-EOS
+      $a = undef
+      $b = undef
+      $o = pick($a, $b)
+      notice(inline_template('picked is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/must receive at least one non empty value/)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/prefix_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/prefix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/prefix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,42 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'prefix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'prefixes array of values' do
+      pp = <<-EOS
+      $o = prefix(['a','b','c'],'p')
+      notice(inline_template('prefix is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/prefix is \["pa", "pb", "pc"\]/)
+      end
+    end
+    it 'prefixs with empty array' do
+      pp = <<-EOS
+      $o = prefix([],'p')
+      notice(inline_template('prefix is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/prefix is \[\]/)
+      end
+    end
+    it 'prefixs array of values with undef' do
+      pp = <<-EOS
+      $o = prefix(['a','b','c'], undef)
+      notice(inline_template('prefix is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/prefix is \["a", "b", "c"\]/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'fails with no arguments'
+    it 'fails when first argument is not array'
+    it 'fails when second argument is not string'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pw_hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pw_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/pw_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+# Windows and OS X do not have useful implementations of crypt(3)
+describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'hashes passwords' do
+      pp = <<-EOS
+      $o = pw_hash('password', 'sha-512', 'salt')
+      notice(inline_template('pw_hash is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."/)
+      end
+    end
+
+    it 'returns nil if no password is provided' do
+      pp = <<-EOS
+      $o = pw_hash('', 'sha-512', 'salt')
+      notice(inline_template('pw_hash is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/pw_hash is nil/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles less than three arguments'
+    it 'handles more than three arguments'
+    it 'handles non strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/range_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/range_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/range_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,36 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'range function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'ranges letters' do
+      pp = <<-EOS
+      $o = range('a','d')
+      notice(inline_template('range is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/range is \["a", "b", "c", "d"\]/)
+      end
+    end
+    it 'ranges letters with a step' do
+      pp = <<-EOS
+      $o = range('a','d', '2')
+      notice(inline_template('range is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/range is \["a", "c"\]/)
+      end
+    end
+    it 'ranges letters with a negative step'
+    it 'ranges numbers'
+    it 'ranges numbers with a step'
+    it 'ranges numbers with a negative step'
+    it 'ranges numeric strings'
+    it 'ranges zero padded numbers'
+  end
+  describe 'failure' do
+    it 'fails with no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/reject_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/reject_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/reject_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,42 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'reject function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'rejects array of values' do
+      pp = <<-EOS
+      $o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
+      notice(inline_template('reject is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/reject is \["bbb", "ccc"\]/)
+      end
+    end
+    it 'rejects with empty array' do
+      pp = <<-EOS
+      $o = reject([],'aaa')
+      notice(inline_template('reject is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/reject is \[\]/)
+      end
+    end
+    it 'rejects array of values with undef' do
+      pp = <<-EOS
+      $o = reject(['aaa','bbb','ccc','aaaddd'], undef)
+      notice(inline_template('reject is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/reject is \[\]/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'fails with no arguments'
+    it 'fails when first argument is not array'
+    it 'fails when second argument is not string'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/reverse_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/reverse_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/reverse_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,23 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'reverses strings' do
+      pp = <<-EOS
+      $a = "the public art galleries"
+      # Anagram: Large picture halls, I bet
+      $o = reverse($a)
+      notice(inline_template('reverse is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/reverse is "seirellag tra cilbup eht"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/rstrip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/rstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/rstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'rstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'rstrips arrays' do
+      pp = <<-EOS
+      $a = ["  the   ","   public   ","   art","galleries   "]
+      # Anagram: Large picture halls, I bet
+      $o = rstrip($a)
+      notice(inline_template('rstrip is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/rstrip is \["  the", "   public", "   art", "galleries"\]/)
+      end
+    end
+    it 'rstrips strings' do
+      pp = <<-EOS
+      $a = "   blowzy night-frumps vex'd jack q   "
+      $o = rstrip($a)
+      notice(inline_template('rstrip is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/rstrip is "   blowzy night-frumps vex'd jack q"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/shuffle_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/shuffle_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/shuffle_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'shuffle function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'shuffles arrays' do
+      pp = <<-EOS
+      $a = ["1", "2", "3", "4", "5", "6", "7", "8", "the","public","art","galleries"]
+      # Anagram: Large picture halls, I bet
+      $o = shuffle($a)
+      notice(inline_template('shuffle is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to_not match(/shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]/)
+      end
+    end
+    it 'shuffles strings' do
+      pp = <<-EOS
+      $a = "blowzy night-frumps vex'd jack q"
+      $o = shuffle($a)
+      notice(inline_template('shuffle is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to_not match(/shuffle is "blowzy night-frumps vex'd jack q"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/size_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/size_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/size_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,55 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'size function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'single string size' do
+      pp = <<-EOS
+      $a = 'discombobulate'
+      $o = size($a)
+      notice(inline_template('size is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/size is 14/)
+      end
+    end
+    it 'with empty string' do
+      pp = <<-EOS
+      $a = ''
+      $o = size($a)
+      notice(inline_template('size is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/size is 0/)
+      end
+    end
+    it 'with undef' do
+      pp = <<-EOS
+      $a = undef
+      $o = size($a)
+      notice(inline_template('size is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/size is 0/)
+      end
+    end
+    it 'strings in array' do
+      pp = <<-EOS
+      $a = ['discombobulate', 'moo']
+      $o = size($a)
+      notice(inline_template('size is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/size is 2/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/sort_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/sort_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/sort_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'sort function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'sorts arrays' do
+      pp = <<-EOS
+      $a = ["the","public","art","galleries"]
+      # Anagram: Large picture halls, I bet
+      $o = sort($a)
+      notice(inline_template('sort is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/sort is \["art", "galleries", "public", "the"\]/)
+      end
+    end
+    it 'sorts strings' do
+      pp = <<-EOS
+      $a = "blowzy night-frumps vex'd jack q"
+      $o = sort($a)
+      notice(inline_template('sort is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/sort is "    '-abcdefghijklmnopqrstuvwxyz"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/squeeze_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/squeeze_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/squeeze_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,47 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'squeeze function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'squeezes arrays' do
+      pp = <<-EOS
+      # Real words!
+      $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
+      $o = squeeze($a)
+      notice(inline_template('squeeze is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]/)
+      end
+    end
+    it 'squeezez arrays with an argument'
+    it 'squeezes strings' do
+      pp = <<-EOS
+      $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
+      $o = squeeze($a)
+      notice(inline_template('squeeze is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/squeeze is "wales laparohysterosalpingophorectomy br godeship"/)
+      end
+    end
+
+    it 'squeezes strings with an argument' do
+      pp = <<-EOS
+      $a = "countessship duchessship governessship hostessship"
+      $o = squeeze($a, 's')
+      notice(inline_template('squeeze is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/squeeze is "counteship ducheship governeship hosteship"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/str2bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/str2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/str2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,31 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'str2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'works with "y"' do
+      pp = <<-EOS
+      $o = str2bool('y')
+      notice(inline_template('str2bool is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/str2bool is true/)
+      end
+    end
+    it 'works with "Y"'
+    it 'works with "yes"'
+    it 'works with "1"'
+    it 'works with "true"'
+    it 'works with "n"'
+    it 'works with "N"'
+    it 'works with "no"'
+    it 'works with "0"'
+    it 'works with "false"'
+    it 'works with undef'
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non arrays or strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'works with "y"' do
+      pp = <<-EOS
+      $o = str2saltedsha512('password')
+      notice(inline_template('str2saltedsha512 is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/str2saltedsha512 is "[a-f0-9]{136}"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles more than one argument'
+    it 'handles non strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/strftime_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/strftime_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/strftime_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'gives the Century' do
+      pp = <<-EOS
+      $o = strftime('%C')
+      notice(inline_template('strftime is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/strftime is "20"/)
+      end
+    end
+    it 'takes a timezone argument'
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles invalid format strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/strip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/strip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/strip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'strip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'strips arrays' do
+      pp = <<-EOS
+      $a = ["  the   ","   public   ","   art","galleries   "]
+      # Anagram: Large picture halls, I bet
+      $o = strip($a)
+      notice(inline_template('strip is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/strip is \["the", "public", "art", "galleries"\]/)
+      end
+    end
+    it 'strips strings' do
+      pp = <<-EOS
+      $a = "   blowzy night-frumps vex'd jack q   "
+      $o = strip($a)
+      notice(inline_template('strip is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/strip is "blowzy night-frumps vex'd jack q"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/suffix_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/suffix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/suffix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,42 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'suffix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'suffixes array of values' do
+      pp = <<-EOS
+      $o = suffix(['a','b','c'],'p')
+      notice(inline_template('suffix is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/suffix is \["ap", "bp", "cp"\]/)
+      end
+    end
+    it 'suffixs with empty array' do
+      pp = <<-EOS
+      $o = suffix([],'p')
+      notice(inline_template('suffix is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/suffix is \[\]/)
+      end
+    end
+    it 'suffixs array of values with undef' do
+      pp = <<-EOS
+      $o = suffix(['a','b','c'], undef)
+      notice(inline_template('suffix is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/suffix is \["a", "b", "c"\]/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'fails with no arguments'
+    it 'fails when first argument is not array'
+    it 'fails when second argument is not string'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/swapcase_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/swapcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/swapcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'works with strings' do
+      pp = <<-EOS
+      $o = swapcase('aBcD')
+      notice(inline_template('swapcase is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/swapcase is "AbCd"/)
+      end
+    end
+    it 'works with arrays'
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non arrays or strings'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/time_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/time_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/time_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,36 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'time function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'gives the time' do
+      pp = <<-EOS
+      $o = time()
+      notice(inline_template('time is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        m = r.stdout.match(/time is (\d+)\D/)
+
+        # When I wrote this test
+        expect(Integer(m[1])).to be > 1398894170
+      end
+    end
+    it 'takes a timezone argument' do
+      pp = <<-EOS
+      $o = time('UTC')
+      notice(inline_template('time is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        m = r.stdout.match(/time is (\d+)\D/)
+
+        expect(Integer(m[1])).to be > 1398894170
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles more arguments'
+    it 'handles invalid timezones'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/to_bytes_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/to_bytes_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/to_bytes_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,27 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'to_bytes function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'converts kB to B' do
+      pp = <<-EOS
+      $o = to_bytes('4 kB')
+      notice(inline_template('to_bytes is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        m = r.stdout.match(/to_bytes is (\d+)\D/)
+        expect(m[1]).to eq("4096")
+      end
+    end
+    it 'works without the B in unit'
+    it 'works without a space before unit'
+    it 'works without a unit'
+    it 'converts fractions'
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non integer arguments'
+    it 'handles unknown units like uB'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/try_get_value_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/try_get_value_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/try_get_value_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,47 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'try_get_value function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'gets a value' do
+      pp = <<-EOS
+      $data = {
+        'a' => { 'b' => 'passing'}
+      }
+
+      $tests = try_get_value($data, 'a/b')
+      notice(inline_template('tests are <%= @tests.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/tests are "passing"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'uses a default value' do
+      pp = <<-EOS
+      $data = {
+        'a' => { 'b' => 'passing'}
+      }
+
+      $tests = try_get_value($data, 'c/d', 'using the default value')
+      notice(inline_template('tests are <%= @tests.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/using the default value/)
+      end
+    end
+
+    it 'raises error on incorrect number of arguments' do
+      pp = <<-EOS
+      $o = try_get_value()
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/wrong number of arguments/i)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/type_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/type_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/type_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || is_future_parser_enabled?) do
+  describe 'success' do
+    it 'types arrays' do
+      pp = <<-EOS
+      $a = ["the","public","art","galleries"]
+      # Anagram: Large picture halls, I bet
+      $o = type($a)
+      notice(inline_template('type is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/type is "array"/)
+      end
+    end
+    it 'types strings' do
+      pp = <<-EOS
+      $a = "blowzy night-frumps vex'd jack q"
+      $o = type($a)
+      notice(inline_template('type is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/type is "string"/)
+      end
+    end
+    it 'types hashes'
+    it 'types integers'
+    it 'types floats'
+    it 'types booleans'
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/union_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/union_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/union_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'unions arrays' do
+      pp = <<-EOS
+      $a = ["the","public"]
+      $b = ["art"]
+      $c = ["galleries"]
+      # Anagram: Large picture halls, I bet
+      $o = union($a,$b,$c)
+      notice(inline_template('union is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/union is \["the", "public", "art", "galleries"\]/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/unique_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/unique_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/unique_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,33 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'unique function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'uniques arrays' do
+      pp = <<-EOS
+      $a = ["wallless", "wallless", "brrr", "goddessship"]
+      $o = unique($a)
+      notice(inline_template('unique is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/unique is \["wallless", "brrr", "goddessship"\]/)
+      end
+    end
+    it 'uniques strings' do
+      pp = <<-EOS
+      $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
+      $o = unique($a)
+      notice(inline_template('unique is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/unique is "wales prohytingcmbd"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/unsupported_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/unsupported_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/unsupported_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,11 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  it 'should fail' do
+    pp = <<-EOS
+    class { 'mysql::server': }
+    EOS
+    expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/upcase_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/upcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/upcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,33 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'upcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'upcases arrays' do
+      pp = <<-EOS
+      $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
+      $o = upcase($a)
+      notice(inline_template('upcase is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]/)
+      end
+    end
+    it 'upcases strings' do
+      pp = <<-EOS
+      $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
+      $o = upcase($a)
+      notice(inline_template('upcase is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/uriescape_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/uriescape_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/uriescape_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,23 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'uriescape function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'uriescape strings' do
+      pp = <<-EOS
+      $a = ":/?#[]@!$&'()*+,;= \\\"{}"
+      $o = uriescape($a)
+      notice(inline_template('uriescape is <%= @o.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"/)
+      end
+    end
+    it 'does nothing if a string is already safe'
+  end
+  describe 'failure' do
+    it 'handles no arguments'
+    it 'handles non strings or arrays'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,31 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_absolute_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    %w{
+      C:/
+      C:\\\\
+      C:\\\\WINDOWS\\\\System32
+      C:/windows/system32
+      X:/foo/bar
+      X:\\\\foo\\\\bar
+      /var/tmp
+      /var/lib/puppet
+      /var/opt/../lib/puppet
+    }.each do |path|
+      it "validates a single argument #{path}" do
+        pp = <<-EOS
+        $one = '#{path}'
+        validate_absolute_path($one)
+        EOS
+
+        apply_manifest(pp, :catch_failures => true)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+    it 'handles relative paths'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_array_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a single argument' do
+      pp = <<-EOS
+      $one = ['a', 'b']
+      validate_array($one)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates an multiple arguments' do
+      pp = <<-EOS
+      $one = ['a', 'b']
+      $two = [['c'], 'd']
+      validate_array($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates a non-array' do
+      {
+        %{validate_array({'a' => 'hash' })} => "Hash",
+        %{validate_array('string')}         => "String",
+        %{validate_array(false)}            => "FalseClass",
+        %{validate_array(undef)}            => "String"
+      }.each do |pp,type|
+        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_augeas_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_augeas_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_augeas_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,63 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_augeas function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows')) do
+  describe 'prep' do
+    it 'installs augeas for tests'
+  end
+  describe 'success' do
+    context 'valid inputs with no 3rd argument' do
+      {
+        'root:x:0:0:root:/root:/bin/bash\n'                        => 'Passwd.lns',
+        'proc /proc   proc    nodev,noexec,nosuid     0       0\n' => 'Fstab.lns'
+      }.each do |line,lens|
+        it "validates a single argument for #{lens}" do
+          pp = <<-EOS
+          $line = "#{line}"
+          $lens = "#{lens}"
+          validate_augeas($line, $lens)
+          EOS
+
+          apply_manifest(pp, :catch_failures => true)
+        end
+      end
+    end
+    context 'valid inputs with 3rd and 4th arguments' do
+      it "validates a restricted value" do
+        line        = 'root:x:0:0:root:/root:/bin/barsh\n'
+        lens        = 'Passwd.lns'
+        restriction = '$file/*[shell="/bin/barsh"]'
+        pp = <<-EOS
+        $line        = "#{line}"
+        $lens        = "#{lens}"
+        $restriction = ['#{restriction}']
+        validate_augeas($line, $lens, $restriction, "my custom failure message")
+        EOS
+
+        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/)
+      end
+    end
+    context 'invalid inputs' do
+      {
+        'root:x:0:0:root' => 'Passwd.lns',
+        '127.0.1.1'       => 'Hosts.lns'
+      }.each do |line,lens|
+        it "validates a single argument for #{lens}" do
+          pp = <<-EOS
+          $line = "#{line}"
+          $lens = "#{lens}"
+          validate_augeas($line, $lens)
+          EOS
+
+          apply_manifest(pp, :expect_failures => true)
+        end
+      end
+    end
+    context 'garbage inputs' do
+      it 'raises an error on invalid inputs'
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a single argument' do
+      pp = <<-EOS
+      $one = true
+      validate_bool($one)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates an multiple arguments' do
+      pp = <<-EOS
+      $one = true
+      $two = false
+      validate_bool($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates a non-bool' do
+      {
+        %{validate_bool('true')}  => "String",
+        %{validate_bool('false')} => "String",
+        %{validate_bool([true])}  => "Array",
+        %{validate_bool(undef)}   => "String",
+      }.each do |pp,type|
+        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_cmd_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_cmd_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_cmd_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,52 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a true command' do
+      pp = <<-EOS
+      $one = 'foo'
+      if $::osfamily == 'windows' {
+        $two = 'echo' #shell built-in
+      } else {
+        $two = '/bin/echo'
+      }
+      validate_cmd($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates a fail command' do
+      pp = <<-EOS
+      $one = 'foo'
+      if $::osfamily == 'windows' {
+        $two = 'C:/aoeu'
+      } else {
+        $two = '/bin/aoeu'
+      }
+      validate_cmd($one,$two)
+      EOS
+
+      apply_manifest(pp, :expect_failures => true)
+    end
+    it 'validates a fail command with a custom error message' do
+      pp = <<-EOS
+      $one = 'foo'
+      if $::osfamily == 'windows' {
+        $two = 'C:/aoeu'
+      } else {
+        $two = '/bin/aoeu'
+      }
+      validate_cmd($one,$two,"aoeu is dvorak")
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |output|
+        expect(output.stderr).to match(/aoeu is dvorak/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+    it 'handles improper argument types'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a single argument' do
+      pp = <<-EOS
+      $one = { 'a' => 1 }
+      validate_hash($one)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates an multiple arguments' do
+      pp = <<-EOS
+      $one = { 'a' => 1 }
+      $two = { 'b' => 2 }
+      validate_hash($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates a non-hash' do
+      {
+        %{validate_hash('{ "not" => "hash" }')} => "String",
+        %{validate_hash('string')}              => "String",
+        %{validate_hash(["array"])}             => "Array",
+        %{validate_hash(undef)}                 => "String",
+      }.each do |pp,type|
+        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,31 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a single argument' do
+      pp = <<-EOS
+      $one = '1.2.3.4'
+      validate_ipv4_address($one)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates an multiple arguments' do
+      pp = <<-EOS
+      $one = '1.2.3.4'
+      $two = '5.6.7.8'
+      validate_ipv4_address($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+    it 'handles ipv6 addresses'
+    it 'handles non-ipv4 strings'
+    it 'handles numbers'
+    it 'handles no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,31 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a single argument' do
+      pp = <<-EOS
+      $one = '3ffe:0505:0002::'
+      validate_ipv6_address($one)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates an multiple arguments' do
+      pp = <<-EOS
+      $one = '3ffe:0505:0002::'
+      $two = '3ffe:0505:0001::'
+      validate_ipv6_address($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+    it 'handles ipv6 addresses'
+    it 'handles non-ipv6 strings'
+    it 'handles numbers'
+    it 'handles no arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_re_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_re_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_re_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,47 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_re function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a string' do
+      pp = <<-EOS
+      $one = 'one'
+      $two = '^one$'
+      validate_re($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates an array' do
+      pp = <<-EOS
+      $one = 'one'
+      $two = ['^one$', '^two']
+      validate_re($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates a failed array' do
+      pp = <<-EOS
+      $one = 'one'
+      $two = ['^two$', '^three']
+      validate_re($one,$two)
+      EOS
+
+      apply_manifest(pp, :expect_failures => true)
+    end
+    it 'validates a failed array with a custom error message' do
+      pp = <<-EOS
+      $one = '3.4.3'
+      $two = '^2.7'
+      validate_re($one,$two,"The $puppetversion fact does not match 2.7")
+      EOS
+
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/does not match/)
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+    it 'handles improper argument types'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_slength_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_slength_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_slength_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,72 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_slength function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a single string max' do
+      pp = <<-EOS
+      $one = 'discombobulate'
+      $two = 17
+      validate_slength($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates multiple string maxes' do
+      pp = <<-EOS
+      $one = ['discombobulate', 'moo']
+      $two = 17
+      validate_slength($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates min/max of  strings in array' do
+      pp = <<-EOS
+      $one = ['discombobulate', 'moo']
+      $two = 17
+      $three = 3
+      validate_slength($one,$two,$three)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates a single string max of incorrect length' do
+      pp = <<-EOS
+      $one = 'discombobulate'
+      $two = 1
+      validate_slength($one,$two)
+      EOS
+
+      apply_manifest(pp, :expect_failures => true)
+    end
+    it 'validates multiple string maxes of incorrect length' do
+      pp = <<-EOS
+      $one = ['discombobulate', 'moo']
+      $two = 3
+      validate_slength($one,$two)
+      EOS
+
+      apply_manifest(pp, :expect_failures => true)
+    end
+    it 'validates multiple strings min/maxes of incorrect length' do
+      pp = <<-EOS
+      $one = ['discombobulate', 'moo']
+      $two = 17
+      $three = 10
+      validate_slength($one,$two,$three)
+      EOS
+
+      apply_manifest(pp, :expect_failures => true)
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+    it 'handles improper first argument type'
+    it 'handles non-strings in array of first argument'
+    it 'handles improper second argument type'
+    it 'handles improper third argument type'
+    it 'handles negative ranges'
+    it 'handles improper ranges'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_string_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/validate_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,36 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'validates a single argument' do
+      pp = <<-EOS
+      $one = 'string'
+      validate_string($one)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates an multiple arguments' do
+      pp = <<-EOS
+      $one = 'string'
+      $two = 'also string'
+      validate_string($one,$two)
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+    it 'validates a non-string' do
+      {
+        %{validate_string({ 'a' => 'hash' })} => "Hash",
+        %{validate_string(['array'])}         => "Array",
+        %{validate_string(false)}             => "FalseClass",
+      }.each do |pp,type|
+        expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/values_at_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/values_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/values_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,73 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'values_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'returns a specific value' do
+      pp = <<-EOS
+      $one = ['a','b','c','d','e']
+      $two = 1
+      $output = values_at($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b"\]/)
+    end
+    it 'returns a specific negative index value' do
+      pending("negative numbers don't work")
+      pp = <<-EOS
+      $one = ['a','b','c','d','e']
+      $two = -1
+      $output = values_at($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["e"\]/)
+    end
+    it 'returns a range of values' do
+      pp = <<-EOS
+      $one = ['a','b','c','d','e']
+      $two = "1-3"
+      $output = values_at($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d"\]/)
+    end
+    it 'returns a negative specific value and range of values' do
+      pp = <<-EOS
+      $one = ['a','b','c','d','e']
+      $two = ["1-3",0]
+      $output = values_at($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["b", "c", "d", "a"\]/)
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments' do
+      pp = <<-EOS
+      $one = ['a','b','c','d','e']
+      $output = values_at($one)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/)
+    end
+    it 'handles non-indicies arguments' do
+      pp = <<-EOS
+      $one = ['a','b','c','d','e']
+      $two = []
+      $output = values_at($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/at least one positive index/)
+    end
+
+    it 'detects index ranges smaller than the start range'
+    it 'handles index ranges larger than array'
+    it 'handles non-integer indicies'
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,35 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'returns an array of values' do
+      pp = <<-EOS
+      $arg = {
+        'a' => 1,
+        'b' => 2,
+        'c' => 3,
+      }
+      $output = values($arg)
+      notice(inline_template('<%= @output.sort.inspect %>'))
+      EOS
+      if is_future_parser_enabled?
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
+      else
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
+      end
+
+    end
+  end
+  describe 'failure' do
+    it 'handles non-hash arguments' do
+      pp = <<-EOS
+      $arg = "foo"
+      $output = values($arg)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires hash/)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/acceptance/zip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/acceptance/zip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/acceptance/zip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,86 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+require 'puppet'
+
+describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    it 'zips two arrays of numbers together' do
+      pp = <<-EOS
+      $one = [1,2,3,4]
+      $two = [5,6,7,8]
+      $output = zip($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+      if is_future_parser_enabled?
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/)
+      else
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/)
+      end
+    end
+    it 'zips two arrays of numbers & bools together' do
+      pp = <<-EOS
+      $one = [1,2,"three",4]
+      $two = [true,true,false,false]
+      $output = zip($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+      if is_future_parser_enabled?
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/)
+      else
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/)
+      end
+    end
+    it 'zips two arrays of numbers together and flattens them' do
+      # XXX This only tests the argument `true`, even though the following are valid:
+      # 1 t y true yes
+      # 0 f n false no
+      # undef undefined
+      pp = <<-EOS
+      $one = [1,2,3,4]
+      $two = [5,6,7,8]
+      $output = zip($one,$two,true)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+      if is_future_parser_enabled?
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/)
+      else
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/)
+      end
+    end
+    it 'handles unmatched length' do
+      # XXX Is this expected behavior?
+      pp = <<-EOS
+      $one = [1,2]
+      $two = [5,6,7,8]
+      $output = zip($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+      if is_future_parser_enabled?
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/)
+      else
+        expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/)
+      end
+    end
+  end
+  describe 'failure' do
+    it 'handles improper number of arguments' do
+      pp = <<-EOS
+      $one = [1,2]
+      $output = zip($one)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/)
+    end
+    it 'handles improper argument types' do
+      pp = <<-EOS
+      $one = "a string"
+      $two = [5,6,7,8]
+      $output = zip($one,$two)
+      notice(inline_template('<%= @output.inspect %>'))
+      EOS
+
+      expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires array/)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/abs_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/abs_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/abs_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe 'abs' do
+  it { is_expected.not_to eq(nil) }
+
+  describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it {
+      pending("Current implementation ignores parameters after the first.")
+      is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    }
+  end
+
+  describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params([]).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params({}).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) }
+  end
+
+  it { is_expected.to run.with_params(-34).and_return(34) }
+  it { is_expected.to run.with_params("-34").and_return(34) }
+  it { is_expected.to run.with_params(34).and_return(34) }
+  it { is_expected.to run.with_params("34").and_return(34) }
+  it { is_expected.to run.with_params(-34.5).and_return(34.5) }
+  it { is_expected.to run.with_params("-34.5").and_return(34.5) }
+  it { is_expected.to run.with_params(34.5).and_return(34.5) }
+  it { is_expected.to run.with_params("34.5").and_return(34.5) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/any2array_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/any2array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/any2array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe "any2array" do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_return([]) }
+  it { is_expected.to run.with_params(true).and_return([true]) }
+  it { is_expected.to run.with_params('one').and_return(['one']) }
+  it { is_expected.to run.with_params('one', 'two').and_return(['one', 'two']) }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two']).and_return(['one', 'two']) }
+  it { is_expected.to run.with_params({}).and_return([]) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/assert_private_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/assert_private_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/assert_private_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe 'assert_private' do
+  context 'when called from inside module' do
+    it "should not fail" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('foo')
+      expect {
+        subject.call []
+      }.not_to raise_error
+    end
+  end
+
+  context "with an explicit failure message" do
+    it "prints the failure message on error" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
+      expect {
+        subject.call ['failure message!']
+      }.to raise_error Puppet::ParseError, /failure message!/
+    end
+  end
+
+  context "when called from private class" do
+    it "should fail with a class error message" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
+      scope.source.expects(:name).returns('foo::baz')
+      scope.source.expects(:type).returns('hostclass')
+      expect {
+        subject.call []
+      }.to raise_error Puppet::ParseError, /Class foo::baz is private/
+    end
+  end
+
+  context "when called from private definition" do
+    it "should fail with a class error message" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
+      scope.source.expects(:name).returns('foo::baz')
+      scope.source.expects(:type).returns('definition')
+      expect {
+        subject.call []
+      }.to raise_error Puppet::ParseError, /Definition foo::baz is private/
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/base64_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/base64_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/base64_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe 'base64' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params("one").and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /first argument must be one of/) }
+  it { is_expected.to run.with_params("encode", ["two"]).and_raise_error(Puppet::ParseError, /second argument must be a string/) }
+  it { is_expected.to run.with_params("encode", 2).and_raise_error(Puppet::ParseError, /second argument must be a string/) }
+  it { is_expected.to run.with_params("encode", "thestring", "three").and_raise_error(Puppet::ParseError, /third argument must be one of/) }
+  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n", "strict").and_raise_error(ArgumentError) }
+
+  it { is_expected.to run.with_params("encode", "thestring").and_return("dGhlc3RyaW5n\n") }
+  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n").and_return("thestring") }
+  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n").and_return("thestring") }
+
+  it { is_expected.to run.with_params("encode", "thestring", "default").and_return("dGhlc3RyaW5n\n") }
+  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n", "default").and_return("thestring") }
+  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n\n", "default").and_return("thestring") }
+
+  it { is_expected.to run.with_params("encode", "thestring", "strict").and_return("dGhlc3RyaW5n") }
+  it { is_expected.to run.with_params("decode", "dGhlc3RyaW5n", "strict").and_return("thestring") }
+
+  it { is_expected.to run.with_params("encode", "a very long string that will cause the base64 encoder to produce output with multiple lines").and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n") }
+  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0\nIGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5l\ncw==\n").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
+  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
+
+  it { is_expected.to run.with_params("encode", "a very long string that will cause the base64 encoder to produce output with multiple lines", "strict").and_return("YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==") }
+  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
+  it { is_expected.to run.with_params("decode", "YSB2ZXJ5IGxvbmcgc3RyaW5nIHRoYXQgd2lsbCBjYXVzZSB0aGUgYmFzZTY0IGVuY29kZXIgdG8gcHJvZHVjZSBvdXRwdXQgd2l0aCBtdWx0aXBsZSBsaW5lcw==", "strict").and_return("a very long string that will cause the base64 encoder to produce output with multiple lines") }
+
+  it { is_expected.to run.with_params("encode", "https://www.google.com.tw/?gws_rd=ssl#q=hello+world", "urlsafe").and_return("aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk") }
+  it { is_expected.to run.with_params("decode", "aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS50dy8_Z3dzX3JkPXNzbCNxPWhlbGxvK3dvcmxk", "urlsafe").and_return("https://www.google.com.tw/?gws_rd=ssl#q=hello+world") }
+
+  it { is_expected.to run.with_params("encode", "https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add", "urlsafe").and_return("aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=") }
+  it { is_expected.to run.with_params("decode", "aHR0cHM6Ly9naXRodWIuY29tL3B1cHBldGxhYnMvcHVwcGV0bGFicy1zdGRsaWIvcHVsbHM_dXRmOD0lRTIlOUMlOTMmcT1pcyUzQXByK2lzJTNBb3BlbitBZGQ=", "urlsafe").and_return("https://github.com/puppetlabs/puppetlabs-stdlib/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+Add") }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/basename_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/basename_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/basename_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe 'basename' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('file.ext') }
+  it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('file.ext') }
+  it { is_expected.to run.with_params('/path/to/a/file.ext', '.ext').and_return('file') }
+  it { is_expected.to run.with_params('relative_path/to/a/file.ext', '.ext').and_return('file') }
+  it { is_expected.to run.with_params('scheme:///path/to/a/file.ext').and_return('file.ext') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/bool2num_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/bool2num_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/bool2num_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe 'bool2num' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+
+  [ true, 'true', AlsoString.new('true') ].each do |truthy|
+    it { is_expected.to run.with_params(truthy).and_return(1) }
+  end
+
+  [ false, 'false', AlsoString.new('false') ].each do |falsey|
+    it { is_expected.to run.with_params(falsey).and_return(0) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/bool2str_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/bool2str_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/bool2str_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe 'bool2str' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  [ 'true', 'false', nil, :undef, ''].each do |invalid|
+    it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError) }
+  end
+  it { is_expected.to run.with_params(true, 'yes', 'no', 'maybe').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(true, 'maybe').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(true, 0, 1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(true).and_return("true") }
+  it { is_expected.to run.with_params(false).and_return("false") }
+  it { is_expected.to run.with_params(true, 'yes', 'no').and_return("yes") }
+  it { is_expected.to run.with_params(false, 'yes', 'no').and_return("no") }
+
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/camelcase_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/camelcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/camelcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe 'camelcase' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params("abc").and_return("Abc") }
+  it { is_expected.to run.with_params("aa_bb_cc").and_return("AaBbCc") }
+  it { is_expected.to run.with_params("_aa__bb__cc_").and_return("AaBbCc") }
+  it { is_expected.to run.with_params("100").and_return("100") }
+  it { is_expected.to run.with_params("1_00").and_return("100") }
+  it { is_expected.to run.with_params("_").and_return("") }
+  it { is_expected.to run.with_params("").and_return("") }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(["abc", "aa_bb_cc"]).and_return(["Abc", "AaBbCc"]) }
+  it { is_expected.to run.with_params(["abc", 1, "aa_bb_cc"]).and_return(["Abc", 1, "AaBbCc"]) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/capitalize_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/capitalize_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/capitalize_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'capitalize' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params("one").and_return("One") }
+  it { is_expected.to run.with_params("one two").and_return("One two") }
+  it { is_expected.to run.with_params("ONE TWO").and_return("One two") }
+
+  it { is_expected.to run.with_params(AlsoString.new("one")).and_return("One") }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(["one", "two"]).and_return(["One", "Two"]) }
+  it { is_expected.to run.with_params(["one", 1, "two"]).and_return(["One", 1, "Two"]) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/ceiling_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/ceiling_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/ceiling_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe 'ceiling' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params("foo").and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(34).and_return(34) }
+  it { is_expected.to run.with_params(-34).and_return(-34) }
+  it { is_expected.to run.with_params(33.1).and_return(34) }
+  it { is_expected.to run.with_params(-33.1).and_return(-33) }
+end
+
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/chomp_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/chomp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/chomp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe 'chomp' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params("a", "b").and_raise_error(Puppet::ParseError)
+  }
+  it { is_expected.to run.with_params("one").and_return("one") }
+  it { is_expected.to run.with_params("one\n").and_return("one") }
+  it { is_expected.to run.with_params("one\n\n").and_return("one\n") }
+  it { is_expected.to run.with_params(["one\n", "two", "three\n"]).and_return(["one", "two", "three"]) }
+
+  it { is_expected.to run.with_params(AlsoString.new("one")).and_return("one") }
+  it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") }
+  it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") }
+  it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "two", "three"]) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/chop_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/chop_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/chop_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe 'chop' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params("a", "b").and_raise_error(Puppet::ParseError)
+  }
+  it { is_expected.to run.with_params("one").and_return("on") }
+  it { is_expected.to run.with_params("one\n").and_return("one") }
+  it { is_expected.to run.with_params("one\n\n").and_return("one\n") }
+  it { is_expected.to run.with_params(["one\n", "two", "three\n"]).and_return(["one", "tw", "three"]) }
+
+  it { is_expected.to run.with_params(AlsoString.new("one")).and_return("on") }
+  it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") }
+  it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") }
+  it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new("two"), "three\n"]).and_return(["one", "tw", "three"]) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/clamp_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/clamp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/clamp_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe 'clamp' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(12, 88, 71, 190).and_raise_error(Puppet::ParseError, /Wrong number of arguments, need three to clamp/) }
+  it { is_expected.to run.with_params('12string', 88, 15).and_raise_error(Puppet::ParseError, /Required explicit numeric/) }
+  it { is_expected.to run.with_params(1, 2, {'a' => 55}).and_raise_error(Puppet::ParseError, /The Hash type is not allowed/) }
+  it { is_expected.to run.with_params('24', [575, 187]).and_return(187) }
+  it { is_expected.to run.with_params([4, 3, '99']).and_return(4) }
+  it { is_expected.to run.with_params(16, 750, 88).and_return(88) }
+  it { is_expected.to run.with_params([3, 873], 73).and_return(73) }
+  it { is_expected.to run.with_params([4], 8, 75).and_return(8) }
+  it { is_expected.to run.with_params([6], [31], 9911).and_return(31) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/concat_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/concat_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/concat_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe 'concat' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([1], [2], [3]).and_return([1, 2, 3]) }
+  it { is_expected.to run.with_params(['1','2','3'],['4','5','6']).and_return(['1','2','3','4','5','6']) }
+  it { is_expected.to run.with_params(['1','2','3'],'4').and_return(['1','2','3','4']) }
+  it { is_expected.to run.with_params(['1','2','3'],[['4','5'],'6']).and_return(['1','2','3',['4','5'],'6']) }
+  it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) }
+  it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) }
+  it { is_expected.to run.with_params([{"a" => "b"}], {"c" => "d", "e" => "f"}).and_return([{"a" => "b"}, {"c" => "d", "e" => "f"}]) }
+
+  it "should leave the original array intact" do
+    argument1 = ['1','2','3']
+    original1 = argument1.dup
+    argument2 = ['4','5','6']
+    original2 = argument2.dup
+    result = subject.call([argument1,argument2])
+    expect(argument1).to eq(original1)
+    expect(argument2).to eq(original2)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/convert_base_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/convert_base_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/convert_base_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'convert_base' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params("asdf").and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params("asdf","moo","cow").and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params(["1"],"2").and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) }
+  it { is_expected.to run.with_params("1",["2"]).and_raise_error(Puppet::ParseError, /argument must be either a string or an integer/) }
+  it { is_expected.to run.with_params("1",1).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) }
+  it { is_expected.to run.with_params("1",37).and_raise_error(Puppet::ParseError, /base must be at least 2 and must not be greater than 36/) }
+
+  it "should raise a ParseError if argument 1 is a string that does not correspond to an integer in base 10" do
+    is_expected.to run.with_params("ten",6).and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/)
+  end
+
+  it "should raise a ParseError if argument 2 is a string and does not correspond to an integer in base 10" do
+    is_expected.to run.with_params(100,"hex").and_raise_error(Puppet::ParseError, /argument must be an integer or a string corresponding to an integer in base 10/)
+  end
+
+  it { is_expected.to run.with_params("11",'16').and_return('b') }
+  it { is_expected.to run.with_params("35",'36').and_return('z') }
+  it { is_expected.to run.with_params(5, 2).and_return('101') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/count_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/count_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/count_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe 'count' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params("one").and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params("one", "two").and_return(1) }
+  it {
+    pending("should actually be like this, and not like above")
+    is_expected.to run.with_params("one", "two").and_raise_error(ArgumentError)
+  }
+  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(ArgumentError) }
+  it { is_expected.to run.with_params(["one", "two", "three"]).and_return(3) }
+  it { is_expected.to run.with_params(["one", "two", "two"], "two").and_return(2) }
+  it { is_expected.to run.with_params(["one", nil, "two"]).and_return(2) }
+  it { is_expected.to run.with_params(["one", "", "two"]).and_return(2) }
+  it { is_expected.to run.with_params(["one", :undef, "two"]).and_return(2) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/deep_merge_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/deep_merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/deep_merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,55 @@
+require 'spec_helper'
+
+describe 'deep_merge' do
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, /unexpected argument type String/) }
+  it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) }
+  it { is_expected.to run.with_params({}, '').and_return({}) }
+  it { is_expected.to run.with_params({}, {}).and_return({}) }
+  it { is_expected.to run.with_params({}, {}, {}).and_return({}) }
+  it { is_expected.to run.with_params({}, {}, {}, {}).and_return({}) }
+  it { is_expected.to run.with_params({'key' => 'value'}, '').and_return({'key' => 'value'}) }
+  it { is_expected.to run.with_params({'key1' => 'value1'}, {'key2' => 'value2' }).and_return({'key1' => 'value1', 'key2' => 'value2'}) }
+
+  describe 'when arguments have key collisions' do
+    it 'should prefer values from the last hash' do
+      is_expected.to run \
+        .with_params(
+          {'key1' => 'value1', 'key2' => 'value2' },
+          {'key2' => 'replacement_value', 'key3' => 'value3'}) \
+        .and_return(
+          {'key1' => 'value1', 'key2' => 'replacement_value', 'key3' => 'value3'})
+    end
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1'}, {'key1' => 'value2'}, {'key1' => 'value3'}) \
+      .and_return({'key1' => 'value3' })
+    }
+  end
+
+  describe 'when arguments have subhashes' do
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1'}, {'key2' => 'value2', 'key3' => {'subkey1' => 'value4'}}) \
+      .and_return( {'key1' => 'value1', 'key2' => 'value2', 'key3' => {'subkey1' => 'value4'}})
+    }
+    it { is_expected.to run \
+      .with_params({'key1' => {'subkey1' => 'value1'}}, {'key1' => {'subkey2' => 'value2'}}) \
+      .and_return( {'key1' => {'subkey1' => 'value1', 'subkey2' => 'value2'}})
+    }
+    it { is_expected.to run \
+      .with_params({'key1' => {'subkey1' => {'subsubkey1' => 'value1'}}}, {'key1' => {'subkey1' => {'subsubkey1' => 'value2'}}}) \
+      .and_return( {'key1' => {'subkey1' => {'subsubkey1' => 'value2'}}})
+    }
+  end
+
+  it 'should not change the original hashes' do
+    argument1 = { 'key1' => 'value1' }
+    original1 = argument1.dup
+    argument2 = { 'key2' => 'value2' }
+    original2 = argument2.dup
+
+    subject.call([argument1, argument2])
+    expect(argument1).to eq(original1)
+    expect(argument2).to eq(original2)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/defined_with_params_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/defined_with_params_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/defined_with_params_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe 'defined_with_params' do
+  describe 'when no resource is specified' do
+    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+  end
+  describe 'when compared against a resource with no attributes' do
+    let :pre_condition do
+      'user { "dan": }'
+    end
+    it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
+    it { is_expected.to run.with_params('User[bob]', {}).and_return(false) }
+    it { is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) }
+  end
+
+  describe 'when compared against a resource with attributes' do
+    let :pre_condition do
+      'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
+    end
+    it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
+    it { is_expected.to run.with_params('User[dan]', '').and_return(true) }
+    it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}).and_return(true) }
+    it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present', 'managehome' => false}).and_return(true) }
+    it { is_expected.to run.with_params('User[dan]', {'ensure' => 'absent', 'managehome' => false}).and_return(false) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_at_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe 'delete_at' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(['one'], 'two').and_raise_error(Puppet::ParseError) }
+  it {
+    pending("Current implementation ignores parameters after the first two.")
+    is_expected.to run.with_params(['one'], 0, 1).and_raise_error(Puppet::ParseError)
+  }
+
+  describe 'argument validation' do
+    it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError) }
+  end
+
+  it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) }
+  it { is_expected.to run.with_params([0, 1, 2], -1).and_return([0, 1]) }
+  it { is_expected.to run.with_params([0, 1, 2], -4).and_return([0, 1, 2]) }
+
+  it "should leave the original array intact" do
+    argument = [1, 2, 3]
+    original = argument.dup
+    result = subject.call([argument,2])
+    expect(argument).to eq(original)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,68 @@
+require 'spec_helper'
+
+describe 'delete' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
+
+  describe 'deleting from an array' do
+    it { is_expected.to run.with_params([], '').and_return([]) }
+    it { is_expected.to run.with_params([], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['two'], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) }
+    it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three', 'two'], ['one', 'two']).and_return(['three']) }
+  end
+
+  describe 'deleting from a string' do
+    it { is_expected.to run.with_params('', '').and_return('') }
+    it { is_expected.to run.with_params('bar', '').and_return('bar') }
+    it { is_expected.to run.with_params('', 'bar').and_return('') }
+    it { is_expected.to run.with_params('bar', 'bar').and_return('') }
+    it { is_expected.to run.with_params('barbar', 'bar').and_return('') }
+    it { is_expected.to run.with_params('barfoobar', 'bar').and_return('foo') }
+    it { is_expected.to run.with_params('foobarbabarz', 'bar').and_return('foobaz') }
+    it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') }
+    # this is so sick
+    it { is_expected.to run.with_params('barfoobar', ['barbar', 'foo']).and_return('barbar') }
+    it { is_expected.to run.with_params('barfoobar', ['foo', 'barbar']).and_return('') }
+  end
+
+  describe 'deleting from an array' do
+    it { is_expected.to run.with_params({}, '').and_return({}) }
+    it { is_expected.to run.with_params({}, 'key').and_return({}) }
+    it { is_expected.to run.with_params({'key' => 'value'}, 'key').and_return({}) }
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, 'key2') \
+      .and_return( {'key1' => 'value1', 'key3' => 'value3'})
+    }
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \
+      .and_return( {'key3' => 'value3'})
+    }
+  end
+
+  it "should leave the original array intact" do
+    argument1 = ['one','two','three']
+    original1 = argument1.dup
+    result = subject.call([argument1,'two'])
+    expect(argument1).to eq(original1)
+  end
+  it "should leave the original string intact" do
+    argument1 = 'onetwothree'
+    original1 = argument1.dup
+    result = subject.call([argument1,'two'])
+    expect(argument1).to eq(original1)
+  end
+  it "should leave the original hash intact" do
+    argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}
+    original1 = argument1.dup
+    result = subject.call([argument1,'key2'])
+    expect(argument1).to eq(original1)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_undef_values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_undef_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_undef_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,56 @@
+require 'spec_helper'
+
+describe 'delete_undef_values' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
+
+  describe 'when deleting from an array' do
+    [ :undef, '', nil ].each do |undef_value|
+      describe "when undef is represented by #{undef_value.inspect}" do
+        before do
+          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
+          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil
+        end
+        it { is_expected.to run.with_params([undef_value]).and_return([]) }
+        it { is_expected.to run.with_params(['one',undef_value,'two','three']).and_return(['one','two','three']) }
+      end
+
+      it "should leave the original argument intact" do
+        argument = ['one',undef_value,'two']
+        original = argument.dup
+        result = subject.call([argument,2])
+        expect(argument).to eq(original)
+      end
+    end
+
+    it { is_expected.to run.with_params(['undef']).and_return(['undef']) }
+  end
+
+  describe 'when deleting from a hash' do
+    [ :undef, '', nil ].each do |undef_value|
+      describe "when undef is represented by #{undef_value.inspect}" do
+        before do
+          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == ''
+          pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value == nil
+        end
+        it { is_expected.to run.with_params({'key' => undef_value}).and_return({}) }
+        it { is_expected.to run \
+          .with_params({'key1' => 'value1', 'undef_key' => undef_value, 'key2' => 'value2'}) \
+          .and_return({'key1' => 'value1', 'key2' => 'value2'})
+        }
+      end
+
+      it "should leave the original argument intact" do
+        argument = { 'key1' => 'value1', 'key2' => undef_value }
+        original = argument.dup
+        result = subject.call([argument,2])
+        expect(argument).to eq(original)
+      end
+    end
+
+    it { is_expected.to run.with_params({'key' => 'undef'}).and_return({'key' => 'undef'}) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/delete_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe 'delete_values' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
+  describe 'when the first argument is not a hash' do
+    it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) }
+    it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError) }
+    it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError) }
+  end
+
+  describe 'when deleting from a hash' do
+    it { is_expected.to run.with_params({}, 'value').and_return({}) }
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1'}, 'non-existing value') \
+      .and_return({'key1' => 'value1'})
+    }
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1', 'key2' => 'value to delete'}, 'value to delete') \
+      .and_return({'key1' => 'value1'})
+    }
+    it { is_expected.to run \
+      .with_params({'key1' => 'value1', 'key2' => 'value to delete', 'key3' => 'value to delete'}, 'value to delete') \
+      .and_return({'key1' => 'value1'})
+    }
+  end
+
+  it "should leave the original argument intact" do
+    argument = { 'key1' => 'value1', 'key2' => 'value2' }
+    original = argument.dup
+    result = subject.call([argument, 'value2'])
+    expect(argument).to eq(original)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/difference_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/difference_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/difference_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'difference' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], []).and_return([]) }
+  it { is_expected.to run.with_params([], ['one']).and_return([]) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return([]) }
+  it { is_expected.to run.with_params(['one'], []).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['one']) }
+  it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3']) end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/dig_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/dig_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/dig_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe 'dig' do
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('bad', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params({}, 'bad').and_raise_error(Puppet::ParseError) }
+
+  it { is_expected.to run.with_params({}, []).and_return({}) }
+  it { is_expected.to run.with_params({"a" => "b"}, ["a"]).and_return("b") }
+  it { is_expected.to run.with_params({"a" => {"b" => "c"}}, ["a", "b"]).and_return("c") }
+  it { is_expected.to run.with_params({}, ["a", "b"], "d").and_return("d") }
+  it { is_expected.to run.with_params({"a" => false}, ["a"]).and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/dirname_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/dirname_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/dirname_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe 'dirname' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('/path/to/a') }
+  it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('relative_path/to/a') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/dos2unix_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/dos2unix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/dos2unix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe 'dos2unix' do
+  context 'Checking parameter validity' do
+    it { is_expected.not_to eq(nil) }
+    it do
+      is_expected.to run.with_params.and_raise_error(ArgumentError, /Wrong number of arguments/)
+    end
+    it do
+      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/)
+    end
+    it do
+      is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError)
+    end
+  end
+
+  context 'Converting from dos to unix format' do
+    sample_text    = "Hello\r\nWorld\r\n"
+    desired_output = "Hello\nWorld\n"
+
+    it 'should output unix format' do
+      should run.with_params(sample_text).and_return(desired_output)
+    end
+  end
+
+  context 'Converting from unix to unix format' do
+    sample_text    = "Hello\nWorld\n"
+    desired_output = "Hello\nWorld\n"
+
+    it 'should output unix format' do
+      should run.with_params(sample_text).and_return(desired_output)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/downcase_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/downcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/downcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'downcase' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params("abc").and_return("abc") }
+  it { is_expected.to run.with_params("Abc").and_return("abc") }
+  it { is_expected.to run.with_params("ABC").and_return("abc") }
+
+  it { is_expected.to run.with_params(AlsoString.new("ABC")).and_return("abc") }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(["ONE", "TWO"]).and_return(["one", "two"]) }
+  it { is_expected.to run.with_params(["One", 1, "Two"]).and_return(["one", 1, "two"]) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/empty_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/empty_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/empty_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'empty' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError)
+  }
+  it { is_expected.to run.with_params(0).and_return(false) }
+  it { is_expected.to run.with_params('').and_return(true) }
+  it { is_expected.to run.with_params('one').and_return(false) }
+
+  it { is_expected.to run.with_params(AlsoString.new('')).and_return(true) }
+  it { is_expected.to run.with_params(AlsoString.new('one')).and_return(false) }
+
+  it { is_expected.to run.with_params([]).and_return(true) }
+  it { is_expected.to run.with_params(['one']).and_return(false) }
+
+  it { is_expected.to run.with_params({}).and_return(true) }
+  it { is_expected.to run.with_params({'key' => 'value'}).and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/ensure_packages_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/ensure_packages_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/ensure_packages_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe 'ensure_packages' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it {
+    pending("should not accept numbers as arguments")
+    is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError)
+  }
+  it {
+    pending("should not accept numbers as arguments")
+    is_expected.to run.with_params(["packagename", 1]).and_raise_error(Puppet::ParseError)
+  }
+  it { is_expected.to run.with_params("packagename") }
+  it { is_expected.to run.with_params(["packagename1", "packagename2"]) }
+
+  context 'given a catalog with "package { puppet: ensure => absent }"' do
+    let(:pre_condition) { 'package { puppet: ensure => absent }' }
+
+    describe 'after running ensure_package("facter")' do
+      before { subject.call(['facter']) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('absent') }
+      it { expect(lambda { catalogue }).to contain_package('facter').with_ensure('present') }
+    end
+
+    describe 'after running ensure_package("facter", { "provider" => "gem" })' do
+      before { subject.call(['facter', { "provider" => "gem" }]) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_package('puppet').with_ensure('absent').without_provider() }
+      it { expect(lambda { catalogue }).to contain_package('facter').with_ensure('present').with_provider("gem") }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/ensure_resource_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/ensure_resource_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/ensure_resource_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,55 @@
+require 'spec_helper'
+
+describe 'ensure_resource' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a type/) }
+  it { is_expected.to run.with_params('type').and_raise_error(ArgumentError, /Must specify a title/) }
+  it { is_expected.to run.with_params('type', 'title', {}, 'extras').and_raise_error(Puppet::ParseError) }
+  it {
+    pending("should not accept numbers as arguments")
+    is_expected.to run.with_params(1,2,3).and_raise_error(Puppet::ParseError)
+  }
+
+  context 'given a catalog with "user { username1: ensure => present }"' do
+    let(:pre_condition) { 'user { username1: ensure => present }' }
+
+    describe 'after running ensure_resource("user", "username1", {})' do
+      before { subject.call(['User', 'username1', {}]) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
+    end
+
+    describe 'after running ensure_resource("user", "username2", {})' do
+      before { subject.call(['User', 'username2', {}]) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
+      it { expect(lambda { catalogue }).to contain_user('username2').without_ensure }
+    end
+
+    describe 'after running ensure_resource("user", ["username1", "username2"], {})' do
+      before { subject.call(['User', ['username1', 'username2'], {}]) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') }
+      it { expect(lambda { catalogue }).to contain_user('username2').without_ensure }
+    end
+
+    describe 'when providing already set params' do
+      let(:params) { { 'ensure' => 'present' } }
+      before { subject.call(['User', ['username2', 'username3'], params]) }
+
+      # this lambda is required due to strangeness within rspec-puppet's expectation handling
+      it { expect(lambda { catalogue }).to contain_user('username1').with(params) }
+      it { expect(lambda { catalogue }).to contain_user('username2').with(params) }
+    end
+
+    context 'when trying to add params' do
+      it { is_expected.to run \
+        .with_params('User', 'username1', { 'ensure' => 'present', 'shell' => true }) \
+        .and_raise_error(Puppet::Resource::Catalog::DuplicateResourceError, /User\[username1\] is already declared/)
+      }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/flatten_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/flatten_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/flatten_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe 'flatten' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(['one']).and_return(['one']) }
+  it { is_expected.to run.with_params([['one']]).and_return(['one']) }
+  it { is_expected.to run.with_params(["a","b","c","d","e","f","g"]).and_return(["a","b","c","d","e","f","g"]) }
+  it { is_expected.to run.with_params([["a","b",["c",["d","e"],"f","g"]]]).and_return(["a","b","c","d","e","f","g"]) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/floor_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/floor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/floor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe 'floor' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params("foo").and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params(34).and_return(34) }
+  it { is_expected.to run.with_params(-34).and_return(-34) }
+  it { is_expected.to run.with_params(33.1).and_return(33) }
+  it { is_expected.to run.with_params(-33.1).and_return(-34) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/fqdn_rand_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,65 @@
+require 'spec_helper'
+
+describe 'fqdn_rand_string' do
+  let(:default_charset) { %r{\A[a-zA-Z0-9]{100}\z} }
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(0).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params(1.5).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params(-10).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params("-10").and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params("string").and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params([]).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params({}).and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, /second argument must be undef or a string/) }
+  it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, /second argument must be undef or a string/) }
+  it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, /second argument must be undef or a string/) }
+  it { is_expected.to run.with_params(100).and_return(default_charset) }
+  it { is_expected.to run.with_params("100").and_return(default_charset) }
+  it { is_expected.to run.with_params(100, nil).and_return(default_charset) }
+  it { is_expected.to run.with_params(100, '').and_return(default_charset) }
+  it { is_expected.to run.with_params(100, 'a').and_return(/\Aa{100}\z/) }
+  it { is_expected.to run.with_params(100, 'ab').and_return(/\A[ab]{100}\z/) }
+
+  it "provides the same 'random' value on subsequent calls for the same host" do
+    expect(fqdn_rand_string(10)).to eql(fqdn_rand_string(10))
+  end
+
+  it "considers the same host and same extra arguments to have the same random sequence" do
+    first_random = fqdn_rand_string(10, :extra_identifier => [1, "same", "host"])
+    second_random = fqdn_rand_string(10, :extra_identifier => [1, "same", "host"])
+
+    expect(first_random).to eql(second_random)
+  end
+
+  it "allows extra arguments to control the random value on a single host" do
+    first_random = fqdn_rand_string(10, :extra_identifier => [1, "different", "host"])
+    second_different_random = fqdn_rand_string(10, :extra_identifier => [2, "different", "host"])
+
+    expect(first_random).not_to eql(second_different_random)
+  end
+
+  it "should return different strings for different hosts" do
+    val1 = fqdn_rand_string(10, :host => "first.host.com")
+    val2 = fqdn_rand_string(10, :host => "second.host.com")
+
+    expect(val1).not_to eql(val2)
+  end
+
+  def fqdn_rand_string(max, args = {})
+    host = args[:host] || '127.0.0.1'
+    charset = args[:charset]
+    extra = args[:extra_identifier] || []
+
+    # workaround not being able to use let(:facts) because some tests need
+    # multiple different hostnames in one context
+    scope.stubs(:lookupvar).with("::fqdn", {}).returns(host)
+
+    function_args = [max]
+    if args.has_key?(:charset) or !extra.empty?
+      function_args << charset
+    end
+    function_args += extra
+    scope.function_fqdn_rand_string(function_args)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/fqdn_rotate_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/fqdn_rotate_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/fqdn_rotate_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,75 @@
+require 'spec_helper'
+
+describe 'fqdn_rotate' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(0).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params('').and_return('') }
+  it { is_expected.to run.with_params('a').and_return('a') }
+
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(['a']).and_return(['a']) }
+
+  it "should rotate a string and the result should be the same size" do
+    expect(fqdn_rotate("asdf").size).to eq(4)
+  end
+
+  it "should rotate a string to give the same results for one host" do
+    val1 = fqdn_rotate("abcdefg", :host => 'one')
+    val2 = fqdn_rotate("abcdefg", :host => 'one')
+    expect(val1).to eq(val2)
+  end
+
+  it "allows extra arguments to control the random rotation on a single host" do
+    val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "different", "host"])
+    val2 = fqdn_rotate("abcdefg", :extra_identifier => [2, "different", "host"])
+    expect(val1).not_to eq(val2)
+  end
+
+  it "considers the same host and same extra arguments to have the same random rotation" do
+    val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"])
+    val2 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"])
+    expect(val1).to eq(val2)
+  end
+
+  it "should rotate a string to give different values on different hosts" do
+    val1 = fqdn_rotate("abcdefg", :host => 'one')
+    val2 = fqdn_rotate("abcdefg", :host => 'two')
+    expect(val1).not_to eq(val2)
+  end
+
+  it "should accept objects which extend String" do
+    result = fqdn_rotate(AlsoString.new('asdf'))
+    expect(result).to eq('dfas')
+  end
+
+  it "should use the Puppet::Util.deterministic_rand function" do
+    if Puppet::Util.respond_to?(:deterministic_rand)
+      Puppet::Util.expects(:deterministic_rand).with(44489829212339698569024999901561968770,4)
+      fqdn_rotate("asdf")
+    else
+      skip 'Puppet::Util#deterministic_rand not available'
+    end
+  end
+
+  it "should not leave the global seed in a deterministic state" do
+    fqdn_rotate("asdf")
+    rand1 = rand()
+    fqdn_rotate("asdf")
+    rand2 = rand()
+    expect(rand1).not_to eql(rand2)
+  end
+
+  def fqdn_rotate(value, args = {})
+    host = args[:host] || '127.0.0.1'
+    extra = args[:extra_identifier] || []
+
+    # workaround not being able to use let(:facts) because some tests need
+    # multiple different hostnames in one context
+    scope.stubs(:lookupvar).with("::fqdn").returns(host)
+
+    function_args = [value] + extra
+    scope.function_fqdn_rotate(function_args)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/get_module_path_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/get_module_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/get_module_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,48 @@
+require 'spec_helper'
+
+describe 'get_module_path' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /Wrong number of arguments, expects one/) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Could not find module/) }
+
+  class StubModule
+    attr_reader :path
+    def initialize(path)
+      @path = path
+    end
+  end
+
+  describe 'when locating a module' do
+    let(:modulepath) { "/tmp/does_not_exist" }
+    let(:path_of_module_foo) { StubModule.new("/tmp/does_not_exist/foo") }
+
+    before(:each) { Puppet[:modulepath] = modulepath }
+
+    context 'in the default environment' do
+      before(:each) { Puppet::Module.expects(:find).with('foo', 'rp_env').returns(path_of_module_foo) }
+
+      it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+
+      context 'when the modulepath is a list' do
+        before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' }
+
+        it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+      end
+    end
+
+    context 'in a non-default default environment' do
+      let(:environment) { 'test' }
+      before(:each) { Puppet::Module.expects(:find).with('foo', 'test').returns(path_of_module_foo) }
+
+      it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+
+      context 'when the modulepath is a list' do
+        before(:each) { Puppet[:modulepath] = modulepath + 'tmp/something_else' }
+
+        it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) }
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/getparam_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/getparam_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/getparam_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe 'getparam' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Must specify a reference/) }
+  it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, /Must specify name of a parameter/) }
+  it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
+  it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
+  it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, /Must specify name of a parameter/) }
+
+  describe 'when compared against a user resource with no params' do
+    let(:pre_condition) { 'user { "one": }' }
+
+    it { is_expected.to run.with_params('User[one]', 'ensure').and_return('') }
+    it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
+    it { is_expected.to run.with_params('User[one]', 'shell').and_return('') }
+  end
+
+  describe 'when compared against a user resource with params' do
+    let(:pre_condition) { 'user { "one": ensure => present, shell => "/bin/sh", managehome => false, }' }
+
+    it { is_expected.to run.with_params('User[one]', 'ensure').and_return('present') }
+    it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
+    it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') }
+    it {
+      pending("both rspec-puppet as well as the function do the wrong thing here.")
+      is_expected.to run.with_params('User[one]', 'managehome').and_return(false)
+    }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/getvar_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/getvar_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/getvar_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'getvar' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  context 'given variables in namespaces' do
+    let(:pre_condition) {
+      <<-'ENDofPUPPETcode'
+      class site::data { $foo = 'baz' }
+      include site::data
+      ENDofPUPPETcode
+    }
+
+    it { is_expected.to run.with_params('site::data::foo').and_return('baz') }
+    it { is_expected.to run.with_params('::site::data::foo').and_return('baz') }
+    it { is_expected.to run.with_params('::site::data::bar').and_return(nil) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/grep_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/grep_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/grep_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'grep' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("grep does not actually check this, and raises NoMethodError instead")
+    is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+  }
+  it {
+    pending("grep does not actually check this, and raises NoMethodError instead")
+    is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+  }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([], 'two').and_return([]) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['two']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['two', 'three']) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/has_interface_with_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/has_interface_with_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/has_interface_with_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,38 @@
+require 'spec_helper'
+
+describe 'has_interface_with' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  # We need to mock out the Facts so we can specify how we expect this function
+  # to behave on different platforms.
+  context "On Mac OS X Systems" do
+    let(:facts) { { :interfaces => 'lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0' } }
+    it { is_expected.to run.with_params('lo0').and_return(true) }
+    it { is_expected.to run.with_params('lo').and_return(false) }
+  end
+
+  context "On Linux Systems" do
+    let(:facts) do
+      {
+        :interfaces => 'eth0,lo',
+        :ipaddress => '10.0.0.1',
+        :ipaddress_lo => '127.0.0.1',
+        :ipaddress_eth0 => '10.0.0.1',
+        :muppet => 'kermit',
+        :muppet_lo => 'mspiggy',
+        :muppet_eth0 => 'kermit',
+      }
+    end
+
+    it { is_expected.to run.with_params('lo').and_return(true) }
+    it { is_expected.to run.with_params('lo0').and_return(false) }
+    it { is_expected.to run.with_params('ipaddress', '127.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('ipaddress', '10.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('ipaddress', '8.8.8.8').and_return(false) }
+    it { is_expected.to run.with_params('muppet', 'kermit').and_return(true) }
+    it { is_expected.to run.with_params('muppet', 'mspiggy').and_return(true) }
+    it { is_expected.to run.with_params('muppet', 'bigbird').and_return(false) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/has_ip_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/has_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/has_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'has_ip_address' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  context "On Linux Systems" do
+    let(:facts) do
+      {
+        :interfaces => 'eth0,lo',
+        :ipaddress => '10.0.0.1',
+        :ipaddress_lo => '127.0.0.1',
+        :ipaddress_eth0 => '10.0.0.1',
+      }
+    end
+
+    it { is_expected.to run.with_params('127.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('10.0.0.1').and_return(true) }
+    it { is_expected.to run.with_params('8.8.8.8').and_return(false) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/has_ip_network_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/has_ip_network_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/has_ip_network_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'has_ip_network' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  context "On Linux Systems" do
+    let(:facts) do
+      {
+        :interfaces => 'eth0,lo',
+        :network => :undefined,
+        :network_lo => '127.0.0.0',
+        :network_eth0 => '10.0.0.0',
+      }
+    end
+
+    it { is_expected.to run.with_params('127.0.0.0').and_return(true) }
+    it { is_expected.to run.with_params('10.0.0.0').and_return(true) }
+    it { is_expected.to run.with_params('8.8.8.0').and_return(false) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/has_key_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/has_key_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/has_key_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'has_key' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params("one").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params("one", "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) }
+  it { is_expected.to run.with_params(1, "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) }
+  it { is_expected.to run.with_params([], "two").and_raise_error(Puppet::ParseError, /expects the first argument to be a hash/) }
+
+  it { is_expected.to run.with_params({ 'key' => 'value' }, "key").and_return(true) }
+  it { is_expected.to run.with_params({}, "key").and_return(false) }
+  it { is_expected.to run.with_params({ 'key' => 'value'}, "not a key").and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe 'hash' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, /Unable to compute/) }
+  it { is_expected.to run.with_params([]).and_return({}) }
+  it { is_expected.to run.with_params(['key1', 'value1']).and_return({ 'key1' => 'value1' }) }
+  it { is_expected.to run.with_params(['key1', 'value1', 'key2', 'value2']).and_return({ 'key1' => 'value1', 'key2' => 'value2' }) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/intersection_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/intersection_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/intersection_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'intersection' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError) }
+  it { is_expected.to run.with_params([], []).and_return([]) }
+  it { is_expected.to run.with_params([], ['one']).and_return([]) }
+  it { is_expected.to run.with_params(['one'], []).and_return([]) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['two', 'three']) }
+  it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return([]) end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_a_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_a_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_a_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+if ENV["FUTURE_PARSER"] == 'yes'
+  describe 'type_of' do
+    pending 'teach rspec-puppet to load future-only functions under 3.7.5' do
+      it { is_expected.not_to eq(nil) }
+    end
+  end
+end
+
+if Puppet.version.to_f >= 4.0
+  describe 'is_a' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) }
+
+    it 'succeeds when comparing a string and a string' do
+      is_expected.to run.with_params('hello world', String).and_return(true)
+    end
+
+    it 'fails when comparing an integer and a string' do
+      is_expected.to run.with_params(5, String).and_return(false)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_array_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'is_array' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params([]).and_return(true) }
+  it { is_expected.to run.with_params(['one']).and_return(true) }
+  it { is_expected.to run.with_params([1]).and_return(true) }
+  it { is_expected.to run.with_params([{}]).and_return(true) }
+  it { is_expected.to run.with_params([[]]).and_return(true) }
+  it { is_expected.to run.with_params('').and_return(false) }
+  it { is_expected.to run.with_params('one').and_return(false) }
+  it { is_expected.to run.with_params(1).and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'is_bool' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(true, false).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(true).and_return(true) }
+  it { is_expected.to run.with_params(false).and_return(true) }
+  it { is_expected.to run.with_params([1]).and_return(false) }
+  it { is_expected.to run.with_params([{}]).and_return(false) }
+  it { is_expected.to run.with_params([[]]).and_return(false) }
+  it { is_expected.to run.with_params([true]).and_return(false) }
+  it { is_expected.to run.with_params('true').and_return(false) }
+  it { is_expected.to run.with_params('false').and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_domain_name_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_domain_name_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_domain_name_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,43 @@
+require 'spec_helper'
+
+describe 'is_domain_name' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1).and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params('').and_return(false) }
+  it { is_expected.to run.with_params('.').and_return(true) }
+  it { is_expected.to run.with_params('com').and_return(true) }
+  it { is_expected.to run.with_params('com.').and_return(true) }
+  it { is_expected.to run.with_params('x.com').and_return(true) }
+  it { is_expected.to run.with_params('x.com.').and_return(true) }
+  it { is_expected.to run.with_params('foo.example.com').and_return(true) }
+  it { is_expected.to run.with_params('foo.example.com.').and_return(true) }
+  it { is_expected.to run.with_params('2foo.example.com').and_return(true) }
+  it { is_expected.to run.with_params('2foo.example.com.').and_return(true) }
+  it { is_expected.to run.with_params('www.2foo.example.com').and_return(true) }
+  it { is_expected.to run.with_params('www.2foo.example.com.').and_return(true) }
+  describe 'inputs with spaces' do
+    it { is_expected.to run.with_params('invalid domain').and_return(false) }
+  end
+  describe 'inputs with hyphens' do
+    it { is_expected.to run.with_params('foo-bar.example.com').and_return(true) }
+    it { is_expected.to run.with_params('foo-bar.example.com.').and_return(true) }
+    it { is_expected.to run.with_params('www.foo-bar.example.com').and_return(true) }
+    it { is_expected.to run.with_params('www.foo-bar.example.com.').and_return(true) }
+    it { is_expected.to run.with_params('-foo.example.com').and_return(false) }
+    it { is_expected.to run.with_params('-foo.example.com').and_return(false) }
+  end
+  # Values obtained from Facter values will be frozen strings
+  # in newer versions of Facter:
+  it { is_expected.to run.with_params('www.example.com'.freeze).and_return(true) }
+  describe 'top level domain must be alphabetic if there are multiple labels' do
+    it { is_expected.to run.with_params('2com').and_return(true) }
+    it { is_expected.to run.with_params('www.example.2com').and_return(false) }
+  end
+  describe 'IP addresses are not domain names' do
+    it { is_expected.to run.with_params('192.168.1.1').and_return(false) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_email_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_email_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_email_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe 'is_email_address' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('bob@gmail.com').and_return(true) }
+  it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com').and_return(true) }
+  it { is_expected.to run.with_params('peter.parker@gmail.com').and_return(true) }
+  it { is_expected.to run.with_params('1.2.3@domain').and_return(false) }
+  it { is_expected.to run.with_params('1.2.3.4.5@').and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_float_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_float_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_float_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'is_float' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  describe 'passing a string' do
+    it { is_expected.to run.with_params('0.1').and_return(true) }
+    it { is_expected.to run.with_params('1.0').and_return(true) }
+    it { is_expected.to run.with_params('1').and_return(false) }
+    it { is_expected.to run.with_params('one').and_return(false) }
+    it { is_expected.to run.with_params('one 1.0').and_return(false) }
+    it { is_expected.to run.with_params('1.0 one').and_return(false) }
+  end
+
+  describe 'passing numbers' do
+    it { is_expected.to run.with_params(0.1).and_return(true) }
+    it { is_expected.to run.with_params(1.0).and_return(true) }
+    it { is_expected.to run.with_params(1).and_return(false) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_function_available.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_function_available.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_function_available.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe 'is_function_available' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('include').and_return(true) }
+  it { is_expected.to run.with_params('no_such_function').and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,11 @@
+require 'spec_helper'
+
+describe 'is_hash' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('').and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(true) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params(1).and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_integer_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_integer_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_integer_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe 'is_integer' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  it { is_expected.to run.with_params(3).and_return(true) }
+  it { is_expected.to run.with_params('3').and_return(true) }
+  it { is_expected.to run.with_params(-3).and_return(true) }
+  it { is_expected.to run.with_params('-3').and_return(true) }
+  
+  it { is_expected.to run.with_params(3.7).and_return(false) }
+  it { is_expected.to run.with_params('3.7').and_return(false) }
+  it { is_expected.to run.with_params(-3.7).and_return(false) }
+  it { is_expected.to run.with_params('3.7').and_return(false) }
+
+  it { is_expected.to run.with_params('one').and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params([1]).and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params(true).and_return(false) }
+  it { is_expected.to run.with_params(false).and_return(false) }
+  it { is_expected.to run.with_params('0001234').and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_ip_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe 'is_ip_address' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('1.2.3.4').and_return(true) }
+  it { is_expected.to run.with_params('1.2.3.255').and_return(true) }
+  it { is_expected.to run.with_params('1.2.3.256').and_return(false) }
+  it { is_expected.to run.with_params('1.2.3').and_return(false) }
+  it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) }
+  it { is_expected.to run.with_params('fe00::1').and_return(true) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74').and_return(true) }
+  it { is_expected.to run.with_params('FE80:0000:CD12:D123:E2F8:47FF:FE09:DD74').and_return(true) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:zzzz').and_return(false) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09').and_return(false) }
+  it { is_expected.to run.with_params('fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74:dd74').and_return(false) }
+  it { is_expected.to run.with_params('').and_return(false) }
+  it { is_expected.to run.with_params('one').and_return(false) }
+  it { is_expected.to run.with_params(1).and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_mac_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_mac_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_mac_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'is_mac_address' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('00:a0:1f:12:7f:a0').and_return(true) }
+  it { is_expected.to run.with_params('00:A0:1F:12:7F:A0').and_return(true) }
+  it { is_expected.to run.with_params('00:00:00:00:00:0g').and_return(false) }
+  it { is_expected.to run.with_params('').and_return(false) }
+  it { is_expected.to run.with_params('one').and_return(false) }
+  it {
+    pending "should properly typecheck its arguments"
+    is_expected.to run.with_params(1).and_return(false)
+  }
+  it {
+    pending "should properly typecheck its arguments"
+    is_expected.to run.with_params({}).and_return(false)
+  }
+  it {
+    pending "should properly typecheck its arguments"
+    is_expected.to run.with_params([]).and_return(false)
+  }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_numeric_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_numeric_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_numeric_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe 'is_numeric' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  it { is_expected.to run.with_params(3).and_return(true) }
+  it { is_expected.to run.with_params('3').and_return(true) }
+  it { is_expected.to run.with_params(-3).and_return(true) }
+  it { is_expected.to run.with_params('-3').and_return(true) }
+  
+  it { is_expected.to run.with_params(3.7).and_return(true) }
+  it { is_expected.to run.with_params('3.7').and_return(true) }
+  it { is_expected.to run.with_params(-3.7).and_return(true) }
+  it { is_expected.to run.with_params('3.7').and_return(true) }
+
+  it { is_expected.to run.with_params('-342.2315e-12').and_return(true) }
+
+  it { is_expected.to run.with_params('one').and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params([1]).and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params(true).and_return(false) }
+  it { is_expected.to run.with_params(false).and_return(false) }
+  it { is_expected.to run.with_params('0001234').and_return(false) }
+  it { is_expected.to run.with_params(' - 1234').and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/is_string_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/is_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/is_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe 'is_string' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+
+  it { is_expected.to run.with_params(3).and_return(false) }
+  it { is_expected.to run.with_params('3').and_return(false) }
+  it { is_expected.to run.with_params(-3).and_return(false) }
+  it { is_expected.to run.with_params('-3').and_return(false) }
+
+  it { is_expected.to run.with_params(3.7).and_return(false) }
+  it { is_expected.to run.with_params('3.7').and_return(false) }
+  it { is_expected.to run.with_params(-3.7).and_return(false) }
+  it { is_expected.to run.with_params('3.7').and_return(false) }
+
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params([1]).and_return(false) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params(true).and_return(false) }
+  it { is_expected.to run.with_params(false).and_return(false) }
+  it { is_expected.to run.with_params('one').and_return(true) }
+  it { is_expected.to run.with_params('0001234').and_return(true) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/join_keys_to_values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/join_keys_to_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/join_keys_to_values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'join_keys_to_values' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /Takes exactly two arguments/) }
+  it { is_expected.to run.with_params({}, '', '').and_raise_error(Puppet::ParseError, /Takes exactly two arguments/) }
+  it { is_expected.to run.with_params('one', '').and_raise_error(TypeError, /The first argument must be a hash/) }
+  it { is_expected.to run.with_params({}, 2).and_raise_error(TypeError, /The second argument must be a string/) }
+
+  it { is_expected.to run.with_params({}, '').and_return([]) }
+  it { is_expected.to run.with_params({}, ':').and_return([]) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return(['keyvalue']) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, ':').and_return(['key:value']) }
+  it { is_expected.to run.with_params({ 'key' => nil }, ':').and_return(['key:']) }
+  it 'should run join_keys_to_values(<hash with multiple keys>, ":") and return the proper array' do
+    result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }, ':'])
+    expect(result.sort).to eq(['key1:value1', 'key2:value2'].sort)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/join_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/join_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/join_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'join' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the second.")
+    is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Requires array to work with/) }
+  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /Requires string to work with/) }
+
+  it { is_expected.to run.with_params([]).and_return('') }
+  it { is_expected.to run.with_params([], ':').and_return('') }
+  it { is_expected.to run.with_params(['one']).and_return('one') }
+  it { is_expected.to run.with_params(['one'], ':').and_return('one') }
+  it { is_expected.to run.with_params(['one', 'two', 'three']).and_return('onetwothree') }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ':').and_return('one:two:three') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/keys_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/keys_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/keys_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'keys' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params({}).and_return([]) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key']) }
+  it 'should return the array of keys' do
+    result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }])
+    expect(result).to match_array(['key1', 'key2'])
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/load_module_metadata_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/load_module_metadata_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/load_module_metadata_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+describe 'load_module_metadata' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  it "should json parse the file" do
+     allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
+     allow(File).to receive(:exists?).with(/metadata.json/).and_return(true)
+     allow(File).to receive(:read).with(/metadata.json/).and_return('{"name": "spencer-science"}')
+
+     result = subject.call(['science'])
+     expect(result['name']).to eq('spencer-science')
+  end
+
+  it "should fail by default if there is no metadata.json" do
+     allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
+     allow(File).to receive(:exists?).with(/metadata.json/).and_return(false)
+     expect {subject.call(['science'])}.to raise_error(Puppet::ParseError)
+  end
+
+  it "should return nil if user allows empty metadata.json" do
+     allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
+     allow(File).to receive(:exists?).with(/metadata.json/).and_return(false)
+     result = subject.call(['science', true])
+     expect(result).to eq({})
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/loadyaml_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/loadyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/loadyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'loadyaml' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  context 'when a non-existing file is specified' do
+    let(:filename) { '/tmp/doesnotexist' }
+    before {
+      File.expects(:exists?).with(filename).returns(false).once
+      YAML.expects(:load_file).never
+    }
+    it { is_expected.to run.with_params(filename).and_return(nil) }
+  end
+  context 'when an existing file is specified' do
+    let(:filename) { '/tmp/doesexist' }
+    let(:data) { { 'key' => 'value' } }
+    before {
+      File.expects(:exists?).with(filename).returns(true).once
+      YAML.expects(:load_file).with(filename).returns(data).once
+    }
+    it { is_expected.to run.with_params(filename).and_return(data) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/lstrip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/lstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/lstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe 'lstrip' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params('').and_return('') }
+  it { is_expected.to run.with_params(' ').and_return('') }
+  it { is_expected.to run.with_params('     ').and_return('') }
+  it { is_expected.to run.with_params("\t").and_return('') }
+  it { is_expected.to run.with_params("\t ").and_return('') }
+  it { is_expected.to run.with_params('one').and_return('one') }
+  it { is_expected.to run.with_params(' one').and_return('one') }
+  it { is_expected.to run.with_params('     one').and_return('one') }
+  it { is_expected.to run.with_params("\tone").and_return('one') }
+  it { is_expected.to run.with_params("\t one").and_return('one') }
+  it { is_expected.to run.with_params('one ').and_return('one ') }
+  it { is_expected.to run.with_params(' one ').and_return('one ') }
+  it { is_expected.to run.with_params('     one ').and_return('one ') }
+  it { is_expected.to run.with_params("\tone ").and_return('one ') }
+  it { is_expected.to run.with_params("\t one ").and_return('one ') }
+  it { is_expected.to run.with_params("one \t").and_return("one \t") }
+  it { is_expected.to run.with_params(" one \t").and_return("one \t") }
+  it { is_expected.to run.with_params("     one \t").and_return("one \t") }
+  it { is_expected.to run.with_params("\tone \t").and_return("one \t") }
+  it { is_expected.to run.with_params("\t one \t").and_return("one \t") }
+  it { is_expected.to run.with_params(' o n e ').and_return('o n e ') }
+  it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one ') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/max_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/max_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/max_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'max' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1).and_return(1) }
+  it { is_expected.to run.with_params(1, 2).and_return(2) }
+  it { is_expected.to run.with_params(1, 2, 3).and_return(3) }
+  it { is_expected.to run.with_params(3, 2, 1).and_return(3) }
+  it { is_expected.to run.with_params('one').and_return('one') }
+  it { is_expected.to run.with_params('one', 'two').and_return('two') }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_return('two') }
+  it { is_expected.to run.with_params('three', 'two', 'one').and_return('two') }
+
+  describe 'implementation artifacts' do
+    it { is_expected.to run.with_params(1, 'one').and_return('one') }
+    it { is_expected.to run.with_params('1', 'one').and_return('one') }
+    it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.4e0') }
+    it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.3e1) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/member_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/member_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/member_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'member' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params([], '').and_return(false) }
+  it { is_expected.to run.with_params([], ['']).and_return(false) }
+  it { is_expected.to run.with_params([''], '').and_return(true) }
+  it { is_expected.to run.with_params([''], ['']).and_return(true) }
+  it { is_expected.to run.with_params([], 'one').and_return(false) }
+  it { is_expected.to run.with_params([], ['one']).and_return(false) }
+  it { is_expected.to run.with_params(['one'], 'one').and_return(true) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return(true) }
+  it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) }
+  it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/merge_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/merge_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe 'merge' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params({}, 'two').and_raise_error(Puppet::ParseError, /unexpected argument type String/) }
+  it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) }
+  it {
+    pending 'should not special case this'
+    is_expected.to run.with_params({}).and_return({})
+  }
+  it { is_expected.to run.with_params({}, {}).and_return({}) }
+  it { is_expected.to run.with_params({}, {}, {}).and_return({}) }
+  describe 'should accept empty strings as puppet undef' do
+    it { is_expected.to run.with_params({}, '').and_return({}) }
+  end
+  it { is_expected.to run.with_params({ 'key' => 'value' }, {}).and_return({ 'key' => 'value' }) }
+  it { is_expected.to run.with_params({}, { 'key' => 'value' }).and_return({ 'key' => 'value' }) }
+  it { is_expected.to run.with_params({ 'key' => 'value1' }, { 'key' => 'value2' }).and_return({ 'key' => 'value2' }) }
+  it {
+    is_expected.to run \
+      .with_params({ 'key1' => 'value1' }, { 'key2' => 'value2' }, { 'key3' => 'value3' }) \
+      .and_return({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' })
+  }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/min_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/min_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/min_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'min' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1).and_return(1) }
+  it { is_expected.to run.with_params(1, 2).and_return(1) }
+  it { is_expected.to run.with_params(1, 2, 3).and_return(1) }
+  it { is_expected.to run.with_params(3, 2, 1).and_return(1) }
+  it { is_expected.to run.with_params('one').and_return('one') }
+  it { is_expected.to run.with_params('one', 'two').and_return('one') }
+  it { is_expected.to run.with_params('one', 'two', 'three').and_return('one') }
+  it { is_expected.to run.with_params('three', 'two', 'one').and_return('one') }
+
+  describe 'implementation artifacts' do
+    it { is_expected.to run.with_params(1, 'one').and_return(1) }
+    it { is_expected.to run.with_params('1', 'one').and_return('1') }
+    it { is_expected.to run.with_params('1.3e1', '1.4e0').and_return('1.3e1') }
+    it { is_expected.to run.with_params(1.3e1, 1.4e0).and_return(1.4e0) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/num2bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/num2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/num2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe 'num2bool' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('abc').and_raise_error(Puppet::ParseError, /does not look like a number/) }
+  it { is_expected.to run.with_params(1).and_return(true) }
+  it { is_expected.to run.with_params('1').and_return(true) }
+  it { is_expected.to run.with_params(1.5).and_return(true) }
+  it { is_expected.to run.with_params('1.5').and_return(true) }
+  it { is_expected.to run.with_params(-1).and_return(false) }
+  it { is_expected.to run.with_params('-1').and_return(false) }
+  it { is_expected.to run.with_params(-1.5).and_return(false) }
+  it { is_expected.to run.with_params('-1.5').and_return(false) }
+  it { is_expected.to run.with_params(0).and_return(false) }
+  it { is_expected.to run.with_params('0').and_return(false) }
+  it { is_expected.to run.with_params([]).and_return(false) }
+  it { is_expected.to run.with_params('[]').and_raise_error(Puppet::ParseError, /does not look like a number/) }
+  it { is_expected.to run.with_params({}).and_return(false) }
+  it { is_expected.to run.with_params('{}').and_raise_error(Puppet::ParseError, /does not look like a number/) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/parsejson_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/parsejson_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/parsejson_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,64 @@
+require 'spec_helper'
+
+describe 'parsejson' do
+  it 'should exist' do
+    is_expected.not_to eq(nil)
+  end
+
+  it 'should raise an error if called without any arguments' do
+    is_expected.to run.with_params().
+                       and_raise_error(/wrong number of arguments/i)
+  end
+
+  context 'with correct JSON data' do
+
+    it 'should be able to parse a JSON data with a Hash' do
+      is_expected.to run.with_params('{"a":"1","b":"2"}').
+                         and_return({'a'=>'1', 'b'=>'2'})
+    end
+
+    it 'should be able to parse a JSON data with an Array' do
+      is_expected.to run.with_params('["a","b","c"]').
+                         and_return(['a', 'b', 'c'])
+    end
+
+    it 'should be able to parse empty JSON values' do
+      is_expected.to run.with_params('[]').
+                         and_return([])
+      is_expected.to run.with_params('{}').
+                         and_return({})
+    end
+
+    it 'should be able to parse a JSON data with a mixed structure' do
+      is_expected.to run.with_params('{"a":"1","b":2,"c":{"d":[true,false]}}').
+                         and_return({'a' =>'1', 'b' => 2, 'c' => { 'd' => [true, false] } })
+    end
+
+    it 'should not return the default value if the data was parsed correctly' do
+      is_expected.to run.with_params('{"a":"1"}', 'default_value').
+                         and_return({'a' => '1'})
+    end
+
+  end
+
+  context 'with incorrect JSON data' do
+    it 'should raise an error with invalid JSON and no default' do
+      is_expected.to run.with_params('').
+                         and_raise_error(PSON::ParserError)
+    end
+
+    it 'should support a structure for a default value' do
+      is_expected.to run.with_params('', {'a' => '1'}).
+                         and_return({'a' => '1'})
+    end
+
+    ['', 1, 1.2, nil, true, false, [], {}, :yaml].each do |value|
+      it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do
+        is_expected.to run.with_params(value, 'default_value').
+                           and_return('default_value')
+      end
+    end
+
+  end
+
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/parseyaml_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/parseyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/parseyaml_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,81 @@
+require 'spec_helper'
+
+describe 'parseyaml' do
+  it 'should exist' do
+    is_expected.not_to eq(nil)
+  end
+
+  it 'should raise an error if called without any arguments' do
+    is_expected.to run.with_params().
+                       and_raise_error(/wrong number of arguments/i)
+  end
+
+  context 'with correct YAML data' do
+    it 'should be able to parse a YAML data with a String' do
+      is_expected.to run.with_params('--- just a string').
+                         and_return('just a string')
+      is_expected.to run.with_params('just a string').
+                         and_return('just a string')
+    end
+
+    it 'should be able to parse a YAML data with a Hash' do
+      is_expected.to run.with_params("---\na: '1'\nb: '2'\n").
+                         and_return({'a' => '1', 'b' => '2'})
+    end
+
+    it 'should be able to parse a YAML data with an Array' do
+      is_expected.to run.with_params("---\n- a\n- b\n- c\n").
+                         and_return(['a', 'b', 'c'])
+    end
+
+    it 'should be able to parse a YAML data with a mixed structure' do
+      is_expected.to run.with_params("---\na: '1'\nb: 2\nc:\n  d:\n  - :a\n  - true\n  - false\n").
+                         and_return({'a' => '1', 'b' => 2, 'c' => {'d' => [:a, true, false]}})
+    end
+
+    it 'should not return the default value if the data was parsed correctly' do
+      is_expected.to run.with_params("---\na: '1'\n", 'default_value').
+                         and_return({'a' => '1'})
+    end
+
+  end
+
+  context 'on a modern ruby', :unless => RUBY_VERSION == '1.8.7' do
+    it 'should raise an error with invalid YAML and no default' do
+      is_expected.to run.with_params('["one"').
+                         and_raise_error(Psych::SyntaxError)
+    end
+  end
+
+    context 'when running on ruby 1.8.7, which does not have Psych', :if => RUBY_VERSION == '1.8.7' do
+      it 'should raise an error with invalid YAML and no default' do
+        is_expected.to run.with_params('["one"').
+          and_raise_error(ArgumentError)
+      end
+    end
+
+  context 'with incorrect YAML data' do
+    it 'should support a structure for a default value' do
+      is_expected.to run.with_params('', {'a' => '1'}).
+                         and_return({'a' => '1'})
+    end
+
+    [1, 1.2, nil, true, false, [], {}, :yaml].each do |value|
+      it "should return the default value for an incorrect #{value.inspect} (#{value.class}) parameter" do
+        is_expected.to run.with_params(value, 'default_value').
+                           and_return('default_value')
+      end
+    end
+
+    context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do
+      ['---', '...', '*8', ''].each do |value|
+        it "should return the default value for an incorrect #{value.inspect} string parameter" do
+          is_expected.to run.with_params(value, 'default_value').
+                             and_return('default_value')
+        end
+      end
+    end
+
+  end
+
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/pick_default_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/pick_default_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/pick_default_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'pick_default' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::Error, /Must receive at least one argument/) }
+
+  it { is_expected.to run.with_params('one', 'two').and_return('one') }
+  it { is_expected.to run.with_params('', 'two').and_return('two') }
+  it { is_expected.to run.with_params(:undef, 'two').and_return('two') }
+  it { is_expected.to run.with_params(:undefined, 'two').and_return('two') }
+  it { is_expected.to run.with_params(nil, 'two').and_return('two') }
+
+  [ '', :undef, :undefined, nil, {}, [], 1, 'default' ].each do |value|
+    describe "when providing #{value.inspect} as default" do
+      it { is_expected.to run.with_params('one', value).and_return('one') }
+      it { is_expected.to run.with_params([], value).and_return([]) }
+      it { is_expected.to run.with_params({}, value).and_return({}) }
+      it { is_expected.to run.with_params(value, value).and_return(value) }
+      it { is_expected.to run.with_params(:undef, value).and_return(value) }
+      it { is_expected.to run.with_params(:undefined, value).and_return(value) }
+      it { is_expected.to run.with_params(nil, value).and_return(value) }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/pick_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/pick_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/pick_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+describe 'pick' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /must receive at least one non empty value/) }
+  it { is_expected.to run.with_params('', nil, :undef, :undefined).and_raise_error(Puppet::ParseError, /must receive at least one non empty value/) }
+  it { is_expected.to run.with_params('one', 'two').and_return('one') }
+  it { is_expected.to run.with_params('', 'two').and_return('two') }
+  it { is_expected.to run.with_params(:undef, 'two').and_return('two') }
+  it { is_expected.to run.with_params(:undefined, 'two').and_return('two') }
+  it { is_expected.to run.with_params(nil, 'two').and_return('two') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/prefix_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/prefix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/prefix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe 'prefix' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the second.")
+    is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /expected first argument to be an Array or a Hash/) }
+  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) }
+  it { is_expected.to run.with_params([], '').and_return([]) }
+  it { is_expected.to run.with_params([''], '').and_return(['']) }
+  it { is_expected.to run.with_params(['one'], 'pre').and_return(['preone']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 'pre').and_return(['preone', 'pretwo', 'prethree']) }
+  it { is_expected.to run.with_params({}).and_return({}) }
+  it { is_expected.to run.with_params({ 'key1' => 'value1', 2 => 3}).and_return({ 'key1' => 'value1', '2' => 3 }) }
+  it { is_expected.to run.with_params({}, '').and_return({}) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return({ 'key' => 'value' }) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }, 'pre').and_return({ 'prekey' => 'value' }) }
+  it {
+    is_expected.to run \
+      .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'pre') \
+      .and_return({ 'prekey1' => 'value1', 'prekey2' => 'value2', 'prekey3' => 'value3' })
+  }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/private_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/private_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/private_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,56 @@
+require 'spec_helper'
+
+describe 'private' do
+  it 'should issue a warning' do
+    scope.expects(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
+    begin
+      subject.call []
+    rescue
+      # ignore this
+    end
+  end
+
+  context "when called from inside module" do
+    it "should not fail" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('foo')
+      expect {
+        subject.call []
+      }.not_to raise_error
+    end
+  end
+
+  context "with an explicit failure message" do
+    it "prints the failure message on error" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
+      expect {
+        subject.call ['failure message!']
+      }.to raise_error Puppet::ParseError, /failure message!/
+    end
+  end
+
+  context "when called from private class" do
+    it "should fail with a class error message" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
+      scope.source.expects(:name).returns('foo::baz')
+      scope.source.expects(:type).returns('hostclass')
+      expect {
+        subject.call []
+      }.to raise_error Puppet::ParseError, /Class foo::baz is private/
+    end
+  end
+
+  context "when called from private definition" do
+    it "should fail with a class error message" do
+      scope.expects(:lookupvar).with('module_name').returns('foo')
+      scope.expects(:lookupvar).with('caller_module_name').returns('bar')
+      scope.source.expects(:name).returns('foo::baz')
+      scope.source.expects(:type).returns('definition')
+      expect {
+        subject.call []
+      }.to raise_error Puppet::ParseError, /Definition foo::baz is private/
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/pw_hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/pw_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/pw_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,69 @@
+require 'spec_helper'
+
+describe 'pw_hash' do
+
+  it { is_expected.not_to eq(nil) }
+
+  context 'when there are less than 3 arguments' do
+    it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('password').and_raise_error(ArgumentError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('password', 'sha-256').and_raise_error(ArgumentError, /wrong number of arguments/i) }
+  end
+
+  context 'when there are more than 3 arguments' do
+    it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra').and_raise_error(ArgumentError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('password', 'sha-256', 'salt', 'extra', 'extra').and_raise_error(ArgumentError, /wrong number of arguments/i) }
+  end
+
+  context 'when the first argument is not a string' do
+    it { is_expected.to run.with_params([], 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
+    it { is_expected.to run.with_params({}, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
+    it { is_expected.to run.with_params(1, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
+    it { is_expected.to run.with_params(true, 'sha-256', 'salt').and_raise_error(ArgumentError, /first argument must be a string/) }
+  end
+
+  context 'when the first argument is undefined' do
+    it { is_expected.to run.with_params('', 'sha-256', 'salt').and_return(nil) }
+    it { is_expected.to run.with_params(nil, 'sha-256', 'salt').and_return(nil) }
+  end
+
+  context 'when the second argument is not a string' do
+    it { is_expected.to run.with_params('password', [], 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
+    it { is_expected.to run.with_params('password', {}, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
+    it { is_expected.to run.with_params('password', 1, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
+    it { is_expected.to run.with_params('password', true, 'salt').and_raise_error(ArgumentError, /second argument must be a string/) }
+  end
+
+  context 'when the second argument is not one of the supported hashing algorithms' do
+    it { is_expected.to run.with_params('password', 'no such algo', 'salt').and_raise_error(ArgumentError, /is not a valid hash type/) }
+  end
+
+  context 'when the third argument is not a string' do
+    it { is_expected.to run.with_params('password', 'sha-256', []).and_raise_error(ArgumentError, /third argument must be a string/) }
+    it { is_expected.to run.with_params('password', 'sha-256', {}).and_raise_error(ArgumentError, /third argument must be a string/) }
+    it { is_expected.to run.with_params('password', 'sha-256', 1).and_raise_error(ArgumentError, /third argument must be a string/) }
+    it { is_expected.to run.with_params('password', 'sha-256', true).and_raise_error(ArgumentError, /third argument must be a string/) }
+  end
+
+  context 'when the third argument is empty' do
+    it { is_expected.to run.with_params('password', 'sha-512', '').and_raise_error(ArgumentError, /third argument must not be empty/) }
+  end
+
+  context 'when the third argument contains invalid characters' do
+    it { is_expected.to run.with_params('password', 'sha-512', 'one%').and_raise_error(ArgumentError, /characters in salt must be in the set/) }
+  end
+
+  context 'when running on a platform with a weak String#crypt implementation' do
+    before(:each) { allow_any_instance_of(String).to receive(:crypt).with('$1$1').and_return('a bad hash') }
+
+    it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_raise_error(Puppet::ParseError, /system does not support enhanced salts/) }
+  end
+
+  if RUBY_PLATFORM == 'java' or 'test'.crypt('$1$1') == '$1$1$Bp8CU9Oujr9SSEw53WV6G.'
+    describe "on systems with enhanced salts support" do
+      it { is_expected.to run.with_params('password', 'md5', 'salt').and_return('$1$salt$qJH7.N4xYta3aEG/dfqo/0') }
+      it { is_expected.to run.with_params('password', 'sha-256', 'salt').and_return('$5$salt$Gcm6FsVtF/Qa77ZKD.iwsJlCVPY0XSMgLJL0Hnww/c1') }
+      it { is_expected.to run.with_params('password', 'sha-512', 'salt').and_return('$6$salt$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy.g.') }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/range_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/range_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/range_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,118 @@
+require 'spec_helper'
+
+describe 'range' do
+  it { is_expected.not_to eq(nil) }
+
+  describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it {
+      pending("Current implementation ignores parameters after the third.")
+      is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    }
+    it { is_expected.to run.with_params('1..2..3').and_raise_error(Puppet::ParseError, /Unable to compute range/i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Unknown range format/i) }
+  end
+
+  describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params('').and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params({}).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params([]).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(true).and_raise_error(ArgumentError) }
+    it {                                        is_expected.to run.with_params(1, 2, 'foo').and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, []).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, {}).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, true).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(ArgumentError) }
+    it { pending "the puppet 4 implementation"; is_expected.to run.with_params('1..2..3').and_raise_error(ArgumentError) }
+  end
+
+  context 'with characters as bounds' do
+    it { is_expected.to run.with_params('d', 'a').and_return([]) }
+    it { is_expected.to run.with_params('a', 'a').and_return(['a']) }
+    it { is_expected.to run.with_params('a', 'b').and_return(['a', 'b']) }
+    it { is_expected.to run.with_params('a', 'd').and_return(['a', 'b', 'c', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', 1).and_return(['a', 'b', 'c', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', '1').and_return(['a', 'b', 'c', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', 2).and_return(['a', 'c']) }
+    it { is_expected.to run.with_params('a', 'd', -2).and_return(['a', 'c']) }
+    it { is_expected.to run.with_params('a', 'd', 3).and_return(['a', 'd']) }
+    it { is_expected.to run.with_params('a', 'd', 4).and_return(['a']) }
+  end
+
+  context 'with strings as bounds' do
+    it { is_expected.to run.with_params('onea', 'oned').and_return(['onea', 'oneb', 'onec', 'oned']) }
+    it { is_expected.to run.with_params('two', 'one').and_return([]) }
+    it { is_expected.to run.with_params('true', 'false').and_return([]) }
+    it { is_expected.to run.with_params('false', 'true').and_return(['false']) }
+  end
+
+  context 'with integers as bounds' do
+    it { is_expected.to run.with_params(4, 1).and_return([]) }
+    it { is_expected.to run.with_params(1, 1).and_return([1]) }
+    it { is_expected.to run.with_params(1, 2).and_return([1, 2]) }
+    it { is_expected.to run.with_params(1, 4).and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params(1, 4, 1).and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params(1, 4, '1').and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params(1, 4, 2).and_return([1, 3]) }
+    it { is_expected.to run.with_params(1, 4, -2).and_return([1, 3]) }
+    it { is_expected.to run.with_params(1, 4, 3).and_return([1, 4]) }
+    it { is_expected.to run.with_params(1, 4, 4).and_return([1]) }
+  end
+
+  context 'with integers as strings as bounds' do
+    it { is_expected.to run.with_params('4', '1').and_return([]) }
+    it { is_expected.to run.with_params('1', '1').and_return([1]) }
+    it { is_expected.to run.with_params('1', '2').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1', '4').and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params('1', '4', 1).and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params('1', '4', '1').and_return([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params('1', '4', 2).and_return([1, 3]) }
+    it { is_expected.to run.with_params('1', '4', -2).and_return([1, 3]) }
+    it { is_expected.to run.with_params('1', '4', 3).and_return([1, 4]) }
+    it { is_expected.to run.with_params('1', '4', 4).and_return([1]) }
+  end
+
+  context 'with prefixed numbers as strings as bounds' do
+    it { is_expected.to run.with_params('host01', 'host04').and_return(['host01', 'host02', 'host03', 'host04']) }
+    it { is_expected.to run.with_params('01', '04').and_return([1, 2, 3, 4]) }
+  end
+
+  context 'with dash-range syntax' do
+    it { is_expected.to run.with_params('4-1').and_return([]) }
+    it { is_expected.to run.with_params('1-1').and_return([1]) }
+    it { is_expected.to run.with_params('1-2').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1-4').and_return([1, 2, 3, 4]) }
+  end
+
+  context 'with two-dot-range syntax' do
+    it { is_expected.to run.with_params('4..1').and_return([]) }
+    it { is_expected.to run.with_params('1..1').and_return([1]) }
+    it { is_expected.to run.with_params('1..2').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1..4').and_return([1, 2, 3, 4]) }
+  end
+
+  context 'with three-dot-range syntax' do
+    it { is_expected.to run.with_params('4...1').and_return([]) }
+    it { is_expected.to run.with_params('1...1').and_return([]) }
+    it { is_expected.to run.with_params('1...2').and_return([1]) }
+    it { is_expected.to run.with_params('1...3').and_return([1, 2]) }
+    it { is_expected.to run.with_params('1...5').and_return([1, 2, 3, 4]) }
+  end
+
+  describe 'when passing mixed arguments as bounds' do
+    it {
+      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially')
+      is_expected.to run.with_params('0', 'a').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/)
+    }
+    it {
+      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially')
+      is_expected.to run.with_params(0, 'a').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/)
+    }
+    it {
+      pending('these bounds should not be allowed as ruby will OOM hard. e.g. `(\'host0\'..\'hosta\').to_a` has 3239930 elements on ruby 1.9, adding more \'0\'s and \'a\'s increases that exponentially')
+      is_expected.to run.with_params('h0', 'ha').and_raise_error(Puppet::ParseError, /cannot interpolate between numeric and non-numeric bounds/)
+    }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/reject_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/reject_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/reject_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'reject' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([], 'pattern', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  it {
+    pending("reject does not actually check this, and raises NoMethodError instead")
+    is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+  }
+  it {
+    pending("reject does not actually check this, and raises NoMethodError instead")
+    is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, /first argument not an array/)
+  }
+  it { is_expected.to run.with_params([], 'two').and_return([]) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['one']) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/reverse_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/reverse_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/reverse_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe 'reverse' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(['a']).and_return(['a']) }
+  it { is_expected.to run.with_params(['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['three', 'two', 'one']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) }
+
+  it { is_expected.to run.with_params('').and_return('') }
+  it { is_expected.to run.with_params('a').and_return('a') }
+  it { is_expected.to run.with_params('abc').and_return('cba') }
+  it { is_expected.to run.with_params('abcd').and_return('dcba') }
+
+  context 'when using a class extending String' do
+    it 'should call its reverse method' do
+      value = AlsoString.new('asdfghjkl')
+      value.expects(:reverse).returns('foo')
+      expect(subject).to run.with_params(value).and_return('foo')
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/rstrip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/rstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/rstrip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe 'rstrip' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params('').and_return('') }
+  it { is_expected.to run.with_params(' ').and_return('') }
+  it { is_expected.to run.with_params('     ').and_return('') }
+  it { is_expected.to run.with_params("\t").and_return('') }
+  it { is_expected.to run.with_params("\t ").and_return('') }
+  it { is_expected.to run.with_params('one').and_return('one') }
+  it { is_expected.to run.with_params(' one').and_return(' one') }
+  it { is_expected.to run.with_params('     one').and_return('     one') }
+  it { is_expected.to run.with_params("\tone").and_return("\tone") }
+  it { is_expected.to run.with_params("\t one").and_return("\t one") }
+  it { is_expected.to run.with_params('one ').and_return('one') }
+  it { is_expected.to run.with_params(' one ').and_return(' one') }
+  it { is_expected.to run.with_params('     one ').and_return('     one') }
+  it { is_expected.to run.with_params("\tone ").and_return("\tone") }
+  it { is_expected.to run.with_params("\t one ").and_return("\t one") }
+  it { is_expected.to run.with_params("one\t").and_return('one') }
+  it { is_expected.to run.with_params(" one\t").and_return(' one') }
+  it { is_expected.to run.with_params("     one\t").and_return('     one') }
+  it { is_expected.to run.with_params("\tone\t").and_return("\tone") }
+  it { is_expected.to run.with_params("\t one\t").and_return("\t one") }
+  it { is_expected.to run.with_params(' o n e ').and_return(' o n e') }
+  it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return(' one') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/seeded_rand_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/seeded_rand_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/seeded_rand_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,53 @@
+require 'spec_helper'
+
+describe 'seeded_rand' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(ArgumentError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(0, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params(1.5, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params(-10, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params("-10", '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params("string", '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params([], '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params({}, '').and_raise_error(ArgumentError, /first argument must be a positive integer/) }
+  it { is_expected.to run.with_params(1, 1).and_raise_error(ArgumentError, /second argument must be a string/) }
+  it { is_expected.to run.with_params(1, []).and_raise_error(ArgumentError, /second argument must be a string/) }
+  it { is_expected.to run.with_params(1, {}).and_raise_error(ArgumentError, /second argument must be a string/) }
+
+  it "provides a random number strictly less than the given max" do
+    expect(seeded_rand(3, 'seed')).to satisfy {|n| n.to_i < 3 }
+  end
+
+  it "provides a random number greater or equal to zero" do
+    expect(seeded_rand(3, 'seed')).to satisfy {|n| n.to_i >= 0 }
+  end
+
+  it "provides the same 'random' value on subsequent calls for the same host" do
+    expect(seeded_rand(10, 'seed')).to eql(seeded_rand(10, 'seed'))
+  end
+
+  it "allows seed to control the random value on a single host" do
+    first_random = seeded_rand(1000, 'seed1')
+    second_different_random = seeded_rand(1000, 'seed2')
+
+    expect(first_random).not_to eql(second_different_random)
+  end
+
+  it "should not return different values for different hosts" do
+    val1 = seeded_rand(1000, 'foo', :host => "first.host.com")
+    val2 = seeded_rand(1000, 'foo', :host => "second.host.com")
+
+    expect(val1).to eql(val2)
+  end
+
+  def seeded_rand(max, seed, args = {})
+    host = args[:host] || '127.0.0.1'
+
+    # workaround not being able to use let(:facts) because some tests need
+    # multiple different hostnames in one context
+    scope.stubs(:lookupvar).with("::fqdn", {}).returns(host)
+
+    scope.function_seeded_rand([max, seed])
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/shuffle_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/shuffle_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/shuffle_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,33 @@
+require 'spec_helper'
+
+describe 'shuffle' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+
+  context 'when running with a specific seed' do
+    # make tests deterministic
+    before(:each) { srand(2) }
+
+    it { is_expected.to run.with_params([]).and_return([]) }
+    it { is_expected.to run.with_params(['a']).and_return(['a']) }
+    it { is_expected.to run.with_params(['one']).and_return(['one']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['two', 'one', 'three']) }
+    it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) }
+
+    it { is_expected.to run.with_params('').and_return('') }
+    it { is_expected.to run.with_params('a').and_return('a') }
+    it { is_expected.to run.with_params('abc').and_return('bac') }
+    it { is_expected.to run.with_params('abcd').and_return('dcba') }
+
+    context 'when using a class extending String' do
+      it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/size_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/size_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/size_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,35 @@
+require 'spec_helper'
+
+describe 'size' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Unknown type given/) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Unknown type given/) }
+  it { is_expected.to run.with_params('1').and_raise_error(Puppet::ParseError, /Requires either string, array or hash to work/) }
+  it { is_expected.to run.with_params('1.0').and_raise_error(Puppet::ParseError, /Requires either string, array or hash to work/) }
+  it { is_expected.to run.with_params([]).and_return(0) }
+  it { is_expected.to run.with_params(['a']).and_return(1) }
+  it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) }
+  it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) }
+
+  it { is_expected.to run.with_params({}).and_return(0) }
+  it { is_expected.to run.with_params({'1' => '2'}).and_return(1) }
+  it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) }
+
+  it { is_expected.to run.with_params('').and_return(0) }
+  it { is_expected.to run.with_params('a').and_return(1) }
+  it { is_expected.to run.with_params('abc').and_return(3) }
+  it { is_expected.to run.with_params('abcd').and_return(4) }
+
+  context 'when using a class extending String' do
+    it 'should call its size method' do
+      value = AlsoString.new('asdfghjkl')
+      value.expects(:size).returns('foo')
+      expect(subject).to run.with_params(value).and_return('foo')
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/sort_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/sort_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/sort_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'sort' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { pending('stricter input checking'); is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /requires string or array/) }
+    it { pending('stricter input checking'); is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /requires string or array/) }
+    it { pending('stricter input checking'); is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /requires string or array/) }
+  end
+
+  context 'when called with an array' do
+    it { is_expected.to run.with_params([]).and_return([]) }
+    it { is_expected.to run.with_params(['a']).and_return(['a']) }
+    it { is_expected.to run.with_params(['c', 'b', 'a']).and_return(['a', 'b', 'c']) }
+  end
+
+  context 'when called with a string' do
+    it { is_expected.to run.with_params('').and_return('') }
+    it { is_expected.to run.with_params('a').and_return('a') }
+    it { is_expected.to run.with_params('cbda').and_return('abcd') }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/squeeze_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/squeeze_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/squeeze_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+describe 'squeeze' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('', '', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1).and_raise_error(NoMethodError) }
+  it { is_expected.to run.with_params({}).and_raise_error(NoMethodError) }
+  it { is_expected.to run.with_params(true).and_raise_error(NoMethodError) }
+
+  context 'when squeezing a single string' do
+    it { is_expected.to run.with_params('').and_return('') }
+    it { is_expected.to run.with_params('a').and_return('a') }
+    it { is_expected.to run.with_params('aaaaaaaaa').and_return('a') }
+    it { is_expected.to run.with_params('aaaaaaaaa', 'a').and_return('a') }
+    it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') }
+  end
+
+  context 'when squeezing values in an array' do
+    it {
+      is_expected.to run \
+        .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc']) \
+        .and_return( ['', 'a', 'a',         'abc'])
+    }
+    it {
+      is_expected.to run \
+        .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'a') \
+        .and_return( ['', 'a', 'a',         'abbbbbbbbbbcccccccccc'])
+    }
+    it {
+      is_expected.to run \
+        .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'b-c') \
+        .and_return( ['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc'])
+    }
+  end
+
+  context 'when using a class extending String' do
+    it 'should call its squeeze method' do
+      value = AlsoString.new('aaaaaaaaa')
+      value.expects(:squeeze).returns('foo')
+      expect(subject).to run.with_params(value).and_return('foo')
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/str2bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/str2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/str2bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe 'str2bool' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('true', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Unknown type of boolean given/) }
+
+  describe 'when testing values that mean "true"' do
+    [ 'TRUE','1', 't', 'y', 'true', 'yes', true ].each do |value|
+      it { is_expected.to run.with_params(value).and_return(true) }
+    end
+  end
+
+  describe 'when testing values that mean "false"' do
+    [ 'FALSE','', '0', 'f', 'n', 'false', 'no', false, 'undef', 'undefined' ].each do |value|
+      it { is_expected.to run.with_params(value).and_return(false) }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/str2saltedsha512_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/str2saltedsha512_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/str2saltedsha512_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,17 @@
+require 'spec_helper'
+
+describe 'str2saltedsha512' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('password', 2).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires a String argument/) }
+
+  context 'when running with a specific seed' do
+    # make tests deterministic
+    before(:each) { srand(2) }
+
+    it { is_expected.to run.with_params('').and_return('0f8a612f4eeed08e47b3875d00f33c5688f7926298f2d9b5fe19d1323f910bc78b6f7b5892596d2fabaa65e7a8d99b3768c102610cf0432c4827eee01f09451e3fae4f7a') }
+    it { is_expected.to run.with_params('password').and_return('0f8a612f43134376566c5707718d600effcfb17581fc9d3fa64d7f447dfda317c174ffdb498d2c5bd5c2075dab41c9d7ada5afbdc6b55354980eb5ba61802371e6b64956') }
+    it { is_expected.to run.with_params('verylongpassword').and_return('0f8a612f7a448537540e062daa8621f9bae326ca8ccb899e1bdb10e7c218cebfceae2530b856662565fdc4d81e986fc50cfbbc46d50436610ed9429ff5e43f2c45b5d039') }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/strftime_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/strftime_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/strftime_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe 'strftime' do
+  it "should exist" do
+    expect(Puppet::Parser::Functions.function("strftime")).to eq("function_strftime")
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    expect { scope.function_strftime([]) }.to( raise_error(Puppet::ParseError))
+  end
+
+  it "using %s should be higher then when I wrote this test" do
+    result = scope.function_strftime(["%s"])
+    expect(result.to_i).to(be > 1311953157)
+  end
+
+  it "using %s should be lower then 1.5 trillion" do
+    result = scope.function_strftime(["%s"])
+    expect(result.to_i).to(be < 1500000000)
+  end
+
+  it "should return a date when given %Y-%m-%d" do
+    result = scope.function_strftime(["%Y-%m-%d"])
+    expect(result).to match(/^\d{4}-\d{2}-\d{2}$/)
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/strip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/strip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/strip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe 'strip' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) }
+  it { is_expected.to run.with_params('').and_return('') }
+  it { is_expected.to run.with_params(' ').and_return('') }
+  it { is_expected.to run.with_params('     ').and_return('') }
+  it { is_expected.to run.with_params("\t").and_return('') }
+  it { is_expected.to run.with_params("\t ").and_return('') }
+  it { is_expected.to run.with_params('one').and_return('one') }
+  it { is_expected.to run.with_params(' one').and_return('one') }
+  it { is_expected.to run.with_params('     one').and_return('one') }
+  it { is_expected.to run.with_params("\tone").and_return('one') }
+  it { is_expected.to run.with_params("\t one").and_return('one') }
+  it { is_expected.to run.with_params('one ').and_return('one') }
+  it { is_expected.to run.with_params(' one ').and_return('one') }
+  it { is_expected.to run.with_params('     one ').and_return('one') }
+  it { is_expected.to run.with_params("\tone ").and_return('one') }
+  it { is_expected.to run.with_params("\t one ").and_return('one') }
+  it { is_expected.to run.with_params("one \t").and_return('one') }
+  it { is_expected.to run.with_params(" one \t").and_return('one') }
+  it { is_expected.to run.with_params("     one \t").and_return('one') }
+  it { is_expected.to run.with_params("\tone \t").and_return('one') }
+  it { is_expected.to run.with_params("\t one \t").and_return('one') }
+  it { is_expected.to run.with_params(' o n e ').and_return('o n e') }
+  it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one') }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/suffix_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/suffix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/suffix_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,38 @@
+require 'spec_helper'
+
+describe 'suffix' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the second.")
+    is_expected.to run.with_params([], 'a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /expected first argument to be an Array/) }
+  it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) }
+  it { is_expected.to run.with_params([]).and_return([]) }
+  it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) }
+  it { is_expected.to run.with_params([], '').and_return([]) }
+  it { is_expected.to run.with_params([''], '').and_return(['']) }
+  it { is_expected.to run.with_params(['one'], 'post').and_return(['onepost']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], 'post').and_return(['onepost', 'twopost', 'threepost']) }
+  it {
+    is_expected.to run.with_params({}).and_return({})
+  }
+  it {
+    is_expected.to run.with_params({ 'key1' => 'value1', 2 => 3}).and_return({ 'key1' => 'value1', '2' => 3 })
+  }
+  it {
+    is_expected.to run.with_params({}, '').and_return({})
+  }
+  it {
+    is_expected.to run.with_params({ 'key' => 'value' }, '').and_return({ 'key' => 'value' })
+  }
+  it {
+    is_expected.to run.with_params({ 'key' => 'value' }, 'post').and_return({ 'keypost' => 'value' })
+  }
+  it {
+    is_expected.to run \
+      .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'post') \
+      .and_return({ 'key1post' => 'value1', 'key2post' => 'value2', 'key3post' => 'value3' })
+  }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/swapcase_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/swapcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/swapcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe 'swapcase' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  describe 'with strings as inputs' do
+    it { is_expected.to run.with_params('').and_return('') }
+    it { is_expected.to run.with_params('one').and_return('ONE') }
+    it { is_expected.to run.with_params('ONE').and_return('one') }
+    it { is_expected.to run.with_params('oNe').and_return('OnE') }
+  end
+  describe 'with arrays as inputs' do
+    it { is_expected.to run.with_params([]).and_return([]) }
+    describe 'only containing strings' do
+      it { is_expected.to run.with_params(['']).and_return(['']) }
+      it { is_expected.to run.with_params(['one']).and_return(['ONE']) }
+      it { is_expected.to run.with_params(['ONE']).and_return(['one']) }
+      it { is_expected.to run.with_params(['oNe']).and_return(['OnE']) }
+      it { is_expected.to run.with_params(['one', 'ONE']).and_return(['ONE', 'one']) }
+      it { is_expected.to run.with_params(['ONE', 'OnE']).and_return(['one', 'oNe']) }
+      it { is_expected.to run.with_params(['oNe', 'one']).and_return(['OnE', 'ONE']) }
+    end
+    describe 'containing mixed types' do
+      it { is_expected.to run.with_params(['OnE', {}]).and_return(['oNe', {}]) }
+      it { is_expected.to run.with_params(['OnE', 1]).and_return(['oNe', 1]) }
+      it { is_expected.to run.with_params(['OnE', []]).and_return(['oNe', []]) }
+      it { is_expected.to run.with_params(['OnE', ['two']]).and_return(['oNe', ['two']]) }
+    end
+  end
+  it "should accept objects which extend String" do
+    is_expected.to run.with_params(AlsoString.new("OnE")).and_return('oNe')
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/time_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/time_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/time_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'time' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params('a', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+  context 'when running at a specific time' do
+    before(:each) {
+      # get a value before stubbing the function
+      test_time = Time.utc(2006, 10, 13, 8, 15, 11)
+      Time.expects(:new).with().returns(test_time).once
+    }
+    it { is_expected.to run.with_params().and_return(1160727311) }
+    it { is_expected.to run.with_params('').and_return(1160727311) }
+    it { is_expected.to run.with_params([]).and_return(1160727311) }
+    it { is_expected.to run.with_params({}).and_return(1160727311) }
+    it { is_expected.to run.with_params('foo').and_return(1160727311) }
+    it { is_expected.to run.with_params('UTC').and_return(1160727311) }
+    it { is_expected.to run.with_params('America/New_York').and_return(1160727311) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/to_bytes_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/to_bytes_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/to_bytes_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,72 @@
+require 'spec_helper'
+
+describe 'to_bytes' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params('1', 'extras').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([]).and_raise_error(TypeError, /(can't convert|no implicit conversion of) Array (in)?to String/) }
+  it { is_expected.to run.with_params({}).and_raise_error(TypeError, /(can't convert|no implicit conversion of) Hash (in)?to String/) }
+  it { is_expected.to run.with_params(true).and_raise_error(TypeError, /(can't convert|no implicit conversion of) (TrueClass|true) (in)?to String/) }
+
+  describe 'when passing numbers' do
+    it { is_expected.to run.with_params(0).and_return(0) }
+    it { is_expected.to run.with_params(1).and_return(1) }
+    it { is_expected.to run.with_params(-1).and_return(-1) }
+    it { is_expected.to run.with_params(1.1).and_return(1.1) }
+    it { is_expected.to run.with_params(-1.1).and_return(-1.1) }
+  end
+
+  describe 'when passing numbers as strings' do
+    describe 'without a unit' do
+      it { is_expected.to run.with_params('1').and_return(1) }
+      it { is_expected.to run.with_params('-1').and_return(-1) }
+      # these are so wrong
+      it { is_expected.to run.with_params('1.1').and_return(1) }
+      it { is_expected.to run.with_params('-1.1').and_return(-1) }
+    end
+
+    describe 'with a unit' do
+      it { is_expected.to run.with_params('1k').and_return(1024) }
+      it { is_expected.to run.with_params('-1kB').and_return(-1024) }
+      it { is_expected.to run.with_params('1k').and_return(1024) }
+      it { is_expected.to run.with_params('1M').and_return(1024*1024) }
+      it { is_expected.to run.with_params('1G').and_return(1024*1024*1024) }
+      it { is_expected.to run.with_params('1T').and_return(1024*1024*1024*1024) }
+      it { is_expected.to run.with_params('1P').and_return(1024*1024*1024*1024*1024) }
+      it { is_expected.to run.with_params('1E').and_return(1024*1024*1024*1024*1024*1024) }
+      it { is_expected.to run.with_params('1.5e3M').and_return(1572864000) }
+
+      it { is_expected.to run.with_params('4k').and_return(4*1024) }
+      it { is_expected.to run.with_params('-4kB').and_return(4*-1024) }
+      it { is_expected.to run.with_params('4k').and_return(4*1024) }
+      it { is_expected.to run.with_params('4M').and_return(4*1024*1024) }
+      it { is_expected.to run.with_params('4G').and_return(4*1024*1024*1024) }
+      it { is_expected.to run.with_params('4T').and_return(4*1024*1024*1024*1024) }
+      it { is_expected.to run.with_params('4P').and_return(4*1024*1024*1024*1024*1024) }
+      it { is_expected.to run.with_params('4E').and_return(4*1024*1024*1024*1024*1024*1024) }
+
+      # these are so wrong
+      it { is_expected.to run.with_params('1.0001 k').and_return(1024) }
+      it { is_expected.to run.with_params('-1.0001 kB').and_return(-1024) }
+    end
+
+    describe 'with a unknown unit' do
+      it { is_expected.to run.with_params('1KB').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
+      it { is_expected.to run.with_params('1K').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
+      it { is_expected.to run.with_params('1mb').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
+      it { is_expected.to run.with_params('1m').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
+      it { is_expected.to run.with_params('1%').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
+      it { is_expected.to run.with_params('1 p').and_raise_error(Puppet::ParseError, /Unknown prefix/) }
+    end
+  end
+
+  # these are so wrong
+  describe 'when passing random stuff' do
+    it { is_expected.to run.with_params('-1....1').and_return(-1) }
+    it { is_expected.to run.with_params('-1.e.e.e.1').and_return(-1) }
+    it { is_expected.to run.with_params('-1+1').and_return(-1) }
+    it { is_expected.to run.with_params('1-1').and_return(1) }
+    it { is_expected.to run.with_params('1 kaboom').and_return(1024) }
+    it { is_expected.to run.with_params('kaboom').and_return(0) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/try_get_value_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/try_get_value_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/try_get_value_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,100 @@
+require 'spec_helper'
+
+describe 'try_get_value' do
+
+  let(:data) do
+    {
+        'a' => {
+            'g' => '2',
+            'e' => [
+                'f0',
+                'f1',
+                {
+                    'x' => {
+                        'y' => 'z'
+                    }
+                },
+                'f3',
+            ]
+        },
+        'b' => true,
+        'c' => false,
+        'd' => '1',
+    }
+  end
+
+  context 'single values' do
+    it 'should exist' do
+      is_expected.not_to eq(nil)
+    end
+
+    it 'should be able to return a single value' do
+      is_expected.to run.with_params('test').and_return('test')
+    end
+
+    it 'should use the default value if data is a single value and path is present' do
+      is_expected.to run.with_params('test', 'path', 'default').and_return('default')
+    end
+
+    it 'should return default if there is no data' do
+      is_expected.to run.with_params(nil, nil, 'default').and_return('default')
+    end
+
+    it 'should be able to use data structures as default values' do
+      is_expected.to run.with_params('test', 'path', data).and_return(data)
+    end
+  end
+
+  context 'structure values' do
+    it 'should be able to extracts a single hash value' do
+      is_expected.to run.with_params(data, 'd', 'default').and_return('1')
+    end
+
+    it 'should be able to extract a deeply nested hash value' do
+      is_expected.to run.with_params(data, 'a/g', 'default').and_return('2')
+    end
+
+    it 'should return the default value if the path is not found' do
+      is_expected.to run.with_params(data, 'missing', 'default').and_return('default')
+    end
+
+    it 'should return the default value if the path is too long' do
+      is_expected.to run.with_params(data, 'a/g/c/d', 'default').and_return('default')
+    end
+
+    it 'should support an array index in the path' do
+      is_expected.to run.with_params(data, 'a/e/1', 'default').and_return('f1')
+    end
+
+    it 'should return the default value if an array index is not a number' do
+      is_expected.to run.with_params(data, 'a/b/c', 'default').and_return('default')
+    end
+
+    it 'should return the default value if and index is out of array length' do
+      is_expected.to run.with_params(data, 'a/e/5', 'default').and_return('default')
+    end
+
+    it 'should be able to path though both arrays and hashes' do
+      is_expected.to run.with_params(data, 'a/e/2/x/y', 'default').and_return('z')
+    end
+
+    it 'should be able to return "true" value' do
+      is_expected.to run.with_params(data, 'b', 'default').and_return(true)
+      is_expected.to run.with_params(data, 'm', true).and_return(true)
+    end
+
+    it 'should be able to return "false" value' do
+      is_expected.to run.with_params(data, 'c', 'default').and_return(false)
+      is_expected.to run.with_params(data, 'm', false).and_return(false)
+    end
+
+    it 'should return "nil" if value is not found and no default value is provided' do
+      is_expected.to run.with_params(data, 'a/1').and_return(nil)
+    end
+
+    it 'should be able to use a custom path separator' do
+      is_expected.to run.with_params(data, 'a::g', 'default', '::').and_return('2')
+      is_expected.to run.with_params(data, 'a::c', 'default', '::').and_return('default')
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/type3x_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/type3x_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/type3x_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,41 @@
+require 'spec_helper'
+
+describe 'type3x' do
+  it "should exist" do
+    expect(Puppet::Parser::Functions.function("type3x")).to eq("function_type3x")
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    expect { scope.function_type3x([]) }.to( raise_error(Puppet::ParseError))
+  end
+
+  it "should return string when given a string" do
+    result = scope.function_type3x(["aaabbbbcccc"])
+    expect(result).to(eq('string'))
+  end
+
+  it "should return array when given an array" do
+    result = scope.function_type3x([["aaabbbbcccc","asdf"]])
+    expect(result).to(eq('array'))
+  end
+
+  it "should return hash when given a hash" do
+    result = scope.function_type3x([{"a"=>1,"b"=>2}])
+    expect(result).to(eq('hash'))
+  end
+
+  it "should return integer when given an integer" do
+    result = scope.function_type3x(["1"])
+    expect(result).to(eq('integer'))
+  end
+
+  it "should return float when given a float" do
+    result = scope.function_type3x(["1.34"])
+    expect(result).to(eq('float'))
+  end
+
+  it "should return boolean when given a boolean" do
+    result = scope.function_type3x([true])
+    expect(result).to(eq('boolean'))
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/type_of_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/type_of_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/type_of_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+if ENV["FUTURE_PARSER"] == 'yes'
+  describe 'type_of' do
+    pending 'teach rspec-puppet to load future-only functions under 3.7.5' do
+      it { is_expected.not_to eq(nil) }
+    end
+  end
+end
+
+if Puppet.version.to_f >= 4.0
+  describe 'type_of' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
+    it { is_expected.to run.with_params('', '').and_raise_error(ArgumentError) }
+
+    it 'gives the type of a string' do
+      expect(subject.call({}, 'hello world')).to be_kind_of(Puppet::Pops::Types::PStringType)
+    end
+
+    it 'gives the type of an integer' do
+      expect(subject.call({}, 5)).to be_kind_of(Puppet::Pops::Types::PIntegerType)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/type_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/type_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/type_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,42 @@
+require 'spec_helper'
+
+describe 'type' do
+  it "should exist" do
+    expect(Puppet::Parser::Functions.function("type")).to eq("function_type")
+  end
+
+  it "should give a deprecation warning when called" do
+    scope.expects(:warning).with("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
+    scope.function_type(["aoeu"])
+  end
+
+  it "should return string when given a string" do
+    result = scope.function_type(["aaabbbbcccc"])
+    expect(result).to(eq('string'))
+  end
+
+  it "should return array when given an array" do
+    result = scope.function_type([["aaabbbbcccc","asdf"]])
+    expect(result).to(eq('array'))
+  end
+
+  it "should return hash when given a hash" do
+    result = scope.function_type([{"a"=>1,"b"=>2}])
+    expect(result).to(eq('hash'))
+  end
+
+  it "should return integer when given an integer" do
+    result = scope.function_type(["1"])
+    expect(result).to(eq('integer'))
+  end
+
+  it "should return float when given a float" do
+    result = scope.function_type(["1.34"])
+    expect(result).to(eq('float'))
+  end
+
+  it "should return boolean when given a boolean" do
+    result = scope.function_type([true])
+    expect(result).to(eq('boolean'))
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/union_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/union_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/union_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'union' do
+  describe 'argument checking' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, /Every parameter must be an array/) }
+    it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError, /Every parameter must be an array/) }
+    it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /Every parameter must be an array/) }
+  end
+
+  it { is_expected.to run.with_params([], []).and_return([]) }
+  it { is_expected.to run.with_params([], ['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one'], []).and_return(['one']) }
+  it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) }
+  it { is_expected.to run.with_params(['one'], ['two']).and_return(['one', 'two']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one', 'two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two'], ['two', 'three'], ['one', 'three']).and_return(['one', 'two', 'three']) }
+  it { is_expected.to run.with_params(['one', 'two'], ['three', 'four'], ['one', 'two', 'three'], ['four']).and_return(['one', 'two', 'three', 'four']) }
+  it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3', 1, 2]) end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/unique_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/unique_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/unique_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe 'unique' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it {
+      pending("Current implementation ignores parameters after the first.")
+      is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  end
+
+  context 'when called with an array' do
+    it { is_expected.to run.with_params([]).and_return([]) }
+    it { is_expected.to run.with_params(['a']).and_return(['a']) }
+    it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) }
+  end
+
+  context 'when called with a string' do
+    it { is_expected.to run.with_params('').and_return('') }
+    it { is_expected.to run.with_params('a').and_return('a') }
+    it { is_expected.to run.with_params('aaba').and_return('ab') }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/unix2dos_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/unix2dos_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/unix2dos_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe 'unix2dos' do
+  context 'Checking parameter validity' do
+    it { is_expected.not_to eq(nil) }
+    it do
+      is_expected.to run.with_params.and_raise_error(ArgumentError, /Wrong number of arguments/)
+    end
+    it do
+      is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, /Wrong number of arguments/)
+    end
+    it do
+      is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError)
+    end
+    it do
+      is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError)
+    end
+  end
+
+  context 'Converting from unix to dos format' do
+    sample_text    = "Hello\nWorld\n"
+    desired_output = "Hello\r\nWorld\r\n"
+
+    it 'should output dos format' do
+      should run.with_params(sample_text).and_return(desired_output)
+    end
+  end
+
+  context 'Converting from dos to dos format' do
+    sample_text    = "Hello\r\nWorld\r\n"
+    desired_output = "Hello\r\nWorld\r\n"
+
+    it 'should output dos format' do
+      should run.with_params(sample_text).and_return(desired_output)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/upcase_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/upcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/upcase_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe 'upcase' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires an array, hash or object that responds to upcase/) }
+    it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, /Requires an array, hash or object that responds to upcase/) }
+  end
+
+  describe 'normal string handling' do
+    it { is_expected.to run.with_params("abc").and_return("ABC") }
+    it { is_expected.to run.with_params("Abc").and_return("ABC") }
+    it { is_expected.to run.with_params("ABC").and_return("ABC") }
+  end
+
+  describe 'handling classes derived from String' do
+    it { is_expected.to run.with_params(AlsoString.new("ABC")).and_return("ABC") }
+  end
+
+  describe 'strings in arrays handling' do
+    it { is_expected.to run.with_params([]).and_return([]) }
+    it { is_expected.to run.with_params(["One", "twO"]).and_return(["ONE", "TWO"]) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/uriescape_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/uriescape_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/uriescape_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe 'uriescape' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it {
+      pending("Current implementation ignores parameters after the first.")
+      is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
+  end
+
+  describe 'handling normal strings' do
+    it 'should call ruby\'s URI.escape function' do
+      URI.expects(:escape).with('uri_string').returns('escaped_uri_string').once
+      is_expected.to run.with_params('uri_string').and_return('escaped_uri_string') 
+    end
+  end
+
+  describe 'handling classes derived from String' do
+    it 'should call ruby\'s URI.escape function' do
+      uri_string = AlsoString.new('uri_string')
+      URI.expects(:escape).with(uri_string).returns('escaped_uri_string').once
+      is_expected.to run.with_params(uri_string).and_return("escaped_uri_string") 
+    end
+  end
+
+  describe 'strings in arrays handling' do
+    it { is_expected.to run.with_params([]).and_return([]) }
+    it { is_expected.to run.with_params(["one}", "two"]).and_return(["one%7D", "two"]) }
+    it { is_expected.to run.with_params(["one}", 1, true, {}, "two"]).and_return(["one%7D", 1, true, {}, "two"]) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_absolute_path_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_absolute_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_absolute_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,62 @@
+require 'spec_helper'
+
+describe 'validate_absolute_path' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  end
+
+  describe "valid paths handling" do
+    %w{
+      C:/
+      C:\\
+      C:\\WINDOWS\\System32
+      C:/windows/system32
+      X:/foo/bar
+      X:\\foo\\bar
+      \\\\host\\windows
+      //host/windows
+      /
+      /var/tmp
+      /var/opt/../lib/puppet
+    }.each do |path|
+      it { is_expected.to run.with_params(path) }
+      it { is_expected.to run.with_params(['/tmp', path]) }
+    end
+  end
+
+  describe 'invalid path handling' do
+    context 'garbage inputs' do
+      [
+        nil,
+        [ nil ],
+        [ nil, nil ],
+        { 'foo' => 'bar' },
+        { },
+        '',
+      ].each do |path|
+        it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+        it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+        it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+      end
+    end
+
+    context 'relative paths' do
+      %w{
+        relative1
+        .
+        ..
+        ./foo
+        ../foo
+        etc/puppetlabs/puppet
+        opt/puppet/bin
+        relative\\windows
+      }.each do |path|
+        it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+        it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+        it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, /is not an absolute path/) }
+      end
+    end
+  end
+end
+
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_array_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_array_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe 'validate_array' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params([]) }
+      it { is_expected.to run.with_params(['one']) }
+      it { is_expected.to run.with_params([], ['two']) }
+      it { is_expected.to run.with_params(['one'], ['two']) }
+    end
+
+    describe 'invalid inputs' do
+      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params([], {}).and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params([], 1).and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params([], true).and_raise_error(Puppet::ParseError, /is not an Array/) }
+      it { is_expected.to run.with_params([], 'one').and_raise_error(Puppet::ParseError, /is not an Array/) }
+    end
+  end
+end
+
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_augeas_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_augeas_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_augeas_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,75 @@
+require 'spec_helper'
+
+describe 'validate_augeas' do
+  unless Puppet.features.augeas?
+    skip "ruby-augeas not installed"
+  else
+    describe 'signature validation' do
+      it { is_expected.not_to eq(nil) }
+      it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+      it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+      it { is_expected.to run.with_params('', '', [], '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+      it { is_expected.to run.with_params('one', 'one', 'MSG to User', '4th arg').and_raise_error(NoMethodError) }
+    end
+
+    describe 'valid inputs' do
+      inputs = [
+        [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns' ],
+        [ "proc /proc   proc    nodev,noexec,nosuid     0       0\n", 'Fstab.lns'],
+      ]
+
+      inputs.each do |input|
+        it { is_expected.to run.with_params(*input) }
+      end
+    end
+
+    describe 'valid inputs which fail augeas validation' do
+      # The intent here is to make sure valid inputs raise exceptions when they
+      # don't specify an error message to display.  This is the behvior in
+      # 2.2.x and prior.
+      inputs = [
+        [ "root:x:0:0:root\n", 'Passwd.lns' ],
+        [ "127.0.1.1\n", 'Hosts.lns' ],
+      ]
+
+      inputs.each do |input|
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /validate_augeas.*?matched less than it should/) }
+      end
+    end
+
+    describe "when specifying nice error messages" do
+      # The intent here is to make sure the function returns the 4th argument
+      # in the exception thrown
+      inputs = [
+        [ "root:x:0:0:root\n", 'Passwd.lns', [], 'Failed to validate passwd content' ],
+        [ "127.0.1.1\n", 'Hosts.lns', [], 'Wrong hosts content' ],
+      ]
+
+      inputs.each do |input|
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /#{input[3]}/) }
+      end
+    end
+
+    describe "matching additional tests" do
+      inputs = [
+        [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']],
+        [ "root:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']],
+      ]
+
+      inputs.each do |input|
+        it { is_expected.to run.with_params(*input) }
+      end
+    end
+
+    describe "failing additional tests" do
+      inputs = [
+        [ "foobar:x:0:0:root:/root:/bin/bash\n", 'Passwd.lns', ['$file/foobar']],
+        [ "root:x:0:0:root:/root:/bin/sh\n", 'Passwd.lns', ['$file/root/shell[.="/bin/sh"]', 'foobar']],
+      ]
+
+      inputs.each do |input|
+        it { is_expected.to run.with_params(*input).and_raise_error(Puppet::ParseError, /testing path/) }
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_bool_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_bool_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe 'validate_bool' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  end
+
+  describe 'acceptable values' do
+    it { is_expected.to run.with_params(true) }
+    it { is_expected.to run.with_params(false) }
+    it { is_expected.to run.with_params(true, false, false, true) }
+  end
+
+  describe 'validation failures' do
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params(true, 'one').and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params('one', false).and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params("true").and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params("false").and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params(true, "false").and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params("true", false).and_raise_error(Puppet::ParseError, /is not a boolean/) }
+    it { is_expected.to run.with_params("true", false, false, false, false, false).and_raise_error(Puppet::ParseError, /is not a boolean/) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_cmd_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_cmd_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_cmd_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,35 @@
+require 'spec_helper'
+
+describe 'validate_cmd' do
+  let(:touch) { File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' }
+
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it {
+      pending('should implement stricter type checking')
+      is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /content must be a string/)
+    }
+    it {
+      pending('should implement stricter type checking')
+      is_expected.to run.with_params('', [], '').and_raise_error(Puppet::ParseError, /checkscript must be a string/)
+    }
+    it {
+      pending('should implement stricter type checking')
+      is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, /custom error message must be a string/)
+    }
+  end
+
+  context 'when validation fails' do
+    context 'with % placeholder' do
+      it { is_expected.to run.with_params('', "#{touch} % /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \S+ \/no\/such\/file' returned 1:.*(cannot touch|o such file or)/) }
+      it { is_expected.to run.with_params('', "#{touch} % /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
+    end
+    context 'without % placeholder' do
+      it { is_expected.to run.with_params('', "#{touch} /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \/no\/such\/file \S+' returned 1:.*(cannot touch|o such file or)/) }
+      it { is_expected.to run.with_params('', "#{touch} /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_email_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_email_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_email_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe 'validate_email_address' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  end
+
+  describe 'valid inputs' do
+    it { is_expected.to run.with_params('bob@gmail.com') }
+    it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com') }
+  end
+
+  describe 'invalid inputs' do
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid email/) }
+    it { is_expected.to run.with_params('bob@gmail.com', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('bob@gmail.com', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('bob@gmail.com', 'one').and_raise_error(Puppet::ParseError, /is not a valid email/) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_hash_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_hash_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe 'validate_hash' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params({}) }
+      it { is_expected.to run.with_params({'key' => 'value'}) }
+      it { is_expected.to run.with_params({}, {'key' => 'value'}) }
+      it { is_expected.to run.with_params({'key1' => 'value1'}, {'key2' => 'value2'}) }
+    end
+
+    describe 'invalid inputs' do
+      it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params({}, []).and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, /is not a Hash/) }
+      it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, /is not a Hash/) }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_integer_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_integer_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_integer_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,90 @@
+require 'spec_helper'
+
+describe 'validate_integer' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', 7.0, -7.0, {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x'].each do |invalid|
+      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /to be an Integer/) }
+      it { is_expected.to run.with_params(invalid, 10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
+      it { is_expected.to run.with_params(invalid, 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
+      it { is_expected.to run.with_params([0, 1, 2, invalid, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
+    end
+
+    context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do
+      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be an Integer/) }
+    end
+
+    context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do
+      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+      it { is_expected.to run.with_params([0, 1, 2, {0=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+    end
+
+    it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, /to be unset or an Integer/) }
+    it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, /to be unset or an Integer/) }
+    it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, /second argument to be larger than third argument/) }
+  end
+
+  context 'with no range constraints' do
+    it { is_expected.to run.with_params(1) }
+    it { is_expected.to run.with_params(-1) }
+    it { is_expected.to run.with_params('1') }
+    it { is_expected.to run.with_params('-1') }
+    it { is_expected.to run.with_params([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params([1, '2', '3', 4]) }
+  end
+
+  context "with a maximum limit of 10" do
+    describe 'rejects numbers greater than the limit' do
+      it { is_expected.to run.with_params(11, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params(100, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params(2**65, 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params([1,2,10,100], 10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+    end
+
+    describe 'accepts numbers less or equal to the limit' do
+      it { is_expected.to run.with_params(10, 10) }
+      it { is_expected.to run.with_params(1, 10) }
+      it { is_expected.to run.with_params(-1, 10) }
+      it { is_expected.to run.with_params('1', 10) }
+      it { is_expected.to run.with_params('-1', 10) }
+      it { is_expected.to run.with_params([1, 2, 3, 4], 10) }
+      it { is_expected.to run.with_params([1, '2', '3', 4], 10) }
+    end
+
+    context "with a minimum limit of -10" do
+      describe 'rejects numbers greater than the upper limit' do
+        it { is_expected.to run.with_params(11, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+        it { is_expected.to run.with_params(100, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+        it { is_expected.to run.with_params(2**65, 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+        it { is_expected.to run.with_params([1,2,10,100], 10, -10).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      end
+
+      describe 'rejects numbers smaller than the lower limit' do
+        it { is_expected.to run.with_params(-11, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+        it { is_expected.to run.with_params(-100, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+        it { is_expected.to run.with_params(-2**65, 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+        it { is_expected.to run.with_params([-10, 1,2,10,-100], 10, -10).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+      end
+
+      describe 'accepts numbers between and including the limits' do
+        it { is_expected.to run.with_params(10, 10, -10) }
+        it { is_expected.to run.with_params(-10, 10, -10) }
+        it { is_expected.to run.with_params(1, 10, -10) }
+        it { is_expected.to run.with_params(-1, 10, -10) }
+        it { is_expected.to run.with_params('1', 10, -10) }
+        it { is_expected.to run.with_params('-1', 10, -10) }
+        it { is_expected.to run.with_params([1, 2, 3, 4], 10, -10) }
+        it { is_expected.to run.with_params([1, '2', '3', 4], 10, -10) }
+      end
+    end
+  end
+
+  it { is_expected.to run.with_params(10, 10, 10) }
+
+  describe 'empty upper limit is interpreted as infinity' do
+    it { is_expected.to run.with_params(11, '', 10) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ip_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ip_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe 'validate_ip_address' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  end
+
+  describe 'valid inputs' do
+    it { is_expected.to run.with_params('0.0.0.0') }
+    it { is_expected.to run.with_params('8.8.8.8') }
+    it { is_expected.to run.with_params('127.0.0.1') }
+    it { is_expected.to run.with_params('10.10.10.10') }
+    it { is_expected.to run.with_params('194.232.104.150') }
+    it { is_expected.to run.with_params('244.24.24.24') }
+    it { is_expected.to run.with_params('255.255.255.255') }
+    it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') }
+    it { is_expected.to run.with_params('3ffe:0505:0002::') }
+    it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') }
+    it { is_expected.to run.with_params('::1/64') }
+    it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') }
+    context 'with netmasks' do
+      it { is_expected.to run.with_params('8.8.8.8/0') }
+      it { is_expected.to run.with_params('8.8.8.8/16') }
+      it { is_expected.to run.with_params('8.8.8.8/32') }
+      it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') }
+    end
+  end
+
+  describe 'invalid inputs' do
+    it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
+    it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
+    it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
+    it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
+    it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
+    it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IP/) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe 'validate_ipv4_address' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params('0.0.0.0') }
+      it { is_expected.to run.with_params('8.8.8.8') }
+      it { is_expected.to run.with_params('127.0.0.1') }
+      it { is_expected.to run.with_params('10.10.10.10') }
+      it { is_expected.to run.with_params('194.232.104.150') }
+      it { is_expected.to run.with_params('244.24.24.24') }
+      it { is_expected.to run.with_params('255.255.255.255') }
+      it { is_expected.to run.with_params('1.2.3.4', '5.6.7.8') }
+      context 'with netmasks' do
+        it { is_expected.to run.with_params('8.8.8.8/0') }
+        it { is_expected.to run.with_params('8.8.8.8/16') }
+        it { is_expected.to run.with_params('8.8.8.8/32') }
+        it { is_expected.to run.with_params('8.8.8.8/255.255.0.0') }
+      end
+    end
+
+    describe 'invalid inputs' do
+      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+      it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+      it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+      it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+      it { is_expected.to run.with_params('affe::beef').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+      it { is_expected.to run.with_params('1.2.3.4', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params('1.2.3.4', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params('1.2.3.4', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params('1.2.3.4', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv4/) }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_ipv6_address_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,32 @@
+require 'spec_helper'
+
+describe 'validate_ipv6_address' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params('3ffe:0505:0002::') }
+      it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') }
+      it { is_expected.to run.with_params('::1/64') }
+      it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') }
+    end
+
+    describe 'invalid inputs' do
+      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+      it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+      it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+      it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+      it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+      it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params('::1', 'one').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) }
+      context 'unless running on ruby 1.8.7', :if => RUBY_VERSION != '1.8.7' do
+        it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
+        it { is_expected.to run.with_params('::1', 1).and_raise_error(Puppet::ParseError, /is not a string/) }
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_numeric_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_numeric_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_numeric_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,89 @@
+require 'spec_helper'
+
+describe 'validate_numeric' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params(1, 2, 3, 4).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    [ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x'].each do |invalid|
+      it { is_expected.to run.with_params(invalid).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
+      it { is_expected.to run.with_params(invalid, 10.0).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
+      it { is_expected.to run.with_params(invalid, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
+    end
+
+    context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do
+      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError, /to be a Numeric/) }
+    end
+
+    context 'when running on ruby, which munges hashes weirdly', :if => RUBY_VERSION == '1.8.7' do
+      it { is_expected.to run.with_params([0, 1, 2, {1=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+      it { is_expected.to run.with_params([0, 1, 2, {0=>2}, 3, 4], 10, -10).and_raise_error(Puppet::ParseError) }
+    end
+
+    it { is_expected.to run.with_params(1, '').and_raise_error(Puppet::ParseError, /to be unset or a Numeric/) }
+    it { is_expected.to run.with_params(1, 2, '').and_raise_error(Puppet::ParseError, /to be unset or a Numeric/) }
+    it { is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError, /second argument to be larger than third argument/) }
+  end
+
+  context 'with no range constraints' do
+    it { is_expected.to run.with_params(1) }
+    it { is_expected.to run.with_params(-1) }
+    it { is_expected.to run.with_params('1') }
+    it { is_expected.to run.with_params('-1') }
+    it { is_expected.to run.with_params([1, 2, 3, 4]) }
+    it { is_expected.to run.with_params([1, '2', '3', 4]) }
+  end
+
+  context "with a maximum limit of 10.0" do
+    describe 'rejects numbers greater than the limit' do
+      it { is_expected.to run.with_params(11, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params(100, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params(2**65, 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      it { is_expected.to run.with_params([1,2,10.0,100], 10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+    end
+
+    describe 'accepts numbers less or equal to the limit' do
+      it { is_expected.to run.with_params(10.0, 10.0) }
+      it { is_expected.to run.with_params(1, 10.0) }
+      it { is_expected.to run.with_params(-1, 10.0) }
+      it { is_expected.to run.with_params('1', 10.0) }
+      it { is_expected.to run.with_params('-1', 10.0) }
+      it { is_expected.to run.with_params([1, 2, 3, 4], 10.0) }
+      it { is_expected.to run.with_params([1, '2', '3', 4], 10.0) }
+    end
+
+    context "with a minimum limit of -10.0" do
+      describe 'rejects numbers greater than the upper limit' do
+        it { is_expected.to run.with_params(11, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+        it { is_expected.to run.with_params(100, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+        it { is_expected.to run.with_params(2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+        it { is_expected.to run.with_params([1,2,10.0,100], 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be smaller or equal/) }
+      end
+
+      describe 'rejects numbers smaller than the lower limit' do
+        it { is_expected.to run.with_params(-11, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+        it { is_expected.to run.with_params(-100, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+        it { is_expected.to run.with_params(-2**65, 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+        it { is_expected.to run.with_params([-10.0, 1,2,10.0,-100], 10.0, -10.0).and_raise_error(Puppet::ParseError, /to be greater or equal/) }
+      end
+
+      describe 'accepts numbers between and including the limits' do
+        it { is_expected.to run.with_params(10.0, 10.0, -10.0) }
+        it { is_expected.to run.with_params(-10.0, 10.0, -10.0) }
+        it { is_expected.to run.with_params(1, 10.0, -10.0) }
+        it { is_expected.to run.with_params(-1, 10.0, -10.0) }
+        it { is_expected.to run.with_params('1', 10.0, -10.0) }
+        it { is_expected.to run.with_params('-1', 10.0, -10.0) }
+        it { is_expected.to run.with_params([1, 2, 3, 4], 10.0, -10.0) }
+        it { is_expected.to run.with_params([1, '2', '3', 4], 10.0, -10.0) }
+      end
+    end
+  end
+
+  it { is_expected.to run.with_params(10.0, 10.0, 10.0) }
+
+  describe 'empty upper limit is interpreted as infinity' do
+    it { is_expected.to run.with_params(11, '', 10.0) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_re_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_re_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_re_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,61 @@
+require 'spec_helper'
+
+describe 'validate_re' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params('', '') }
+      it { is_expected.to run.with_params('', ['']) }
+      it { is_expected.to run.with_params('', [''], 'custom error') }
+      it { is_expected.to run.with_params('one', '^one') }
+      it { is_expected.to run.with_params('one', [ '^one', '^two' ]) }
+      it { is_expected.to run.with_params('one', [ '^one', '^two' ], 'custom error') }
+    end
+
+    describe 'invalid inputs' do
+      it {
+        pending('should implement stricter type checking')
+        is_expected.to run.with_params([], '').and_raise_error(Puppet::ParseError, /is not a String/)
+      }
+      it {
+        pending('should implement stricter type checking')
+        is_expected.to run.with_params('', {}).and_raise_error(Puppet::ParseError, /is not an Array/)
+      }
+      it {
+        pending('should implement stricter type checking')
+        is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, /is not a String/)
+      }
+      it {
+        pending('should implement stricter type checking')
+        is_expected.to run.with_params(nil, nil).and_raise_error(Puppet::ParseError, /is not a String/)
+      }
+      it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, /does not match/) }
+      it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
+      it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
+      it { is_expected.to run.with_params('', ['two']).and_raise_error(Puppet::ParseError, /does not match/) }
+      it { is_expected.to run.with_params('', ['two'], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
+      it { is_expected.to run.with_params('notone', '^one').and_raise_error(Puppet::ParseError, /does not match/) }
+      it { is_expected.to run.with_params('notone', [ '^one', '^two' ]).and_raise_error(Puppet::ParseError, /does not match/) }
+      it { is_expected.to run.with_params('notone', [ '^one', '^two' ], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
+
+      describe 'non-string inputs' do
+        [
+          1,             # Fixnum
+          3.14,          # Float
+          nil,           # NilClass
+          true,          # TrueClass
+          false,         # FalseClass
+          ["10"],        # Array
+          :key,          # Symbol
+          {:key=>"val"}, # Hash
+        ].each do |input|
+          it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, /needs to be a String/) }
+        end
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_slength_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_slength_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_slength_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,61 @@
+require 'spec_helper'
+
+describe 'validate_slength' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('', 2, 3, 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /second argument to be a positive Numeric/) }
+    it { is_expected.to run.with_params('', -1).and_raise_error(Puppet::ParseError, /second argument to be a positive Numeric/) }
+    it { is_expected.to run.with_params('', 1, '').and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) }
+    it { is_expected.to run.with_params('', 1, -1).and_raise_error(Puppet::ParseError, /third argument to be unset or a positive Numeric/) }
+    it { is_expected.to run.with_params('', 1, 2).and_raise_error(Puppet::ParseError, /argument to be equal to or larger than third argument/) }
+  end
+
+  context "with a maximum length of 10" do
+    describe 'rejects strings longer than the limit' do
+      it { is_expected.to run.with_params('1234567890a', 10).and_raise_error(Puppet::ParseError, /Expected length/) }
+      it { is_expected.to run.with_params('1234567890abcdef', 10).and_raise_error(Puppet::ParseError, /Expected length/) }
+      it { is_expected.to run.with_params([ 'one', '1234567890abcdef' ], 10).and_raise_error(Puppet::ParseError, /Expected length/) }
+    end
+
+    describe 'accepts strings shorter or equal to the limit' do
+      it { is_expected.to run.with_params('1234567890', 10) }
+      it { is_expected.to run.with_params('12345', 10) }
+      it { is_expected.to run.with_params([ 'one', 'two' ], 10) }
+    end
+
+    context "with a minimum length of 5" do
+      describe 'rejects strings longer than the upper limit' do
+        it { is_expected.to run.with_params('1234567890a', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
+        it { is_expected.to run.with_params('1234567890abcdef', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
+      end
+
+      describe 'rejects numbers shorter than the lower limit' do
+        it { is_expected.to run.with_params('one', 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
+        it { is_expected.to run.with_params(['12345678', 'two'], 10, 5).and_raise_error(Puppet::ParseError, /Expected length/) }
+      end
+
+      describe 'accepts strings of length between and including the limits' do
+        it { is_expected.to run.with_params('12345', 10, 5) }
+        it { is_expected.to run.with_params('123456', 10, 5) }
+        it { is_expected.to run.with_params('1234567', 10, 5) }
+        it { is_expected.to run.with_params('12345678', 10, 5) }
+        it { is_expected.to run.with_params('123456789', 10, 5) }
+        it { is_expected.to run.with_params('1234567890', 10, 5) }
+        it { is_expected.to run.with_params(['1233456', '12345678'], 10, 5) }
+      end
+    end
+  end
+
+  describe 'corner cases' do
+    it { pending('this should work'); is_expected.to run.with_params('', 0, 0) }
+    it { is_expected.to run.with_params('1234567890', 10, 10) }
+  end
+
+  describe 'empty upper limit is interpreted as infinity' do
+    it { pending('not implemented'); is_expected.to run.with_params('1234567890ab', '', 10) }
+    it { pending('not implemented'); is_expected.to run.with_params('12345678', '', 10).and_raise_error(Puppet::ParseError, /Expected length/) }
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_string_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_string_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe 'validate_string' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+
+    describe 'valid inputs' do
+      it { is_expected.to run.with_params('') }
+      it { is_expected.to run.with_params('one') }
+      it { is_expected.to run.with_params('one', 'two') }
+    end
+
+    describe 'invalid inputs' do
+      it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/validate_x509_rsa_key_pair_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,180 @@
+require 'spec_helper'
+
+describe 'validate_x509_rsa_key_pair' do
+
+  let(:valid_cert) do
+  <<EOS
+-----BEGIN CERTIFICATE-----
+MIIC9jCCAeCgAwIBAgIRAK11n3X7aypJ7FPM8UFyAeowCwYJKoZIhvcNAQELMBIx
+EDAOBgNVBAoTB0FjbWUgQ28wHhcNMTUxMTIzMjIzOTU4WhcNMTYxMTIyMjIzOTU4
+WjASMRAwDgYDVQQKEwdBY21lIENvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
+CgKCAQEAz9bY/piKahD10AiJSfbI2A8NG5UwRz0r9T/WfvNVdhgrsGFgNQjvpUoZ
+nNJpQIHBbgMOiXqfATFjJl5FjEkSf7GUHohlGVls9MX2JmVvknzsiitd75H/EJd+
+N+k915lix8Vqmj8d1CTlbF/8tEjzANI67Vqw5QTuqebO7rkIUvRg6yiRfSo75FK1
+RinCJyl++kmleBwQZBInQyg95GvJ5JTqMzBs67DeeyzskDhTeTePRYVF2NwL8QzY
+htvLIBERTNsyU5i7nkxY5ptUwgFUwd93LH4Q19tPqL5C5RZqXxhE51thOOwafm+a
+W/cRkqYqV+tv+j1jJ3WICyF1JNW0BQIDAQABo0swSTAOBgNVHQ8BAf8EBAMCAKAw
+EwYDVR0lBAwwCgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADAUBgNVHREEDTALggls
+b2NhbGhvc3QwCwYJKoZIhvcNAQELA4IBAQAzRo0hpVTrFQZLIXpwvKwZVGvJdCkV
+P95DTsSk/VTGV+/YtxrRqks++hJZnctm2PbnTsCAoIP3AMx+vicCKiKrxvpsLU8/
++6cowUbcuGMdSQktwDqbAgEhQlLsETll06w1D/KC+ejOc4+LRn3GQcEyGDtMk/EX
+IeAvBZHr4/kVXWnfo6kzCLcku1f8yE/yDEFClZe9XV1Lk/s+3YfXVtNnMJJ1giZI
+QVOe6CkmuQq+4AtIeW8aLkvlfp632jag1F77a1y+L268koKkj0hBMrtcErVQaxmq
+xym0+soR4Tk4pTIGckeFglrLxkP2JpM/yTwSEAVlmG9vgTliYKyR0uMl
+-----END CERTIFICATE-----
+EOS
+  end
+
+  let(:valid_key) do
+  <<EOS
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEAz9bY/piKahD10AiJSfbI2A8NG5UwRz0r9T/WfvNVdhgrsGFg
+NQjvpUoZnNJpQIHBbgMOiXqfATFjJl5FjEkSf7GUHohlGVls9MX2JmVvknzsiitd
+75H/EJd+N+k915lix8Vqmj8d1CTlbF/8tEjzANI67Vqw5QTuqebO7rkIUvRg6yiR
+fSo75FK1RinCJyl++kmleBwQZBInQyg95GvJ5JTqMzBs67DeeyzskDhTeTePRYVF
+2NwL8QzYhtvLIBERTNsyU5i7nkxY5ptUwgFUwd93LH4Q19tPqL5C5RZqXxhE51th
+OOwafm+aW/cRkqYqV+tv+j1jJ3WICyF1JNW0BQIDAQABAoIBADAiZ/r+xP+vkd5u
+O61/lCBFzBlZQecdybJw6HJaVK6XBndA9hESUr4LHUdui6W+51ddKd65IV4bXAUk
+zCKjQb+FFvLDT/bA+TTvLATUdTSN7hJJ3OWBAHuNOlQklof6JCB0Hi4+89+P8/pX
+eKUgR/cmuTMDT/iaXdPHeqFbBQyA1ZpQFRjN5LyyJMS/9FkywuNc5wlpsArtc51T
+gIKENUZCuPhosR+kMFc2iuTNvqZWPhvouSrmhi2O6nSqV+oy0+irlqSpCF2GsCI8
+72TtLpq94Grrq0BEH5avouV+Lp4k83vO65OKCQKUFQlxz3Xkxm2U3J7KzxqnRtM3
+/b+cJ/kCgYEA6/yOnaEYhH/7ijhZbPn8RujXZ5VGJXKJqIuaPiHMmHVS5p1j6Bah
+2PcnqJA2IlLs3UloN+ziAxAIH6KCBiwlQ/uPBNMMaJsIjPNBEy8axjndKhKUpidg
+R0OJ7RQqMShOJ8akrSfWdPtXC/GBuwCYE//t77GgZaIMO3FcT9EKA48CgYEA4Xcx
+Fia0Jg9iyAhNmUOXI6hWcGENavMx01+x7XFhbnMjIKTZevFfTnTkrX6HyLXyGtMU
+gHOn+k4PE/purI4ARrKO8m5wYEKqSIt4dBMTkIXXirfQjXgfjR8E4T/aPe5fOFZo
+7OYuxLRtzmG1C2sW4txwKAKX1LaWcVx/RLSttSsCgYBbcj8Brk+F6OJcqYFdzXGJ
+OOlf5mSMVlopyg83THmwCqbZXtw8L6kAHqZrl5airmfDSJLuOQlMDoZXW+3u3mSC
+d5TwVahVUN57YDgzaumBLyMZDqIz0MZqVy23hTzkV64Rk9R0lR9xrYQJyMhw4sYL
+2f0mCTsSpzz+O+t9so+i2QKBgEC38gMlwPhb2kMI/x1LZYr6uzUu5qcYf+jowy4h
+KZKGwkKQj0zXFEB1FV8nvtpCP+irRmtIx6L13SYi8LnfWPzyLE4ynVdES5TfVAgd
+obQOdzx+XwL8xDHCAaiWp5K3ZeXKB/xYZnxYPlzLdyh76Ond1OPnOqX4c16+6llS
+c7pZAoGATd9NckT0XtXLEsF3IraDivq8dP6bccX2DNfS8UeEvRRrRwpFpSRrmuGb
+jbG4yzoIX4RjQfj/z48hwhJB+cKiN9WwcPsFXtHe7v3F6BRwK0JUfrCiXad8/SGZ
+KAf7Dfqi608zBdnPWHacre2Y35gPHB00nFQOLS6u46aBNSq07YA=
+-----END RSA PRIVATE KEY-----
+EOS
+  end
+
+  let(:another_valid_key) do
+  <<EOS
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEAoISxYJBTPAeAzFnm+lE/ljLlmGal2Xr3vwZKkvJiuKA/m4QJ
+0ZNdtkBSDOVuG2dXVv6W4sChRtsCdvuVe7bjTYvlU8TWM3VEJDL9l9cRXScxxlKQ
+Xwb35y1yV35NJfaK/jzm9KcErtQQs1RxvGlWRaohmLM8uQcuhjZfMsSlQoHQD5LX
+sbPtk82RPyxYc1dj2vsaoi1VvuP2+jv4xLQOmNJY1bT5GTurqiltmxEtWhNNmGg0
+2wtK00ifqLVO5HNc3gXQCDM2M99Sbmn1YtbrgsU9xMYfcPmvQvb+YoKskyoqck+c
+HR//hi7vslbxABrny15LBkEfRc4TickphSGYXwIDAQABAoIBAATEzGw8/WwMIQRx
+K06GeWgh7PZBHm4+m/ud2TtSXiJ0CE+7dXs3cJJIiOd/LW08/bhE6gCkjmYHfaRB
+Ryicv1X/cPmzIFX5BuQ4a5ZGOmrVDkKBE27vSxAgJoR46RvWnjx9XLMp/xaekDxz
+psldK8X4DvV1ZbltgDFWji947hvyqUtHdKnkQnc5j7aCIFJf9GMfzaeeDPMaL8WF
+mVL4iy9EAOjNOHBshZj/OHyU5FbJ8ROwZQlCOiLCdFegftSIXt8EYDnjB3BdsALH
+N6hquqrD7xDKyRbTD0K7lqxUubuMwTQpi61jZD8TBTXEPyFVAnoMpXkc0Y+np40A
+YiIsR+kCgYEAyrc4Bh6fb9gt49IXGXOSRZ5i5+TmJho4kzIONrJ7Ndclwx9wzHfh
+eGBodWaw5CxxQGMf4vEiaZrpAiSFeDffBLR+Wa2TFE5aWkdYkR34maDjO00m4PE1
+S+YsZoGw7rGmmj+KS4qv2T26FEHtUI+F31RC1FPohLsQ22Jbn1ORipsCgYEAyrYB
+J2Ncf2DlX1C0GfxyUHQOTNl0V5gpGvpbZ0WmWksumYz2kSGOAJkxuDKd9mKVlAcz
+czmN+OOetuHTNqds2JJKKJy6hJbgCdd9aho3dId5Xs4oh4YwuFQiG8R/bJZfTlXo
+99Qr02L7MmDWYLmrR3BA/93UPeorHPtjqSaYU40CgYEAtmGfWwokIglaSDVVqQVs
+3YwBqmcrla5TpkMLvLRZ2/fktqfL4Xod9iKu+Klajv9ZKTfFkXWno2HHL7FSD/Yc
+hWwqnV5oDIXuDnlQOse/SeERb+IbD5iUfePpoJQgbrCQlwiB0TNGwOojR2SFMczf
+Ai4aLlQLx5dSND9K9Y7HS+8CgYEAixlHQ2r4LuQjoTs0ytwi6TgqE+vn3K+qDTwc
+eoods7oBWRaUn1RCKAD3UClToZ1WfMRQNtIYrOAsqdveXpOWqioAP0wE5TTOuZIo
+GiWxRgIsc7TNtOmNBv+chCdbNP0emxdyjJUIGb7DFnfCw47EjHnn8Guc13uXaATN
+B2ZXgoUCgYAGa13P0ggUf5BMJpBd8S08jKRyvZb1CDXcUCuGtk2yEx45ern9U5WY
+zJ13E5z9MKKO8nkGBqrRfjJa8Xhxk4HKNFuzHEet5lvNE7IKCF4YQRb0ZBhnb/78
++4ZKjFki1RrWRNSw9TdvrK6qaDKgTtCTtfRVXAYQXUgq7lSFOTtL3A==
+-----END RSA PRIVATE KEY-----
+EOS
+  end
+
+  let(:valid_cert_but_indented) do
+    valid_cert.gsub(/^/, '  ')
+  end
+
+  let(:valid_key_but_indented) do
+    valid_key.gsub(/^/, '  ')
+  end
+
+  let(:malformed_cert) do
+    truncate_middle(valid_cert)
+  end
+
+  let(:malformed_key) do
+    truncate_middle(valid_key)
+  end
+
+  let(:bad_cert) do
+    'foo'
+  end
+
+  let(:bad_key) do
+    'bar'
+  end
+
+  context 'function signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params(0, 1, 2, 3).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  end
+
+  context 'valid input' do
+    describe 'valid certificate and key' do
+      it { is_expected.to run.with_params(valid_cert, valid_key) }
+    end
+  end
+
+  context 'bad input' do
+    describe 'valid certificate, valid but indented key' do
+      it { is_expected.to run.with_params(valid_cert, valid_key_but_indented).and_raise_error(Puppet::ParseError, /Not a valid RSA key/) }
+    end
+
+    describe 'valid certificate, malformed key' do
+      it { is_expected.to run.with_params(valid_cert, malformed_key).and_raise_error(Puppet::ParseError, /Not a valid RSA key/) }
+    end
+
+    describe 'valid certificate, bad key' do
+      it { is_expected.to run.with_params(valid_cert, bad_key).and_raise_error(Puppet::ParseError, /Not a valid RSA key/) }
+    end
+
+    describe 'valid but indented certificate, valid key' do
+      it { is_expected.to run.with_params(valid_cert_but_indented, valid_key).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+    end
+
+    describe 'malformed certificate, valid key' do
+      it { is_expected.to run.with_params(malformed_cert, valid_key).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+    end
+
+    describe 'bad certificate, valid key' do
+      it { is_expected.to run.with_params(bad_cert, valid_key).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+    end
+
+    describe 'validate certificate and key; certficate not signed by key' do
+      it { is_expected.to run.with_params(valid_cert, another_valid_key).and_raise_error(Puppet::ParseError, /Certificate signature does not match supplied key/) }
+    end
+
+    describe 'valid cert and key but arguments in wrong order' do
+      it { is_expected.to run.with_params(valid_key, valid_cert).and_raise_error(Puppet::ParseError, /Not a valid x509 certificate/) }
+    end
+
+    describe 'non-string arguments' do
+      it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(true, true).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params("foo", {}).and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params(1, "bar").and_raise_error(Puppet::ParseError, /is not a string/) }
+      it { is_expected.to run.with_params("baz", true).and_raise_error(Puppet::ParseError, /is not a string/) }
+    end
+  end
+
+  def truncate_middle(string)
+    chars_to_truncate = 48
+    middle = (string.length / 2).floor
+    start_pos = middle - (chars_to_truncate / 2)
+    end_pos = middle + (chars_to_truncate / 2)
+
+    string[start_pos...end_pos] = ''
+    return string
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/values_at_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/values_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/values_at_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,49 @@
+require 'spec_helper'
+
+describe 'values_at' do
+  describe 'signature validation' do
+    it { is_expected.not_to eq(nil) }
+    it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+    it {
+      pending("Current implementation ignores parameters after the first two.")
+      is_expected.to run.with_params([], 0, 1).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+    }
+    it { is_expected.to run.with_params('', 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
+    it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
+    it { is_expected.to run.with_params(true, 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
+    it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, /Requires array/i) }
+    it { is_expected.to run.with_params([0,1,2], 'two').and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
+    it { is_expected.to run.with_params([0,1,2], []).and_raise_error(Puppet::ParseError, /provide at least one positive index/) }
+    it { is_expected.to run.with_params([0,1,2], '-1-1').and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
+    it { is_expected.to run.with_params([0,1,2], '2-1').and_raise_error(Puppet::ParseError, /Stop index in given indices range is smaller than the start index/) }
+  end
+
+  context 'when requesting a single item' do
+    it { is_expected.to run.with_params([0, 1, 2], -1).and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
+    it { is_expected.to run.with_params([0, 1, 2], 0).and_return([0]) }
+    it { is_expected.to run.with_params([0, 1, 2], 1).and_return([1]) }
+    it { is_expected.to run.with_params([0, 1, 2], [1]).and_return([1]) }
+    it { is_expected.to run.with_params([0, 1, 2], '1').and_return([1]) }
+    it { is_expected.to run.with_params([0, 1, 2], '1-1').and_return([1]) }
+    it { is_expected.to run.with_params([0, 1, 2], 2).and_return([2]) }
+    it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, /index exceeds array size/) }
+  end
+
+  context 'when requesting multiple items' do
+    it { is_expected.to run.with_params([0, 1, 2], [1, -1]).and_raise_error(Puppet::ParseError, /Unknown format of given index/) }
+    it { is_expected.to run.with_params([0, 1, 2], [0, 2]).and_return([0, 2]) }
+    it { is_expected.to run.with_params([0, 1, 2], ['0-2', 1, 2]).and_return([0, 1, 2, 1, 2]) }
+    it { is_expected.to run.with_params([0, 1, 2], [3, 2]).and_raise_error(Puppet::ParseError, /index exceeds array size/) }
+
+    describe 'different range syntaxes' do
+      it { is_expected.to run.with_params([0, 1, 2], '0-2').and_return([0, 1, 2]) }
+      it { is_expected.to run.with_params([0, 1, 2], '0..2').and_return([0, 1, 2]) }
+      it { is_expected.to run.with_params([0, 1, 2], '0...2').and_return([0, 1]) }
+      it {
+        pending('fix this bounds check')
+        is_expected.to run.with_params([0, 1, 2], '0...3').and_return([0, 1, 2])
+      }
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/values_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/values_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'values' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the first.")
+    is_expected.to run.with_params({}, 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /Requires hash to work with/) }
+  it { is_expected.to run.with_params({}).and_return([]) }
+  it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['value']) }
+  it 'should return the array of values' do
+    result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2', 'duplicate_value_key' => 'value2' }])
+    expect(result).to match_array(['value1', 'value2', 'value2'])
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/functions/zip_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/functions/zip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/functions/zip_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe 'zip' do
+  it { is_expected.not_to eq(nil) }
+  it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+  it {
+    pending("Current implementation ignores parameters after the third.")
+    is_expected.to run.with_params([], [], true, []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
+  }
+  it { is_expected.to run.with_params([], []).and_return([]) }
+  it { is_expected.to run.with_params([1,2,3], [4,5,6]).and_return([[1,4], [2,5], [3,6]]) }
+  it { is_expected.to run.with_params([1,2,3], [4,5,6], false).and_return([[1,4], [2,5], [3,6]]) }
+  it { is_expected.to run.with_params([1,2,3], [4,5,6], true).and_return([1, 4, 2, 5, 3, 6]) }
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,9 @@
+#! /usr/bin/env ruby -S rspec
+require 'rspec'
+
+class Object
+  # This is necessary because the RAL has a 'should'
+  # method.
+  alias :must :should
+  alias :must_not :should_not
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/monkey_patches/publicize_methods.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/monkey_patches/publicize_methods.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/monkey_patches/publicize_methods.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,11 @@
+#! /usr/bin/env ruby -S rspec
+# Some monkey-patching to allow us to test private methods.
+class Class
+    def publicize_methods(*methods)
+        saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods
+
+        self.class_eval { public(*saved_private_instance_methods) }
+        yield
+        self.class_eval { private(*saved_private_instance_methods) }
+    end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/spec_helper.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/spec_helper.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/spec_helper.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,8 @@
+#This file is generated by ModuleSync, do not edit.
+require 'puppetlabs_spec_helper/module_spec_helper'
+
+# put local configuration and setup into spec_helper_local
+begin
+  require 'spec_helper_local'
+rescue LoadError
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/spec_helper_acceptance.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/spec_helper_acceptance.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/spec_helper_acceptance.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,70 @@
+#! /usr/bin/env ruby -S rspec
+require 'beaker-rspec'
+require 'beaker/puppet_install_helper'
+
+UNSUPPORTED_PLATFORMS = []
+
+run_puppet_install_helper
+
+RSpec.configure do |c|
+  # Project root
+  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+  # Readable test descriptions
+  c.formatter = :documentation
+
+  # Configure all nodes in nodeset
+  c.before :suite do
+    if ENV['FUTURE_PARSER'] == 'yes'
+      default[:default_apply_opts] ||= {}
+      default[:default_apply_opts].merge!({:parser => 'future'})
+    end
+
+    copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib')
+  end
+end
+
+def is_future_parser_enabled?
+  if default[:type] == 'aio'
+    return true
+  elsif default[:default_apply_opts]
+    return default[:default_apply_opts][:parser] == 'future'
+  end
+  return false
+end
+
+def get_puppet_version
+  (on default, puppet('--version')).output.chomp
+end
+
+RSpec.shared_context "with faked facts" do
+  let(:facts_d) do
+    puppet_version = get_puppet_version
+    if fact('osfamily') =~ /windows/i
+      if fact('kernelmajversion').to_f < 6.0
+        'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
+      else
+        'C:/ProgramData/PuppetLabs/facter/facts.d'
+      end
+    elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true"
+      '/etc/puppetlabs/facter/facts.d'
+    else
+      '/etc/facter/facts.d'
+    end
+  end
+
+  before :each do
+    #No need to create on windows, PE creates by default
+    if fact('osfamily') !~ /windows/i
+      shell("mkdir -p '#{facts_d}'")
+    end
+  end
+
+  after :each do
+    shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0,1])
+  end
+
+  def fake_fact(name, value)
+    shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'")
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/spec_helper_local.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/spec_helper_local.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/spec_helper_local.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,29 @@
+
+# hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
+RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
+
+RSpec.configure do |config|
+  # supply tests with a possibility to test for the future parser
+  config.add_setting :puppet_future
+  config.puppet_future = Puppet.version.to_f >= 4.0
+
+  config.before :each do
+    # Ensure that we don't accidentally cache facts and environment between
+    # test cases.  This requires each example group to explicitly load the
+    # facts being exercised with something like
+    # Facter.collection.loader.load(:ipaddress)
+    Facter.clear
+    Facter.clear_messages
+    
+    RSpec::Mocks.setup
+  end
+
+  config.after :each do
+    RSpec::Mocks.verify
+    RSpec::Mocks.teardown
+  end
+end
+
+# Helper class to test handling of arguments which are derived from string
+class AlsoString < String
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/facter_dot_d_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,32 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+require 'facter/facter_dot_d'
+
+describe Facter::Util::DotD do
+
+  context 'returns a simple fact' do
+    before :each do
+      Facter.stubs(:version).returns('1.6.1')
+      subject.stubs(:entries).returns(['/etc/facter/facts.d/fake_fact.txt'])
+      File.stubs(:readlines).with('/etc/facter/facts.d/fake_fact.txt').returns(['fake_fact=fake fact'])
+      subject.create
+    end
+
+    it 'should return successfully' do
+      expect(Facter.fact(:fake_fact).value).to eq('fake fact')
+    end
+  end
+
+  context 'returns a fact with equals signs' do
+    before :each do
+      Facter.stubs(:version).returns('1.6.1')
+      subject.stubs(:entries).returns(['/etc/facter/facts.d/foo.txt'])
+      File.stubs(:readlines).with('/etc/facter/facts.d/foo.txt').returns(['foo=1+1=2'])
+      subject.create
+    end
+
+    it 'should return successfully' do
+      expect(Facter.fact(:foo).value).to eq('1+1=2')
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/package_provider_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/package_provider_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/package_provider_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,44 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+require 'puppet/type'
+require 'puppet/type/package'
+
+describe 'package_provider', :type => :fact do
+  before { Facter.clear }
+  after { Facter.clear }
+
+  ['4.2.2', '3.7.1 (Puppet Enterprise 3.2.1)'].each do |puppetversion|
+    describe "on puppet ''#{puppetversion}''" do
+      before :each do
+        Facter.stubs(:value).returns puppetversion
+      end
+
+      context "darwin" do
+        it "should return pkgdmg" do
+          provider = Puppet::Type.type(:package).provider(:pkgdmg)
+          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+
+          expect(Facter.fact(:package_provider).value).to eq('pkgdmg')
+        end
+      end
+
+      context "centos 7" do
+        it "should return yum" do
+          provider = Puppet::Type.type(:package).provider(:yum)
+          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+
+          expect(Facter.fact(:package_provider).value).to eq('yum')
+        end
+      end
+
+      context "ubuntu" do
+        it "should return apt" do
+          provider = Puppet::Type.type(:package).provider(:apt)
+          Puppet::Type.type(:package).stubs(:defaultprovider).returns provider
+
+          expect(Facter.fact(:package_provider).value).to eq('apt')
+        end
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/pe_version_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/pe_version_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/pe_version_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,88 @@
+#!/usr/bin/env rspec
+
+require 'spec_helper'
+
+describe "PE Version specs" do
+  before :each do
+    # Explicitly load the pe_version.rb file which contains generated facts
+    # that cannot be automatically loaded.  Puppet 2.x implements
+    # Facter.collection.load while Facter 1.x markes Facter.collection.load as
+    # a private method.
+    if Facter.collection.respond_to? :load
+      Facter.collection.load(:pe_version)
+    else
+      Facter.collection.loader.load(:pe_version)
+    end
+  end
+  
+  context "When puppetversion is nil" do
+    before :each do
+      Facter.fact(:puppetversion).stubs(:value).returns(nil)
+    end
+    
+    it "pe_version is nil" do
+      expect(Facter.fact(:puppetversion).value).to be_nil
+      expect(Facter.fact(:pe_version).value).to be_nil
+    end
+  end
+
+  context "If PE is installed" do
+    %w{ 2.6.1 2.10.300 }.each do |version|
+      puppetversion = "2.7.19 (Puppet Enterprise #{version})"
+      context "puppetversion => #{puppetversion}" do
+        before :each do
+          Facter.fact(:puppetversion).stubs(:value).returns(puppetversion)
+        end
+
+        (major,minor,patch) = version.split(".")
+
+        it "Should return true" do
+          expect(Facter.fact(:is_pe).value).to eq(true)
+        end
+
+        it "Should have a version of #{version}" do
+          expect(Facter.fact(:pe_version).value).to eq(version)
+        end
+
+        it "Should have a major version of #{major}" do
+          expect(Facter.fact(:pe_major_version).value).to eq(major)
+        end
+
+        it "Should have a minor version of #{minor}" do
+          expect(Facter.fact(:pe_minor_version).value).to eq(minor)
+        end
+
+        it "Should have a patch version of #{patch}" do
+          expect(Facter.fact(:pe_patch_version).value).to eq(patch)
+        end
+      end
+    end
+  end
+
+  context "When PE is not installed" do
+    before :each do
+      Facter.fact(:puppetversion).stubs(:value).returns("2.7.19")
+    end
+
+    it "is_pe is false" do
+      expect(Facter.fact(:is_pe).value).to eq(false)
+    end
+
+    it "pe_version is nil" do
+      expect(Facter.fact(:pe_version).value).to be_nil
+    end
+
+    it "pe_major_version is nil" do
+      expect(Facter.fact(:pe_major_version).value).to be_nil
+    end
+
+    it "pe_minor_version is nil" do
+      expect(Facter.fact(:pe_minor_version).value).to be_nil
+    end
+
+    it "Should have a patch version" do
+      expect(Facter.fact(:pe_patch_version).value).to be_nil
+    end
+  end
+
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/root_home_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/root_home_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/root_home_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,65 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+require 'facter/root_home'
+
+describe Facter::Util::RootHome do
+  context "solaris" do
+    let(:root_ent) { "root:x:0:0:Super-User:/:/sbin/sh" }
+    let(:expected_root_home) { "/" }
+
+    it "should return /" do
+      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
+      expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home)
+    end
+  end
+  context "linux" do
+    let(:root_ent) { "root:x:0:0:root:/root:/bin/bash" }
+    let(:expected_root_home) { "/root" }
+
+    it "should return /root" do
+      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
+      expect(Facter::Util::RootHome.get_root_home).to eq(expected_root_home)
+    end
+  end
+  context "windows" do
+    before :each do
+      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil)
+    end
+    it "should be nil on windows" do
+      expect(Facter::Util::RootHome.get_root_home).to be_nil
+    end
+  end
+end
+
+describe 'root_home', :type => :fact do
+  before { Facter.clear }
+  after { Facter.clear }
+
+  context "macosx" do
+    before do
+      Facter.fact(:kernel).stubs(:value).returns("Darwin")
+      Facter.fact(:osfamily).stubs(:value).returns("Darwin")
+    end
+    let(:expected_root_home) { "/var/root" }
+    sample_dscacheutil = File.read(fixtures('dscacheutil','root'))
+
+    it "should return /var/root" do
+      Facter::Util::Resolution.stubs(:exec).with("dscacheutil -q user -a name root").returns(sample_dscacheutil)
+      expect(Facter.fact(:root_home).value).to eq(expected_root_home)
+    end
+  end
+
+  context "aix" do
+    before do
+      Facter.fact(:kernel).stubs(:value).returns("AIX")
+      Facter.fact(:osfamily).stubs(:value).returns("AIX")
+    end
+    let(:expected_root_home) { "/root" }
+    sample_lsuser = File.read(fixtures('lsuser','root'))
+
+    it "should return /root" do
+      Facter::Util::Resolution.stubs(:exec).with("lsuser -c -a home root").returns(sample_lsuser)
+      expect(Facter.fact(:root_home).value).to eq(expected_root_home)
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/service_provider_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/service_provider_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/service_provider_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+require 'puppet/type'
+require 'puppet/type/service'
+
+describe 'service_provider', :type => :fact do
+  before { Facter.clear }
+  after { Facter.clear }
+
+  context "macosx" do
+    it "should return launchd" do
+      provider = Puppet::Type.type(:service).provider(:launchd)
+      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+
+      expect(Facter.fact(:service_provider).value).to eq('launchd')
+    end
+  end
+
+  context "systemd" do
+    it "should return systemd" do
+      provider = Puppet::Type.type(:service).provider(:systemd)
+      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+
+      expect(Facter.fact(:service_provider).value).to eq('systemd')
+    end
+  end
+
+  context "redhat" do
+    it "should return redhat" do
+      provider = Puppet::Type.type(:service).provider(:redhat)
+      Puppet::Type.type(:service).stubs(:defaultprovider).returns provider
+
+      expect(Facter.fact(:service_provider).value).to eq('redhat')
+    end
+  end
+
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,37 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+require 'facter/util/puppet_settings'
+
+describe Facter::Util::PuppetSettings do
+
+  describe "#with_puppet" do
+    context "Without Puppet loaded" do
+      before(:each) do
+        Module.expects(:const_get).with("Puppet").raises(NameError)
+      end
+
+      it 'should be nil' do
+        expect(subject.with_puppet { Puppet[:vardir] }).to be_nil
+      end
+      it 'should not yield to the block' do
+        Puppet.expects(:[]).never
+        expect(subject.with_puppet { Puppet[:vardir] }).to be_nil
+      end
+    end
+    context "With Puppet loaded" do
+      module Puppet; end
+      let(:vardir) { "/var/lib/puppet" }
+
+      before :each do
+        Puppet.expects(:[]).with(:vardir).returns vardir
+      end
+
+      it 'should yield to the block' do
+        subject.with_puppet { Puppet[:vardir] }
+      end
+      it 'should return the nodes vardir' do
+        expect(subject.with_puppet { Puppet[:vardir] }).to eq vardir
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,69 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+
+describe "the enclose_ipv6 function" do
+  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+
+  it "should exist" do
+    expect(Puppet::Parser::Functions.function("enclose_ipv6")).to eq("function_enclose_ipv6")
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    expect { scope.function_enclose_ipv6([]) }.to( raise_error(Puppet::ParseError) )
+  end
+
+  it "should raise a ParseError if there is more than 1 arguments" do
+    expect { scope.function_enclose_ipv6(['argument1','argument2']) }.to( raise_error(Puppet::ParseError) )
+  end
+
+  it "should raise a ParseError when given garbage" do
+    expect { scope.function_enclose_ipv6(['garbage']) }.to( raise_error(Puppet::ParseError) )
+  end
+
+  it "should raise a ParseError when given something else than a string or an array" do
+    expect { scope.function_enclose_ipv6([['1' => '127.0.0.1']]) }.to( raise_error(Puppet::ParseError) )
+  end
+
+  it "should not raise a ParseError when given a single ip string" do
+    expect { scope.function_enclose_ipv6(['127.0.0.1']) }.to_not raise_error
+  end
+
+  it "should not raise a ParseError when given * as ip string" do
+    expect { scope.function_enclose_ipv6(['*']) }.to_not raise_error
+  end
+
+  it "should not raise a ParseError when given an array of ip strings" do
+    expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1']]) }.to_not raise_error
+  end
+
+  it "should not raise a ParseError when given differently notations of ip addresses" do
+    expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::1]']]) }.to_not raise_error
+  end
+
+  it "should raise a ParseError when given a wrong ipv4 address" do
+    expect { scope.function_enclose_ipv6(['127..0.0.1']) }.to( raise_error(Puppet::ParseError) )
+  end
+
+  it "should raise a ParseError when given a ipv4 address with square brackets" do
+    expect { scope.function_enclose_ipv6(['[127.0.0.1]']) }.to( raise_error(Puppet::ParseError) )
+  end
+
+  it "should raise a ParseError when given a wrong ipv6 address" do
+    expect { scope.function_enclose_ipv6(['fe80:::1']) }.to( raise_error(Puppet::ParseError) )
+  end
+
+  it "should embrace ipv6 adresses within an array of ip addresses" do
+    result = scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::2]']])
+    expect(result).to(eq(['127.0.0.1','[fe80::1]','[fe80::2]']))
+  end
+
+  it "should embrace a single ipv6 adresse" do
+    result = scope.function_enclose_ipv6(['fe80::1'])
+    expect(result).to(eq(['[fe80::1]']))
+  end
+
+  it "should not embrace a single ipv4 adresse" do
+    result = scope.function_enclose_ipv6(['127.0.0.1'])
+    expect(result).to(eq(['127.0.0.1']))
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/parser/functions/is_absolute_path_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,86 @@
+require 'spec_helper'
+
+describe :is_absolute_path do
+  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
+
+  let(:function_args) do
+    []
+  end
+
+  let(:function) do
+    scope.function_is_absolute_path(function_args)
+  end
+
+
+  describe 'validate arity' do
+    let(:function_args) do
+       [1,2]
+    end
+    it "should raise a ParseError if there is more than 1 arguments" do
+      lambda { function }.should( raise_error(ArgumentError))
+    end
+
+  end
+  
+  it "should exist" do
+    Puppet::Parser::Functions.function(subject).should == "function_#{subject}"
+  end
+
+  # help enforce good function defination
+  it 'should contain arity' do
+
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { function }.should( raise_error(ArgumentError))
+  end
+
+
+  describe 'should retrun true' do
+    let(:return_value) do
+      true
+    end
+
+    describe 'windows' do
+      let(:function_args) do
+        ['c:\temp\test.txt']
+      end
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+
+    describe 'non-windows' do
+      let(:function_args) do
+        ['/temp/test.txt']
+      end
+
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+  end
+
+  describe 'should return false' do
+    let(:return_value) do
+      false
+    end
+    describe 'windows' do
+      let(:function_args) do
+        ['..\temp\test.txt']
+      end
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+
+    describe 'non-windows' do
+      let(:function_args) do
+        ['../var/lib/puppet']
+      end
+      it 'should return data' do
+        function.should eq(return_value)
+      end
+    end
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,440 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+require 'tempfile'
+provider_class = Puppet::Type.type(:file_line).provider(:ruby)
+describe provider_class do
+  context "when adding" do
+    let :tmpfile do
+      tmp = Tempfile.new('tmp')
+      path = tmp.path
+      tmp.close!
+      path
+    end
+    let :resource do
+      Puppet::Type::File_line.new(
+        {:name => 'foo', :path => tmpfile, :line => 'foo'}
+      )
+    end
+    let :provider do
+      provider_class.new(resource)
+    end
+
+    it 'should detect if the line exists in the file' do
+      File.open(tmpfile, 'w') do |fh|
+        fh.write('foo')
+      end
+      expect(provider.exists?).to be_truthy
+    end
+    it 'should detect if the line does not exist in the file' do
+      File.open(tmpfile, 'w') do |fh|
+        fh.write('foo1')
+      end
+      expect(provider.exists?).to be_nil
+    end
+    it 'should append to an existing file when creating' do
+      provider.create
+      expect(File.read(tmpfile).chomp).to eq('foo')
+    end
+  end
+  context 'when using replace' do
+    before :each do
+      # TODO: these should be ported over to use the PuppetLabs spec_helper
+      #  file fixtures once the following pull request has been merged:
+      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
+      tmp = Tempfile.new('tmp')
+      @tmpfile = tmp.path
+      tmp.close!
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name    => 'foo',
+          :path    => @tmpfile,
+          :line    => 'foo = bar',
+          :match   => '^foo\s*=.*$',
+          :replace => false,
+        }
+      )
+      @provider = provider_class.new(@resource)
+    end
+
+    it 'should not replace the matching line' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo=blah\nfoo2\nfoo3")
+      end
+      expect(@provider.exists?).to be_truthy
+      @provider.create
+      expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo=blah\nfoo2\nfoo3")
+    end
+
+    it 'should append the line if no matches are found' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo2")
+      end
+      expect(@provider.exists?).to be_nil
+      @provider.create
+      expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo2\nfoo = bar")
+    end
+
+    it 'should raise an error with invalid values' do
+      expect {
+        @resource = Puppet::Type::File_line.new(
+          {
+            :name     => 'foo',
+            :path     => @tmpfile,
+            :line     => 'foo = bar',
+            :match    => '^foo\s*=.*$',
+            :replace  => 'asgadga',
+          }
+        )
+      }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./)
+    end
+  end
+  context "when matching" do
+    before :each do
+      # TODO: these should be ported over to use the PuppetLabs spec_helper
+      #  file fixtures once the following pull request has been merged:
+      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
+      tmp = Tempfile.new('tmp')
+      @tmpfile = tmp.path
+      tmp.close!
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name  => 'foo',
+          :path  => @tmpfile,
+          :line  => 'foo = bar',
+          :match => '^foo\s*=.*$',
+        }
+      )
+      @provider = provider_class.new(@resource)
+    end
+
+    describe 'using match' do
+      it 'should raise an error if more than one line matches, and should not have modified the file' do
+        File.open(@tmpfile, 'w') do |fh|
+          fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
+        end
+        expect(@provider.exists?).to be_nil
+        expect { @provider.create }.to raise_error(Puppet::Error, /More than one line.*matches/)
+        expect(File.read(@tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz")
+      end
+
+      it 'should replace all lines that matches' do
+        @resource = Puppet::Type::File_line.new(
+          {
+            :name     => 'foo',
+            :path     => @tmpfile,
+            :line     => 'foo = bar',
+            :match    => '^foo\s*=.*$',
+            :multiple => true,
+          }
+        )
+        @provider = provider_class.new(@resource)
+        File.open(@tmpfile, 'w') do |fh|
+          fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz")
+        end
+        expect(@provider.exists?).to be_nil
+        @provider.create
+        expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar")
+      end
+
+      it 'should raise an error with invalid values' do
+        expect {
+          @resource = Puppet::Type::File_line.new(
+            {
+              :name     => 'foo',
+              :path     => @tmpfile,
+              :line     => 'foo = bar',
+              :match    => '^foo\s*=.*$',
+              :multiple => 'asgadga',
+            }
+          )
+        }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./)
+      end
+
+      it 'should replace a line that matches' do
+        File.open(@tmpfile, 'w') do |fh|
+          fh.write("foo1\nfoo=blah\nfoo2")
+        end
+        expect(@provider.exists?).to be_nil
+        @provider.create
+        expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
+      end
+      it 'should add a new line if no lines match' do
+        File.open(@tmpfile, 'w') do |fh|
+          fh.write("foo1\nfoo2")
+        end
+        expect(@provider.exists?).to be_nil
+        @provider.create
+        expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n")
+      end
+      it 'should do nothing if the exact line already exists' do
+        File.open(@tmpfile, 'w') do |fh|
+          fh.write("foo1\nfoo = bar\nfoo2")
+        end
+        expect(@provider.exists?).to be_truthy
+        @provider.create
+        expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2")
+      end
+    end
+
+    describe 'using after' do
+      let :resource do
+        Puppet::Type::File_line.new(
+          {
+            :name  => 'foo',
+            :path  => @tmpfile,
+            :line  => 'inserted = line',
+            :after => '^foo1',
+          }
+        )
+      end
+
+      let :provider do
+        provider_class.new(resource)
+      end
+      context 'match and after set' do
+        shared_context 'resource_create' do
+          let(:match) { '^foo2$' }
+          let(:after) { '^foo1$' }
+          let(:resource) {
+            Puppet::Type::File_line.new(
+              {
+                :name  => 'foo',
+                :path  => @tmpfile,
+                :line  => 'inserted = line',
+                :after => after,
+                :match => match,
+              }
+            )
+          }
+        end
+        before :each do
+          File.open(@tmpfile, 'w') do |fh|
+            fh.write("foo1\nfoo2\nfoo = baz")
+          end
+        end
+        describe 'inserts at match' do
+          include_context 'resource_create'
+          it {
+            provider.create
+            expect(File.read(@tmpfile).chomp).to eq("foo1\ninserted = line\nfoo = baz")
+          }
+        end
+        describe 'inserts a new line after when no match' do
+          include_context 'resource_create' do
+            let(:match) { '^nevergoingtomatch$' }
+          end
+          it {
+            provider.create
+            expect(File.read(@tmpfile).chomp).to eq("foo1\ninserted = line\nfoo2\nfoo = baz")
+          }
+        end
+        describe 'append to end of file if no match for both after and match' do
+          include_context 'resource_create' do
+            let(:match) { '^nevergoingtomatch$' }
+            let(:after) { '^stillneverafter' }
+          end
+          it {
+            provider.create
+            expect(File.read(@tmpfile).chomp).to eq("foo1\nfoo2\nfoo = baz\ninserted = line")
+          }
+        end
+      end
+      context 'with one line matching the after expression' do
+        before :each do
+          File.open(@tmpfile, 'w') do |fh|
+            fh.write("foo1\nfoo = blah\nfoo2\nfoo = baz")
+          end
+        end
+
+        it 'inserts the specified line after the line matching the "after" expression' do
+          provider.create
+          expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz")
+        end
+      end
+
+      context 'with multiple lines matching the after expression' do
+        before :each do
+          File.open(@tmpfile, 'w') do |fh|
+            fh.write("foo1\nfoo = blah\nfoo2\nfoo1\nfoo = baz")
+          end
+        end
+
+        it 'errors out stating "One or no line must match the pattern"' do
+          expect { provider.create }.to raise_error(Puppet::Error, /One or no line must match the pattern/)
+        end
+
+        it 'adds the line after all lines matching the after expression' do
+          @resource = Puppet::Type::File_line.new(
+            {
+              :name     => 'foo',
+              :path     => @tmpfile,
+              :line     => 'inserted = line',
+              :after    => '^foo1$',
+              :multiple => true,
+            }
+          )
+          @provider = provider_class.new(@resource)
+          expect(@provider.exists?).to be_nil
+          @provider.create
+          expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo1\ninserted = line\nfoo = baz")
+        end
+      end
+
+      context 'with no lines matching the after expression' do
+        let :content do
+          "foo3\nfoo = blah\nfoo2\nfoo = baz\n"
+        end
+
+        before :each do
+          File.open(@tmpfile, 'w') do |fh|
+            fh.write(content)
+          end
+        end
+
+        it 'appends the specified line to the file' do
+          provider.create
+          expect(File.read(@tmpfile)).to eq(content << resource[:line] << "\n")
+        end
+      end
+    end
+  end
+
+  context "when removing" do
+    before :each do
+      # TODO: these should be ported over to use the PuppetLabs spec_helper
+      #  file fixtures once the following pull request has been merged:
+      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
+      tmp = Tempfile.new('tmp')
+      @tmpfile = tmp.path
+      tmp.close!
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name   => 'foo',
+          :path   => @tmpfile,
+          :line   => 'foo',
+          :ensure => 'absent',
+        }
+      )
+      @provider = provider_class.new(@resource)
+    end
+    it 'should remove the line if it exists' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo2")
+    end
+
+    it 'should remove the line without touching the last new line' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2\n")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
+    end
+
+    it 'should remove any occurence of the line' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2\nfoo\nfoo")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
+    end
+  end
+
+  context "when removing with a match" do
+    before :each do
+      # TODO: these should be ported over to use the PuppetLabs spec_helper
+      #  file fixtures once the following pull request has been merged:
+      # https://github.com/puppetlabs/puppetlabs-stdlib/pull/73/files
+      tmp = Tempfile.new('tmp')
+      @tmpfile = tmp.path
+      tmp.close!
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name              => 'foo',
+          :path              => @tmpfile,
+          :line              => 'foo2',
+          :ensure            => 'absent',
+          :match             => 'o$',
+          :match_for_absence => true,
+        }
+      )
+      @provider = provider_class.new(@resource)
+    end
+
+    it 'should remove one line if it matches' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo2")
+    end
+
+    it 'should raise an error if more than one line matches' do
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2\nfoo\nfoo")
+      end
+      expect { @provider.destroy }.to raise_error(Puppet::Error, /More than one line/)
+    end
+
+    it 'should remove multiple lines if :multiple is true' do
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name              => 'foo',
+          :path              => @tmpfile,
+          :line              => 'foo2',
+          :ensure            => 'absent',
+          :match             => 'o$',
+          :multiple          => true,
+          :match_for_absence => true,
+        }
+      )
+      @provider = provider_class.new(@resource)
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2\nfoo\nfoo")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n")
+    end
+
+    it 'should ignore the match if match_for_absence is not specified' do
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name     => 'foo',
+          :path     => @tmpfile,
+          :line     => 'foo2',
+          :ensure   => 'absent',
+          :match    => 'o$',
+        }
+      )
+      @provider = provider_class.new(@resource)
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo\n")
+    end
+
+    it 'should ignore the match if match_for_absence is false' do
+      @resource = Puppet::Type::File_line.new(
+        {
+          :name              => 'foo',
+          :path              => @tmpfile,
+          :line              => 'foo2',
+          :ensure            => 'absent',
+          :match             => 'o$',
+          :match_for_absence => false,
+        }
+      )
+      @provider = provider_class.new(@resource)
+      File.open(@tmpfile, 'w') do |fh|
+        fh.write("foo1\nfoo\nfoo2")
+      end
+      @provider.destroy
+      expect(File.read(@tmpfile)).to eql("foo1\nfoo\n")
+    end
+
+  end
+
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+
+require 'spec_helper'
+
+anchor = Puppet::Type.type(:anchor).new(:name => "ntp::begin")
+
+describe anchor do
+  it "should stringify normally" do
+    expect(anchor.to_s).to eq("Anchor[ntp::begin]")
+  end
+end
Index: src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb
===================================================================
--- src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
+++ src/puppetcode/environments/test/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb	(revision 1c22429c336ddd7087e5a50b7a6a3e4add4e004b)
@@ -0,0 +1,76 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+require 'tempfile'
+describe Puppet::Type.type(:file_line) do
+  let :file_line do
+    Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path')
+  end
+  it 'should accept a line and path' do
+    file_line[:line] = 'my_line'
+    expect(file_line[:line]).to eq('my_line')
+    file_line[:path] = '/my/path'
+    expect(file_line[:path]).to eq('/my/path')
+  end
+  it 'should accept a match regex' do
+    file_line[:match] = '^foo.*$'
+    expect(file_line[:match]).to eq('^foo.*$')
+  end
+  it 'should accept a match regex that does not match the specified line' do
+    expect {
+      Puppet::Type.type(:file_line).new(
+          :name   => 'foo',
+          :path   => '/my/path',
+          :line   => 'foo=bar',
+          :match  => '^bar=blah$'
+    )}.not_to raise_error
+  end
+  it 'should accept a match regex that does match the specified line' do
+    expect {
+      Puppet::Type.type(:file_line).new(
+          :name   => 'foo',
+          :path   => '/my/path',
+          :line   => 'foo=bar',
+          :match  => '^\s*foo=.*$'
+      )}.not_to raise_error
+  end
+  it 'should accept posix filenames' do
+    file_line[:path] = '/tmp/path'
+    expect(file_line[:path]).to eq('/tmp/path')
+  end
+  it 'should not accept unqualified path' do
+    expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, /File paths must be fully qualified/)
+  end
+  it 'should require that a line is specified' do
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.to raise_error(Puppet::Error, /line is a required attribute/)
+  end
+  it 'should not require that a line is specified when matching for absence' do
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error
+  end
+  it 'should require that a file is specified' do
+    expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/)
+  end
+  it 'should default to ensure => present' do
+    expect(file_line[:ensure]).to eq :present
+  end
+  it 'should default to replace => true' do
+    expect(file_line[:replace]).to eq :true
+  end
+
+  it "should autorequire the file it manages" do
+    catalog = Puppet::Resource::Catalog.new
+    file = Puppet::Type.type(:file).new(:name => "/tmp/path")
+    catalog.add_resource file
+    catalog.add_resource file_line
+
+    relationship = file_line.autorequire.find do |rel|
+      (rel.source.to_s == "File[/tmp/path]") and (rel.target.to_s == file_line.to_s)
+    end
+    expect(relationship).to be_a Puppet::Relationship
+  end
+
+  it "should not autorequire the file it manages if it is not managed" do
+    catalog = Puppet::Resource::Catalog.new
+    catalog.add_resource file_line
+    expect(file_line.autorequire).to be_empty
+  end
+end
