Sha256: c26096249c4662872d108115dd7e2189115e1d8c779bf92fd841aa9f6e2df41a

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 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.19 test/fe_lookup_att_test.rb