diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-13 23:09:05 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-13 23:09:05 +0000 |
commit | 9743376ac87220356d40c1dd7adb8fbf4f99e5dd (patch) | |
tree | ce17ec67b757b7fe12c94163cf7efc491c583f71 /t | |
parent | a2ff0af05a5a9d2e622cde2555b654017acef1ac (diff) |
Test that invoking parse_line() honours macro definitions.
Diffstat (limited to 't')
-rwxr-xr-x | t/test-parser.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/t/test-parser.rb b/t/test-parser.rb index 636dccf..c061cbe 100755 --- a/t/test-parser.rb +++ b/t/test-parser.rb @@ -101,6 +101,35 @@ class TestParser < Test::Unit::TestCase assert( val.size() == 2 ) assert( val.include?( "kvm1.vm.bytemark.co.uk" ) ) assert( val.include?( "kvm2.vm.bytemark.co.uk" ) ) + + + # + # Add a macro, using the parser directly. + # + # Before defining it double-check it doesn't exist + # + assert( !(parser.is_macro?( "BAR" )) ) + + parser.parse_line( "BAR is example.vm.bytemark.co.uk and www.bytemark.co.uk." ) + + # + # OK we should now have two macros defined. + # + macros = parser.macros + assert( macros.size() == 2 ) + + # + # The macro name "BAR" should exist + # + assert( parser.is_macro?( "BAR" ) ) + + # + # The contents of the BAR macro should have the value we expect + # + val = parser.get_macro_targets( "BAR" ) + assert( val.size() == 2 ) + assert( val.include?( "example.vm.bytemark.co.uk" ) ) + assert( val.include?( "www.bytemark.co.uk" ) ) end |