Sha256: 4c9f141e68ee27ab62c04f2313c1f959d99fa5123552633d43d03bf6991cfef5

Contents?: true

Size: 1.6 KB

Versions: 42

Compression:

Stored size: 1.6 KB

Contents

#!/usr/bin/env ruby -w

require "test/unit"
require "xamplr-generator"

include XamplGenerator
include Xampl

class TestXampl < Test::Unit::TestCase

  def setup
    Xampl.disable_all_persisters
  end

  def test_same_names
    options = Xampl.make(Options) { | options |
      options.new_index_attribute("name")
      options.new_resolve{ | resolver |
        resolver.pkg = "XamplExampleNames"
        resolver.namespace="http://xampl.com/example"
      }
    }
    generator = Generator.new(options)
    xml = %Q{
<conflict name="hansel" xmlns='http://xampl.com/example'>
  <xname name='blah'>
	  <conflict name='nested'/>
	</xname>
  <name name='blah'>
	  <conflict name='nested'/>
	</name>
</conflict>
}
    generator.comprehend_from_strings([ xml ])
    generator.generate_and_eval() { | module_definition, name |
      eval(module_definition, nil, name, 1)
    }

    parser = FromXML.new
    conflict = parser.parse_string(xml)

    assert(conflict)
    assert_equal("hansel", conflict.name)
    assert_equal("hansel"[0], conflict.name[0])
    assert_equal("blah", conflict.xname_child[0].name)
    assert_equal("blah", conflict.name_child[0].name)
    assert_nil(conflict.name['blah'])
  end

  def check_parents(xampl, parent=nil)
    if (nil != parent) then
      found = false
      xampl.parents.each{ | p |
        found = true if (parent == p)
      }
      assert(found)
    else
      if (xampl.kind_of? XamplObject)
        assert((nil == xampl.parents) || (0 == xampl.parents.size))
      end
    end
    xampl.children.each{ | child |
      check_parents(child, xampl) if (child.kind_of? XamplObject)
    }
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
hutch-xamplr-1.3.9 lib/xamplr/test-support/test-names.rb
xamplr-1.9.20 lib/xamplr/test-support/test-names.rb
xamplr-1.9.18 lib/xamplr/test-support/test-names.rb
xamplr-1.9.16 lib/xamplr/test-support/test-names.rb
xamplr-1.9.15 lib/xamplr/test-support/test-names.rb
xamplr-1.9.14 lib/xamplr/test-support/test-names.rb
xamplr-1.9.13 lib/xamplr/test-support/test-names.rb
xamplr-1.9.12 lib/xamplr/test-support/test-names.rb
xamplr-1.9.11 lib/xamplr/test-support/test-names.rb
xamplr-1.9.10 lib/xamplr/test-support/test-names.rb
xamplr-1.9.9 lib/xamplr/test-support/test-names.rb
xamplr-1.9.8 lib/xamplr/test-support/test-names.rb
xamplr-1.9.7 lib/xamplr/test-support/test-names.rb
xamplr-1.9.6 lib/xamplr/test-support/test-names.rb
xamplr-1.9.5 lib/xamplr/test-support/test-names.rb
xamplr-1.9.4 lib/xamplr/test-support/test-names.rb
xamplr-1.9.3 lib/xamplr/test-support/test-names.rb
xamplr-1.9.2 lib/xamplr/test-support/test-names.rb
xamplr-1.9.1 lib/xamplr/test-support/test-names.rb
xamplr-1.9.0 lib/xamplr/test-support/test-names.rb