require "runit/testcase"
require "runit/cui/testrunner"

require "rexml/document"
require "rexml/parseexception"

class ContribTester < RUNIT::TestCase
	def test_bad_doctype_TobiasReif
		source = <<-EOF
		 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
				"http://www.w3.org/TR/SVG/DTD/svg10.dtd"
			 [
			 <!-- <!ENTITY % fast-slow "0 0  .5 1">-->
			 <!--<!ENTITY % slow-fast ".5 0  1 1">-->
			 <!ENTITY hover_ani
				'<animateTransform attributeName="transform"
				 type="scale" restart="whenNotActive" values="1;0.96"
				 dur="0.5s" calcMode="spline" keySplines="0 0  .5 1"
				 fill="freeze" begin="mouseover"/>
				 <animateTransform  attributeName="transform"
				 type="scale" restart="whenNotActive" values="0.96;1"
				 dur="0.5s" calcMode="spline" keySplines=".5 0  1 1"
				 fill="freeze" begin="mouseover+0.5s"/>'
			 >
			 ]
		 >
		EOF
		doc = REXML::Document.new source
		out = ""
		doc.write(out)
		assert out[/>'>/] != nil, "Couldn't find >'>" # '
		assert out[/]>/] != nil, "Couldn't find ]>"
	end

=begin
	def test_complex_xpath_TobiasReif
		source = <<-EOF
		<root>
			<foo>
				<bar style="baz"/>
				<blah style="baz"/>
				<blam style="baz"/>
			</foo>
		</root>
		EOF
		complex_path = "*[* "+
			"and not(*/node()) "+
			"and not(*[not(@style)]) "+
			"and not(*/@style != */@style)]"
		doc = REXML::Document.new source
		results = REXML::XPath.match( doc, complex_path )
		assert_not_nil results
		assert_equal "foo", results[0].name
	end

	def test_other_xpath_TobiasReif
		schema = <<-Delimiter
		<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
			elementFormDefault="qualified">
			<xs:element name="rect">
				<xs:complexType>
					<xs:attribute name="width" type="xs:byte" use="required"/>
					<xs:attribute name="height" type="xs:byte" use="required"/>
				</xs:complexType>
			</xs:element>
			<xs:element name="svg">
				<xs:complexType>
					<xs:sequence>
						<xs:element ref="rect"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:schema>
		Delimiter

		doc = REXML::Document.new schema

		result = REXML::XPath.first(doc, 'xs:element[descendant::xs:element[@ref]]')
		assert_not_nil result
		assert_equal "svg", result.attributes['name']
		result = REXML::XPath.first(doc, 'element[descendant::element[@ref]]')
		assert_nil result
	end
=end
end
