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 | 07c651ef879a50844ce30844435642f65eaaeac8 (patch) | |
tree | ce17ec67b757b7fe12c94163cf7efc491c583f71 | |
parent | 7cc1607bf608c6ba3842e65f28d5e0971185adad (diff) |
Test that invoking parse_line() honours macro definitions.
-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 |