summaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-09-26 23:03:39 +0200
committerJames Turnbull <james@lovedthanlost.net>2008-10-01 01:35:03 +1000
commit4cf9710bd27fdb5f0720f4d8478ef940e7c4ba59 (patch)
treee2db8d91c8e1d45bb9413899ff6566a712264b0a /test/data
parentcfa230a2d7b0c5e57cc0379785bd2025520f1c35 (diff)
downloadpuppet-4cf9710bd27fdb5f0720f4d8478ef940e7c4ba59.tar.gz
puppet-4cf9710bd27fdb5f0720f4d8478ef940e7c4ba59.tar.xz
puppet-4cf9710bd27fdb5f0720f4d8478ef940e7c4ba59.zip
Add parser for arbitrary expressions
The expressions can be used in if 'test' and in the right side of assignements. The expressions can contain any number of sub-expressions combined by either arithmetic operators, comparison operators, or boolean operators. Random Usage Examples: $result = ((( $two + 2) / $one) + 4 * 5.45) - (6 << 7) + (0x800 + -9) or if ($a < 10) and ($a + 10 != 200) { ... }
Diffstat (limited to 'test/data')
-rw-r--r--test/data/snippets/arithmetic_expression.pp8
-rw-r--r--test/data/snippets/ifexpression.rb6
2 files changed, 14 insertions, 0 deletions
diff --git a/test/data/snippets/arithmetic_expression.pp b/test/data/snippets/arithmetic_expression.pp
new file mode 100644
index 000000000..aae98a4db
--- /dev/null
+++ b/test/data/snippets/arithmetic_expression.pp
@@ -0,0 +1,8 @@
+
+$one = 1.30
+$two = 2.034e-2
+
+$result = ((( $two + 2) / $one) + 4 * 5.45) - (6 << 7) + (0x800 + -9)
+
+
+notice("result is $result == 1295.87692307692") \ No newline at end of file
diff --git a/test/data/snippets/ifexpression.rb b/test/data/snippets/ifexpression.rb
new file mode 100644
index 000000000..eea3b855b
--- /dev/null
+++ b/test/data/snippets/ifexpression.rb
@@ -0,0 +1,6 @@
+$one = 1
+$two = 2
+
+if ($one < $two) and (($two < 3) or ($two == 2)) {
+ notice("True!")
+}