diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 01:21:58 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 01:21:58 +0000 |
commit | 4df0738de2e93b8c0408561153543682aa1a3455 (patch) | |
tree | d657835c5496e1dca96aab0f1bbc3317bd743994 /test | |
parent | 0f16bf3c5b925f5656a5592b527ae56d92c662f9 (diff) | |
download | puppet-4df0738de2e93b8c0408561153543682aa1a3455.tar.gz puppet-4df0738de2e93b8c0408561153543682aa1a3455.tar.xz puppet-4df0738de2e93b8c0408561153543682aa1a3455.zip |
Applying a modified form of the patch by cstorey from #523. The modifications were mostly around the fact that Strscan does not set $1 and its ilk.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2239 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-x | test/language/scope.rb | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/test/language/scope.rb b/test/language/scope.rb index bf89dbba2..c2346dac5 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -201,31 +201,44 @@ class TestScope < Test::Unit::TestCase assert_nothing_raised { scope.setvar("test","value") } - val = nil - assert_nothing_raised { - val = scope.strinterp("string ${test}") + tests = { + "string ${test}" => "string value", + "string ${test} ${test} ${test}" => "string value value value", + "string $test ${test} $test" => "string value value value", + "string \\$test" => "string $test", + '\\$test string' => "$test string", + '$test string' => "value string", + 'a testing $' => "a testing $", + 'a testing \$' => "a testing $", + '\$' => "$", + '\s' => "\s", + '\t' => "\t", + '\n' => "\n" } - assert_equal("string value", val) - assert_nothing_raised { - val = scope.strinterp("string ${test} ${test} ${test}") - } - assert_equal("string value value value", val) + tests.each do |input, output| + assert_nothing_raised("Failed to scan %s" % input.inspect) do + assert_equal(output, scope.strinterp(input), + 'did not interpret %s correctly' % input) + end + end - assert_nothing_raised { - val = scope.strinterp("string $test ${test} $test") - } - assert_equal("string value value value", val) + logs = [] + Puppet::Util::Log.close + Puppet::Util::Log.newdestination(logs) - assert_nothing_raised { - val = scope.strinterp("string \\$test") - } - assert_equal("string $test", val) + # #523 + %w{d f h l w z}.each do |l| + string = "\\" + l + assert_nothing_raised do + assert_equal(string, scope.strinterp(string), + 'did not interpret %s correctly' % string) + end - assert_nothing_raised { - val = scope.strinterp("\\$test string") - } - assert_equal("$test string", val) + assert(logs.detect { |m| m.message =~ /Unrecognised escape/ }, + "Did not get warning about escape sequence with %s" % string) + logs.clear + end end def test_setclass |