[feaLib] Round-trip useExtension keyword
This commit is contained in:
parent
18ac453781
commit
f48f4cc6b4
@ -293,7 +293,10 @@ class FeatureBlock(Block):
|
|||||||
builder.end_feature()
|
builder.end_feature()
|
||||||
|
|
||||||
def asFea(self, indent=""):
|
def asFea(self, indent=""):
|
||||||
res = indent + "feature %s {\n" % self.name.strip()
|
res = indent + "feature %s " % self.name.strip()
|
||||||
|
if self.use_extension:
|
||||||
|
res += "useExtension "
|
||||||
|
res += "{\n"
|
||||||
res += Block.asFea(self, indent=indent)
|
res += Block.asFea(self, indent=indent)
|
||||||
res += indent + "} %s;\n" % self.name.strip()
|
res += indent + "} %s;\n" % self.name.strip()
|
||||||
return res
|
return res
|
||||||
@ -329,7 +332,10 @@ class LookupBlock(Block):
|
|||||||
builder.end_lookup_block()
|
builder.end_lookup_block()
|
||||||
|
|
||||||
def asFea(self, indent=""):
|
def asFea(self, indent=""):
|
||||||
res = "lookup {} {{\n".format(self.name)
|
res = "lookup {} ".format(self.name)
|
||||||
|
if self.use_extension:
|
||||||
|
res += "useExtension "
|
||||||
|
res += "{\n"
|
||||||
res += Block.asFea(self, indent=indent)
|
res += Block.asFea(self, indent=indent)
|
||||||
res += "{}}} {};\n".format(indent, self.name)
|
res += "{}}} {};\n".format(indent, self.name)
|
||||||
return res
|
return res
|
||||||
|
@ -215,6 +215,8 @@ class ParserTest(unittest.TestCase):
|
|||||||
[liga] = self.parse("feature liga useExtension {} liga;").statements
|
[liga] = self.parse("feature liga useExtension {} liga;").statements
|
||||||
self.assertEqual(liga.name, "liga")
|
self.assertEqual(liga.name, "liga")
|
||||||
self.assertTrue(liga.use_extension)
|
self.assertTrue(liga.use_extension)
|
||||||
|
self.assertEqual(liga.asFea(),
|
||||||
|
"feature liga useExtension {\n \n} liga;\n")
|
||||||
|
|
||||||
def test_feature_comment(self):
|
def test_feature_comment(self):
|
||||||
[liga] = self.parse("feature liga { # Comment\n } liga;").statements
|
[liga] = self.parse("feature liga { # Comment\n } liga;").statements
|
||||||
@ -608,6 +610,8 @@ class ParserTest(unittest.TestCase):
|
|||||||
[lookup] = self.parse("lookup Foo useExtension {} Foo;").statements
|
[lookup] = self.parse("lookup Foo useExtension {} Foo;").statements
|
||||||
self.assertEqual(lookup.name, "Foo")
|
self.assertEqual(lookup.name, "Foo")
|
||||||
self.assertTrue(lookup.use_extension)
|
self.assertTrue(lookup.use_extension)
|
||||||
|
self.assertEqual(lookup.asFea(),
|
||||||
|
"lookup Foo useExtension {\n \n} Foo;\n")
|
||||||
|
|
||||||
def test_lookup_block_name_mismatch(self):
|
def test_lookup_block_name_mismatch(self):
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user