dom/bindings/parser/tests/test_error_lineno.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/bindings/parser/tests/test_error_lineno.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,28 @@
     1.4 +import WebIDL
     1.5 +
     1.6 +def WebIDLTest(parser, harness):
     1.7 +    # Check that error messages put the '^' in the right place.
     1.8 +
     1.9 +    threw = False
    1.10 +    input = """\
    1.11 +// This is a comment.
    1.12 +interface Foo {
    1.13 +};
    1.14 +
    1.15 +/* This is also a comment. */
    1.16 +interface ?"""
    1.17 +    try:
    1.18 +        parser.parse(input)
    1.19 +        results = parser.finish()
    1.20 +    except WebIDL.WebIDLError, e:
    1.21 +        threw = True
    1.22 +        lines = str(e).split('\n')
    1.23 +
    1.24 +        harness.check(len(lines), 3, 'Expected number of lines in error message')
    1.25 +        harness.ok(lines[0].endswith('line 6:10'), 'First line of error should end with "line 6:10", but was "%s".' % lines[0])
    1.26 +        harness.check(lines[1], 'interface ?', 'Second line of error message is the line which caused the error.')
    1.27 +        harness.check(lines[2], ' ' * (len('interface ?') - 1) + '^',
    1.28 +                      'Correct column pointer in error message.')
    1.29 +
    1.30 +    harness.ok(threw, "Should have thrown.")
    1.31 +

mercurial