-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests of writing functions in the puppet language
- Loading branch information
1 parent
07d7837
commit 1ac91ea
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function none::square_me(Numeric $number, Numeric *$numbers) { | ||
if $numbers != [] { | ||
$all = [$number, $numbers].flatten | ||
$all.map |$x| {$x * $x} | ||
} | ||
else { | ||
$number * $number | ||
} | ||
} | ||
|
||
notice( spew( none::square_me(200) )) | ||
# Notice: Scope(Class[main]): [40000] | ||
# [Fixnum] | ||
|
||
#notice( spew( square_me('NaN') )) | ||
# Error: Evaluation Error: Error while evaluating a Function Call, 'square_me' parameter 'number' expects a Numeric value, got String at /Users/nick/Documents/manifests/functions_in_puppet.pp:7:15 on node magpie.lan | ||
|
||
notice( spew( none::square_me(200, 300, 400) )) | ||
# Notice: Scope(Class[main]): [[40000, 90000, 160000]] | ||
# [Array] | ||
|
||
# Cool. | ||
|
||
function make_resource(String $thing) { | ||
file {"/tmp/$thing": | ||
ensure => file, | ||
content => "made by function thingy thing.", | ||
} | ||
} | ||
|
||
notice( spew( make_resource("hey_hey_hey_hi") )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
notice( spew( functionbucket::square_me(200) )) | ||
# Notice: Scope(Class[main]): [40000] | ||
# [Fixnum] | ||
|
||
#notice( spew( functionbucket::square_me('NaN') )) | ||
# Error: Evaluation Error: Error while evaluating a Function Call, 'square_me' parameter 'number' expects a Numeric value, got String at /Users/nick/Documents/manifests/functions_in_puppet.pp:7:15 on node magpie.lan | ||
|
||
notice( spew( functionbucket::square_me(200, 300, 400) )) | ||
# Notice: Scope(Class[main]): [[40000, 90000, 160000]] | ||
# [Array] | ||
|
||
# notice( spew( functionbucket::square_me(200, 300, 'NaN', 500) )) | ||
# Error: Evaluation Error: Error while evaluating a Function Call, 'functionbucket::square_me' parameter 'numbers' expects a Numeric value, got String at /Users/nick/Documents/manifests/functions_in_puppet_in_module.pp:12:15 on node magpie.lan | ||
|
||
# Cool. | ||
|
||
# include at_tester | ||
# notice( functionbucket::default_value() ) | ||
|
||
class hey { | ||
$fqdn = "overridden" | ||
notice( functionbucket::default_value() ) | ||
# Notice: Scope(Class[Hey]): wren | ||
} | ||
include hey |