Sha256: 89728b1a8b2508302b03d15df43b8643b6d1cb12beaf88a2b628e18d812ad4e6

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Thu Nov  1 19:33:45 JST 2007
#

require 'rubygems'

require 'test/unit'
require 'openwfe/expressions/flowexpression'


class FeLookupAttTest < Test::Unit::TestCase

    #def setup
    #end

    #def teardown
    #end

    def test_0

        attributes = { 
            "a" => true, 
            "b" => false,
            "A" => "a, b, c,d,${e},f",
            "B" => [ 1, 2, 3, "${a}" ]
        }

        fe = OpenWFE::FlowExpression.new_exp nil, nil, nil, nil, attributes

        class << fe
            def lookup_variable (varname)
                varname * 2
            end
        end

        assert_equal true, fe.lookup_boolean_attribute("a", nil)
        assert_equal true, fe.lookup_boolean_attribute(:a, nil)
        assert_equal true, fe.lookup_boolean_attribute("a", nil, false)
        assert_equal true, fe.lookup_boolean_attribute(:a, nil, false)
        assert_equal true, fe.lookup_boolean_attribute("a", nil, true)
        assert_equal true, fe.lookup_boolean_attribute(:a, nil, true)

        assert_equal false, fe.lookup_boolean_attribute("b", nil)
        assert_equal false, fe.lookup_boolean_attribute(:b, nil)
        assert_equal false, fe.lookup_boolean_attribute("b", nil, false)
        assert_equal false, fe.lookup_boolean_attribute(:b, nil, false)
        assert_equal false, fe.lookup_boolean_attribute("b", nil, true)
        assert_equal false, fe.lookup_boolean_attribute(:b, nil, true)

        assert_equal %w{ a b c d ee f }, fe.lookup_array_attribute('A', nil)
        assert_equal [ 1, 2, 3, "aa" ], fe.lookup_array_attribute('B', nil)

        # a fat but fast test
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-0.9.18 test/fe_lookup_att_test.rb