Puppet Function: assert::not_equal

Defined in:
lib/puppet/functions/assert/not_equal.rb
Function type:
Ruby 4.x API

Overview

assert::not_equal(Any $result, Any $expected)Any

Accepts two parameters that must be of the same type and returns true if both parameter values are not equal. Raises Puppet::Error if they are equal.

~~~ puppet

assert::not_equal([1,2,3], {'foo' => 'bar'})
'foo'.assert::not_equal('bar')
[3,2,1].assert::not_equal(sort([3,2,1]))

~~~

~~~ puppet

'foo'.assert::not_equal(foo)
true.assert::not_equal(true)
assert::not_equal(1,1)

~~~

Examples:

the following are expected to return true

the following are expected to raise an exception

Parameters:

  • result (Any)
  • expected (Any)

Returns:

  • (Any)


20
21
22
23
24
25
26
27
28
29
30
# File 'lib/puppet/functions/assert/not_equal.rb', line 20

Puppet::Functions.create_function(:'assert::not_equal') do
  dispatch :test do
    param 'Any', :result
    param 'Any', :expected
  end

  def test(result, expected)
    raise Puppet::Error, "assert::not_equal failed because expected result #{expected} equals actual result #{result}" if result == expected
    return true
  end
end