def test_simple_values(self): ast, _ = self.ftl_parser.parse(ftl(''' foo = Foo bar = Bar ''')) self.assertEqual( ast.traverse(lambda x: x).toJSON(), ast.toJSON() )
def test_complex_values(self): ast, _ = self.ftl_parser.parse(ftl(''' foo = Foo foo = Foo { bar } [bar] AAA { $num -> [one] One *[other] Many { NUMBER($num) } } BBB ''')) self.assertEqual( ast.traverse(lambda x: x).toJSON(), ast.toJSON() )
def ftl_message_to_json(code): ast, errors = ftl_parser.parse(ftl(code), with_source=False) return ast.body[0].toJSON()
def ftl_resource_to_json(code): ast, errors = ftl_parser.parseResource(ftl(code), with_source=False) return ast