Test for :first-letter punctuation extension

View: New views
2 Messages — Rating Filter:   Alert me  

Test for :first-letter punctuation extension

by L. David Baron :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Attached are two files that I'm contributing to the CSS 2.1 test
suite.  The story behind them is a little complicated, though.

In the tests that Microsoft contributed, there are 412 tests, named
first-letter-punctuation-001.xht through
first-letter-punctuation-412.xht , which are extremely repetitive.
I don't think it's appropriate to have such repetitive tests in a
manual test suite, because of the costs in time of both reviewing
and running them.

This test is an attempt to put all of those tests in a single file
that can be easily verified at a quick glance.  Furthermore, this
test also attempts to test the negative:  that any characters not in
the punctuation classes given do not cause extension of the string
covered by the :first-letter pseudo-element.

This means the resulting test is extremely large, and loads very
slowly.  It's also failing, for a few characters, in all the
browsers I've tried it in.  I haven't yet analyzed if that's a bug
in the test (e.g., making assumptions that it can't make about
certain whitespace characters) or a bug in the browsers in question,
though I suspect it's a bug in the test.

However, I wanted to get the test contributed before the September
15 deadline even though it's incomplete.  So, attached are:

 1) an HTML file that is the beginning of the test
 2) a python script to generate the large part of the test file (the
    hardcoded path in it should be changed to the location of the
    appropriate file from the Unicode 5.1.0 character database),
    which should replace the last 6 lines of (1)

-David

--
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/

CSS 2.1: punctuation classes for :first-letter extension
"C
0C


#!/usr/bin/python

import re

isSurrogateOrPUA = re.compile('^<.*(Private Use|Surrogate).*>$').search

isPunctuation = re.compile('^P(s|e|i|f|o)$').search

charinf = { 'number': 0 }

def print_info(charcode, ispunct):
    printbr = False
    if charinf['number'] == 256:
        charinf['number'] = 0
        printbr = True
    charinf['number'] = charinf['number'] + 1
    if ispunct:
        classname = "extend"
    else:
        classname = "dontextend"
    start = ">"
    if printbr:
        start = start + "</div><div>"
    print start + "<div class=\"test " + classname + "\"><div>&#x" + \
          hex(charcode)[2:] + ";C<span class=\"spacer\"></span></div></div"

unicodedb = open("/home/dbaron/specs/unicode/UNIDATA-5.1.0/UnicodeData.txt")
rangefirst = None
print "<div"
for line in unicodedb:
    fields = line.split(";")
    charcode = int(fields[0], 16)
    charname = fields[1]
    ispunct = isPunctuation(fields[2])
    if isSurrogateOrPUA(charname):
        pass
    elif charname.endswith(", First>"):
        if rangefirst != None:
            raise SyntaxError
        rangefirst = charcode
    elif charname.endswith(", Last>"):
        if rangefirst == None:
            raise SyntaxError
        for c in range(rangefirst, charcode + 1):
            print_info(c, ispunct)
        rangefirst = None
    else:
        if rangefirst != None:
            raise SyntaxError
        print_info(charcode, ispunct)
print "></div>"


Re: Test for :first-letter punctuation extension

by fantasai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

L. David Baron wrote:

> Attached are two files that I'm contributing to the CSS 2.1 test
> suite.  The story behind them is a little complicated, though.
>
> In the tests that Microsoft contributed, there are 412 tests, named
> first-letter-punctuation-001.xht through
> first-letter-punctuation-412.xht , which are extremely repetitive.
> I don't think it's appropriate to have such repetitive tests in a
> manual test suite, because of the costs in time of both reviewing
> and running them.
>
> This test is an attempt to put all of those tests in a single file
> that can be easily verified at a quick glance.  Furthermore, this
> test also attempts to test the negative:  that any characters not in
> the punctuation classes given do not cause extension of the string
> covered by the :first-letter pseudo-element.
>
> This means the resulting test is extremely large, and loads very
> slowly.  It's also failing, for a few characters, in all the
> browsers I've tried it in.  I haven't yet analyzed if that's a bug
> in the test (e.g., making assumptions that it can't make about
> certain whitespace characters) or a bug in the browsers in question,
> though I suspect it's a bug in the test.
>
> However, I wanted to get the test contributed before the September
> 15 deadline even though it's incomplete.  So, attached are:
>
>  1) an HTML file that is the beginning of the test
>  2) a python script to generate the large part of the test file (the
>     hardcoded path in it should be changed to the location of the
>     appropriate file from the Unicode 5.1.0 character database),
>     which should replace the last 6 lines of (1)

I think combining some of those 400+ :first-letter pseudo-element
tests is a good idea, but can we break this up so that it's not
all one huge file? One of the criteria for CSS2.1 tests is that
they have to be *short*: the goal here is to test :first-letter
correctness, not to stress-test mobile devices.

Another problem is that the file is not valid XHTML. (It's not
even well-formed XHTML.) The build scripts will choke on that.
Also, it appears from the source that this is a visual verification
test, but there are no instructions.

Using a script to generate this test is fine; we have other tests
that need a pre-build process. But the other three issues make the
test unusable as-is.

r- fantasai

~fantasai