1 ! Copyright (C) 2010 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: html.parser html.parser.analyzer kernel math sequences tools.test ;
4 IN: html.parser.analyzer.tests
7 [ 1 { 3 5 7 9 11 } [ odd? ] find-nth ] unit-test
10 [ 3 { 3 5 7 9 11 } [ odd? ] find-nth ] unit-test
13 [ 3 1 { 3 5 7 9 11 } [ odd? ] find-nth-from ] unit-test
16 [ 1 { 3 5 7 9 11 } [ odd? ] find-last-nth ] unit-test
19 [ 3 { 3 5 7 9 11 } [ odd? ] find-last-nth ] unit-test
22 [ 1 2 { 3 5 7 9 11 } [ odd? ] find-last-nth-from ] unit-test
25 [ 0 { 3 5 7 9 11 } [ odd? ] find-nth ]
26 [ undefined-find-nth? ] must-fail-with
28 [ 0 { 3 5 7 9 11 } [ odd? ] find-last-nth ]
29 [ undefined-find-nth? ] must-fail-with
32 T{ tag f text f "foo" f }
35 "<html><head><title>foo</title></head></html>" parse-html
36 "title" find-between-first
40 T{ tag f "p" H{ } f f }
41 T{ tag f text f "para" f }
42 T{ tag f "p" H{ } f t }
45 "<body><div><p>para</p></div></body>" parse-html "div" find-between-first
49 T{ tag f "div" H{ { "class" "foo" } } f f }
50 T{ tag f "p" H{ } f f }
51 T{ tag f text f "para" f }
52 T{ tag f "p" H{ } f t }
53 T{ tag f "div" H{ } f t }
56 "<body><div class=\"foo\"><p>para</p></div></body>" parse-html
57 "foo" find-by-class-between
61 T{ tag f "div" H{ { "class" "foo" } } f f }
62 T{ tag f "div" H{ } f f }
63 T{ tag f "p" H{ } f f }
64 T{ tag f text f "para" f }
65 T{ tag f "p" H{ } f t }
66 T{ tag f "div" H{ } f t }
67 T{ tag f "div" H{ } f t }
70 "<body><div class=\"foo\"><div><p>para</p></div></div></body>" parse-html
71 "foo" find-by-class-between
75 T{ tag { name "f" } { attributes H{ { "class" "a b c" } } } }
76 { "a" "b" "c" } [ html-class? ] with all?
83 { attributes H{ { "class" "foo and more" } } }
85 T{ tag { name "div" } { attributes H{ } } { closing? t } }
87 ] [ "<div class=\"foo and more\"></div>" parse-html
88 "foo" find-by-class-between
93 T{ tag { name "div" } { attributes H{ { "class" "foo bar" } } } }
95 "<div class=\"foo bar\"></div>" parse-html "bar" find-by-class