From 3ebf148bf3d82d25e690aec6ec49975e0837e604 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 28 Jul 2009 19:56:34 +0200 Subject: Enhance selector and case statements to match with regexp The case and selector statements define ephemeral vars, like 'if'. Usage: case statement: $var = "foobar" case $var { "foo": { notify { "got a foo": } } /(.*)bar$/: { notify{ "hey we got a $1": } } } and for selector: $val = $test ? { /^match.*$/ => "matched", default => "default" } Signed-off-by: Brice Figureau --- test/lib/puppettest/parsertesting.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/lib') diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb index 8186bf304..dee38eb3a 100644 --- a/test/lib/puppettest/parsertesting.rb +++ b/test/lib/puppettest/parsertesting.rb @@ -33,6 +33,11 @@ module PuppetTest::ParserTesting def safeevaluate(*args) evaluate() end + + def evaluate_match(othervalue, scope, options={}) + value = evaluate() + othervalue == value + end end def astarray(*args) -- cgit