From 35990e5939c9e76bf80294cee5ff2ebc4d36bf2d Mon Sep 17 00:00:00 2001 From: Jonathan Lee Date: Fri, 21 Oct 2022 12:07:31 -0700 Subject: [PATCH] [wptmanifest] Allow atoms in a group block (#36596) This change fixes an unintuitive parse failure that occurs from writing something like: ``` disabled: @False ``` Whereas this parses OK: ``` disabled: @False ``` --- tools/wptrunner/wptrunner/wptmanifest/parser.py | 2 ++ .../wptrunner/wptmanifest/tests/test_serializer.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/tools/wptrunner/wptrunner/wptmanifest/parser.py b/tools/wptrunner/wptrunner/wptmanifest/parser.py index c0ef9b4dd33d43..11e73841f7c3b5 100644 --- a/tools/wptrunner/wptrunner/wptmanifest/parser.py +++ b/tools/wptrunner/wptrunner/wptmanifest/parser.py @@ -599,6 +599,8 @@ def value_block(self): self.expression_values() if self.token[0] == token_types.string: self.value() + elif self.token[0] == token_types.atom: + self.atom() elif self.token[0] == token_types.list_start: self.consume() self.list_value() diff --git a/tools/wptrunner/wptrunner/wptmanifest/tests/test_serializer.py b/tools/wptrunner/wptrunner/wptmanifest/tests/test_serializer.py index 84917491fc0a13..7635e0ad238648 100644 --- a/tools/wptrunner/wptrunner/wptmanifest/tests/test_serializer.py +++ b/tools/wptrunner/wptrunner/wptmanifest/tests/test_serializer.py @@ -1,5 +1,6 @@ # mypy: allow-untyped-defs +import textwrap import unittest from .. import parser, serializer @@ -146,6 +147,15 @@ def test_18(self): """, """key: ] """) + def test_atom_as_default(self): + self.compare( + textwrap.dedent( + """\ + key: + if a == 1: @True + @False + """).encode()) + def test_escape_0(self): self.compare(br"""k\t\:y: \a\b\f\n\r\t\v""", r"""k\t\:y: \x07\x08\x0c\n\r\t\x0b