]> gitweb.factorcode.org Git - factor.git/blob - extra/html/parser/parser-tests.factor
stomp.cli: simplify
[factor.git] / extra / html / parser / parser-tests.factor
1 USING: html.parser kernel tools.test ;
2
3 {
4     V{ T{ tag f "html" H{ } f f } }
5 } [ "<html>" parse-html ] unit-test
6
7 {
8     V{ T{ tag f "html" H{ } f t } }
9 } [ "</html>" parse-html ] unit-test
10
11 {
12     V{ T{ tag f "a" H{ { "href" "http://factorcode.org/" } } f f } }
13 } [ "<a href=\"http://factorcode.org/\">" parse-html ] unit-test
14
15 {
16     V{ T{ tag f "a" H{ { "href" "http://factorcode.org/" } } f f } }
17 } [ "<a   href  =  \"http://factorcode.org/\"   >" parse-html ] unit-test
18
19 {
20 V{
21     T{
22         tag
23         f
24         "a"
25         H{ { "baz" "\"quux\"" } { "foo" "bar's" } }
26         f
27         f
28     }
29 }
30 } [ "<a   foo=\"bar's\" baz='\"quux\"'  >" parse-html ] unit-test
31
32 {
33 V{
34     T{ tag f "a"
35         H{
36             { "a" "pirsqd" }
37             { "foo" "bar" }
38             { "href" "http://factorcode.org/" }
39             { "baz" "quux" }
40         } f f }
41 }
42 } [ "<a   href  =    \"http://factorcode.org/\"    foo   =  bar baz='quux'a=pirsqd  >" parse-html ] unit-test
43
44 {
45 V{
46     T{ tag f "a"
47         H{
48             { "a" "pirsqd" }
49             { "foo" "bar" }
50             { "href" "http://factorcode.org/" }
51             { "baz" "quux" }
52             { "nofollow" "nofollow" }
53         } f f }
54 }
55 } [ "<a   href  =    \"http://factorcode.org/\"    nofollow  foo   =  bar baz='quux'a=pirsqd  >" parse-html ] unit-test
56
57 {
58 V{
59     T{ tag f "html" H{ } f f }
60     T{ tag f "head" H{ } f f }
61     T{ tag f "head" H{ } f t }
62     T{ tag f "html" H{ } f t }
63 }
64 } [ "<html<head</head</html" parse-html ] unit-test
65
66 {
67 V{
68     T{ tag f "head" H{ } f f }
69     T{ tag f "title" H{ } f f }
70     T{ tag f text f "Spagna" f }
71     T{ tag f "title" H{ } f t }
72     T{ tag f "head" H{ } f t }
73 }
74 } [ "<head<title>Spagna</title></head" parse-html ] unit-test
75
76 {
77 V{
78     T{ tag
79         { name dtd }
80         { text
81             "DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Draft//EN\""
82         }
83     }
84 }
85 }
86 [
87     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Draft//EN\">"
88     parse-html
89 ] unit-test
90
91 {
92 V{
93     T{ tag { name comment } { text "comment" } }
94 }
95 } [
96     "<!--comment-->" parse-html
97 ] unit-test
98
99 ! Issue #1233, trailing / in tags
100 {
101     V{
102         T{ tag
103             { name "img" }
104             { attributes H{ { "src" "http://factorcode.org" } } }
105         }
106     }
107 }
108 [ "<img src=\"http://factorcode.org\">" parse-html ] unit-test
109
110 {
111     V{
112         T{ tag
113             { name "img" }
114             { attributes H{ { "src" "http://factorcode.org" } } }
115         }
116     }
117 }
118 [ "<img src=\"http://factorcode.org\"/>" parse-html ] unit-test
119
120 {
121     V{
122         T{ tag
123             { name "img" }
124             { attributes H{ { "src" "http://factorcode.org" } } }
125         }
126     }
127 }
128 [ "<img src=\"http://factorcode.org\"////////>" parse-html ] unit-test