From 850069ec83b8d2e45644d924877f60bfb18cffd6 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Fri, 18 Jan 2013 06:35:52 -0700 Subject: [PATCH] Adding test for lex-name change --- collects/tests/html/test.rkt | 90 +++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/collects/tests/html/test.rkt b/collects/tests/html/test.rkt index b2d937f4fd..1e34b85fad 100644 --- a/collects/tests/html/test.rkt +++ b/collects/tests/html/test.rkt @@ -8,45 +8,61 @@ (define html-tests (test-suite "HTML" - + (test-case "Example" (local - [(define an-html - (h:read-xhtml - (open-input-string - (string-append - "My title" - "

Hello world

Testing!

" - "")))) - - ; extract-pcdata: html-content -> (listof string) - ; Pulls out the pcdata strings from some-content. - (define (extract-pcdata some-content) - (cond [(x:pcdata? some-content) - (list (x:pcdata-string some-content))] - [(x:entity? some-content) - (list)] - [else - (extract-pcdata-from-element some-content)])) - - ; extract-pcdata-from-element: html-element -> (listof string) - ; Pulls out the pcdata strings from an-html-element. - (define (extract-pcdata-from-element an-html-element) - (match an-html-element - [(struct h:html-full (attributes content)) - (apply append (map extract-pcdata content))] - - [(struct h:html-element (attributes)) - '()]))] - - (check-equal? (extract-pcdata an-html) - ' ("My title" "Hello world" "Testing" "!")))) - - - (test-case "Eli - March 1" - (check-not-false (lambda () (h:read-html-as-xml (get-pure-port (string->url "http://list.cs.brown.edu/pipermail/plt-scheme/")))))) - - )) + [(define an-html + (h:read-xhtml + (open-input-string + (string-append + "My title" + "

Hello world

Testing!

" + "")))) + + ; extract-pcdata: html-content -> (listof string) + ; Pulls out the pcdata strings from some-content. + (define (extract-pcdata some-content) + (cond [(x:pcdata? some-content) + (list (x:pcdata-string some-content))] + [(x:entity? some-content) + (list)] + [else + (extract-pcdata-from-element some-content)])) + + ; extract-pcdata-from-element: html-element -> (listof string) + ; Pulls out the pcdata strings from an-html-element. + (define (extract-pcdata-from-element an-html-element) + (match an-html-element + [(struct h:html-full (attributes content)) + (apply append (map extract-pcdata content))] + + [(struct h:html-element (attributes)) + '()]))] + + (check-equal? (extract-pcdata an-html) + ' ("My title" "Hello world" "Testing" "!")))) + + + (test-case + "Eli - March 1" + (check-not-false + (lambda () + (h:read-html-as-xml + (get-pure-port + (string->url + "http://list.cs.brown.edu/pipermail/plt-scheme/")))))) + + (test-case + "DW - Jan 18 2013" + (check-equal? + (h:read-html-as-xml (open-input-string "<новости новости=\"новости\">")) + (list + (x:element + (x:location 0 0 0) + (x:location 0 0 48) + 'новости + (list (x:attribute (x:location 0 0 16) (x:location 0 0 47) 'новости "новости")) + '())))))) (run-tests html-tests)