Sha256: 12e18f9619bc687f119a9b24f01343ebf0d0977aac41c3fc3eac3d4b138ac1fc

Contents?: true

Size: 1.59 KB

Versions: 16

Compression:

Stored size: 1.59 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Mon Oct  9 22:19:44 JST 2006
#

require 'test/unit'
require 'openwfe/util/dollar'

#
# testing the 'dollar notation'
#

class DollarTest < Test::Unit::TestCase

    #def setup
    #end

    #def teardown
    #end

    def test_one
        dict = {}
        dict['renard'] = 'goupil'
        dict['cane'] = 'oie'
        dict['oie blanche'] = 'poule'

        dotest("le petit renard", dict, "le petit renard")
        dotest("le petit {renard}", dict, "le petit {renard}")
        dotest("le petit ${renard}", dict, "le petit goupil")
        dotest("le petit ${renard} noir", dict, "le petit goupil noir")

        dotest("la grande ${${cane} blanche}", dict, "la grande poule")

        dotest("le ${renard} et la ${cane}", dict, "le goupil et la oie")
            #
            # excuse my french...

        dotest("le \\${renard} encore", dict, "le \\${renard} encore")

        dotest("", dict, "")

        dotest("""
""", dict, """
""")
        dotest(""" 
""", dict, """ 
""")
    end

    def test_two
        dict = {}
        dict['x'] = 'y'
        dotest("${x}", dict, "y")
        dotest("\\${x}", dict, "\\${x}")
    end

    def test_three
        dict = {}
        dict['A'] = 'a'
        dict['B'] = 'b'
        dict['ab'] = 'ok'
        dotest("${${A}${B}}", dict, "ok")
    end

    def dotest (text, dict, target)
        result = OpenWFE::dsub(text, dict)
        #puts "..>#{text}<"
        #puts "...->"
        #puts "..>#{result}<"
        #puts
        assert \
            result == target,
            ">#{result}< != >#{target}<"
    end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
openwferu-0.9.10 test/dollar_test.rb
openwferu-0.9.10.653 test/dollar_test.rb
openwferu-0.9.11 test/dollar_test.rb
openwferu-0.9.12 test/dollar_test.rb
openwferu-0.9.12.863 test/dollar_test.rb
openwferu-0.9.13 test/dollar_test.rb
openwferu-0.9.14 test/dollar_test.rb
openwferu-0.9.15 test/dollar_test.rb
openwferu-0.9.2 test/dollartest.rb
openwferu-0.9.3 test/dollar_test.rb
openwferu-0.9.4 test/dollar_test.rb
openwferu-0.9.5 test/dollar_test.rb
openwferu-0.9.6 test/dollar_test.rb
openwferu-0.9.7 test/dollar_test.rb
openwferu-0.9.8 test/dollar_test.rb
openwferu-0.9.9 test/dollar_test.rb