test suite test markup grammar
import ideal • machine • characters • unicode handler
import ideal • machine • channels • string writer
var string error message
test case test entity ref()
assert entity ref("<")
assert entity ref("&")
assert entity ref("•")
assert !entity ref("foo")
assert !entity ref("&foo")
assert !entity ref("foo;")
test case test attribute value()
grammar : make grammar()
assert quot attr value("foo")
assert quot attr value("*bar*")
assert quot attr value("'baz'")
assert !quot attr value("<")
assert !quot attr value("\"a")
assert apos attr value("foo")
assert apos attr value("*bar*")
assert apos attr value("\"baz\"")
assert !apos attr value("<")
assert !apos attr value("'a")
test case test attribute()
assert attribute("id = '68'")
assert attribute("href = \"https://theideal.org/\"")
assert attribute("clear='all'")
assert !attribute("<html>")
assert !attribute("foo")
assert !attribute("bar =")
assert !attribute("<name> = 'value'")
test case test empty element()
test case test content()
assert content(" hello, world!")
assert content("<html>")
assert !content("<bar>")
test case test simple parse()
grammar : make grammar()
assert document matcher("<html>foo</html>")
assert document matcher(" <html>foo</html> ")
assert document matcher(" <html >foo</html > ")
assert document matcher(" <html >Hello & goodbye!</html > ")
assert document matcher(" <html /> ")
assert document matcher("<html/>")
assert document matcher(" <html>Hello <em>world!</em></html> ")
assert document matcher(" <html><body ><p>Hello <em >world!</em ></p></body ></html> ")
assert document matcher(" <html><body > <p>Hello<br />world!</p> </body ></html> ")
assert document matcher(" <html><body > Hello <world!> </body ></html> ")
assert document matcher("<html><p class='klass'>foo</p></html>")
assert document matcher("<html><a class = 'klass' href = 'link'>bar</a></html>")
assert document matcher("<html><p class = 'value\">==' attr=\"foo'\">foo</p></html>")
assert document matcher("<html><p class = '***' attr=\"baz\">foo</p></html>")
assert !document matcher(" no markup ")
assert !document matcher(" <html>foo ")
assert !document matcher(" <html>foo<bar> ")
assert !document matcher(" <>foo ")
assert !document matcher(" &<html>foo</html> ")
assert !document matcher("<html><p class='klass\">foo</p></html>")
assert !document matcher("<html><p class='klass'>foo</p class=\"foo\"></html>")
assert !document matcher("<html foo= ><p class='klass'>foo</p></html>")
assert !document matcher("<html foo=bar><p class='klass'>foo</p></html>")
assert document matcher(" <abc>foo</def> ")
assert matches(document matcher • parse(" <html >Hello & goodbye!</html > "), "<html>Hello & goodbye!</html>")
assert matches(document matcher • parse(" <html>Hello <em>world!</em></html> "), "<html>Hello <em>world!</em></html>")
assert matches(document matcher • parse(" <html><body > <p>Hello<br />world!</p> </body ></html> "), "<html><body> <p>Hello<br />world!</p> </body></html>")
assert matches(document matcher • parse("<html><p class='klass'>foo</p></html>"), "<html><p class='klass'>foo</p></html>")
assert matches(document matcher • parse("<html><p id='f&f'>foo</p></html>"), "<html><p id='f&f'>foo</p></html>")
assert matches(document matcher • parse("<html><a class = 'klass' href = 'link'>bar</a></html>"), "<html><a class='klass' href='link'>bar</a></html>")
test case test parse errors()
grammar : make grammar()
assert matches with error(parser • parse("<html>&bug;</html>"), "<html>&_error_;</html>", "Unrecognized entity: bug")
assert matches with error(parser • parse("<html><foo>Hello!</foo></html>"), "<html><_error_>Hello!</_error_></html>", "Unrecognized element name: foo")
assert matches with error(parser • parse("<html><b attr=\"value\">Hello!</b></html>"), "<html><b _error_='value'>Hello!</b></html>", "Unrecognized attribute name: attr")
assert matches with error(parser • parse("<html><a>Hello!</b></html>"), "<html><a>Hello!</a></html>", "Mismatched element name: start a, end b")
private boolean matches with error(text element the text element, string expected, string expected error)
private boolean matches(text element the text element, string expected)
the writer : string writer • new()
return the writer • elements() == expected