]> gitweb.factorcode.org Git - factor.git/commitdiff
html.parser.printer: unit tests
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 5 Aug 2013 11:25:26 +0000 (13:25 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 5 Aug 2013 16:56:44 +0000 (09:56 -0700)
extra/html/parser/printer/printer-tests.factor [new file with mode: 0644]

diff --git a/extra/html/parser/printer/printer-tests.factor b/extra/html/parser/printer/printer-tests.factor
new file mode 100644 (file)
index 0000000..1d4d676
--- /dev/null
@@ -0,0 +1,33 @@
+USING:
+    html.parser html.parser.printer
+    io.streams.string
+    namespaces
+    tools.test ;
+IN: html.parser.printer.tests
+
+[
+    "          "
+] [
+    [ 5 #indentations set 2 tab-width set tabs ] with-scope
+] unit-test
+
+[
+    " rel='nofollow' href='http://www.google.com'"
+] [
+    H{ { "href" "http://www.google.com" } { "rel" "nofollow" } }
+        [ print-attributes ] with-string-writer
+] unit-test
+
+[
+    "<p>\n  Sup dude!\n  <br>\n</p>\n"
+] [
+    "<p>Sup dude!<br></p>" parse-html [ prettyprint-html ] with-string-writer
+] unit-test
+
+! Wrongly nested tags
+[
+    "<div>\n  <p>\n    Sup dude!\n    <br>\n  </div>\n</p>\n"
+] [
+    "<div><p>Sup dude!<br></div></p>" parse-html
+    [ prettyprint-html ] with-string-writer
+] unit-test