# another product.
# Tests for SAXophoNit
-module test_saxophonit is test_suite
+module test_saxophonit is test
import sax::helpers::sax_locator_impl
import sax::helpers::attributes_impl
class TestSaxophonit
super SAXTestSuite
+ test
redef fun create_reader do return new XophonReader
- fun test_empty do
+ fun test_empty is test do
before_test
parse_string("<foo />")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_simple_element do
+ fun test_simple_element is test do
before_test
parse_string("<foo>bar</foo>")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_type_mismatch do
+ fun test_type_mismatch is test do
before_test
parse_string("<a></b>")
expected.document_locator = new SAXLocatorImpl
expected.start_document
expected.start_element("", "a", "a", new AttributesImpl)
- expected.fatal_error(new SAXParseException.with(
+ expected.fatal_error(new SAXParseException.with_info(
"The type in the closing tag (`b`) does not match the type " +
"in the opening tag (`a`).", null, null, 1, 8))
expected.end_document
assert_equals
end
- fun test_attributes do
+ fun test_attributes is test do
var atts = new AttributesImpl
before_test
assert_equals
end
- fun test_nested do
+ fun test_nested is test do
var atts = new AttributesImpl
before_test
assert_equals
end
- fun test_xmldecl do
+ fun test_xmldecl is test do
before_test
parse_string("<?xml version='1.0'?><foo />")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_xmldecl_encoding do
+ fun test_xmldecl_encoding is test do
before_test
parse_string("<?xml version=\"1.0\" encoding='utf-8'?><foo />")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_xmldecl_standalone do
+ fun test_xmldecl_standalone is test do
before_test
parse_string("<?xml version='1.0' standalone=\"yes\"?><foo />")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_xmldecl_both do
+ fun test_xmldecl_both is test do
before_test
parse_string("<?xml version='1.0' encoding='utf-8' standalone=\"yes\"?><foo />")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_reference_builtin do
+ fun test_reference_builtin is test do
before_test
parse_string("<foo>&"'<>00:</foo>")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_comments do
+ fun test_comments is test do
# TODO For the moment, comments are simply ignored.
before_test
parse_string("<!-- I--><foo>bar<!--l-i-k-e--></foo><!--comments -->")
assert_equals
end
- fun test_ns_simple do
+ fun test_ns_simple is test do
before_test
parse_string("<foo:bar xmlns:foo='https://s.exemple.org' />")
expected.document_locator = new SAXLocatorImpl
assert_equals
end
- fun test_ns_prefix do
+ fun test_ns_prefix is test do
var atts = new AttributesImpl
before_test
expected.end_document
assert_equals
end
+
+ fun test_mixed is test do
+ var atts = new AttributesImpl
+
+ # TODO For the moment, ignorable white space is not detected.
+ before_test
+ parse_string("<foo> \r\n\n<bar> baz </bar></foo>")
+ expected.document_locator = new SAXLocatorImpl
+ expected.start_document
+ expected.start_element("", "foo", "foo", atts)
+ expected.characters(" \n\n")
+ expected.start_element("", "bar", "bar", atts)
+ expected.characters(" baz ")
+ expected.end_element("", "bar", "bar")
+ expected.end_element("", "foo", "foo")
+ expected.end_document
+ assert_equals
+ end
end