aboutsummaryrefslogtreecommitdiff
path: root/Tests/feaLib/parser_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/feaLib/parser_test.py')
-rw-r--r--Tests/feaLib/parser_test.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/Tests/feaLib/parser_test.py b/Tests/feaLib/parser_test.py
index db505950..de2bc3ca 100644
--- a/Tests/feaLib/parser_test.py
+++ b/Tests/feaLib/parser_test.py
@@ -1280,6 +1280,76 @@ class ParserTest(unittest.TestCase):
'"dflt" is not a valid script tag; use "DFLT" instead',
self.parse, "feature test {script dflt;} test;")
+ def test_stat_design_axis(self): # STAT DesignAxis
+ doc = self.parse('table STAT { DesignAxis opsz 0 '
+ '{name "Optical Size";}; } STAT;')
+ da = doc.statements[0].statements[0]
+ self.assertIsInstance(da, ast.STATDesignAxisStatement)
+ self.assertEqual(da.tag, 'opsz')
+ self.assertEqual(da.axisOrder, 0)
+ self.assertEqual(da.names[0].string, 'Optical Size')
+
+ def test_stat_axis_value_format1(self): # STAT AxisValue
+ doc = self.parse('table STAT { DesignAxis opsz 0 '
+ '{name "Optical Size";}; '
+ 'AxisValue {location opsz 8; name "Caption";}; } '
+ 'STAT;')
+ avr = doc.statements[0].statements[1]
+ self.assertIsInstance(avr, ast.STATAxisValueStatement)
+ self.assertEqual(avr.locations[0].tag, 'opsz')
+ self.assertEqual(avr.locations[0].values[0], 8)
+ self.assertEqual(avr.names[0].string, 'Caption')
+
+ def test_stat_axis_value_format2(self): # STAT AxisValue
+ doc = self.parse('table STAT { DesignAxis opsz 0 '
+ '{name "Optical Size";}; '
+ 'AxisValue {location opsz 8 6 10; name "Caption";}; } '
+ 'STAT;')
+ avr = doc.statements[0].statements[1]
+ self.assertIsInstance(avr, ast.STATAxisValueStatement)
+ self.assertEqual(avr.locations[0].tag, 'opsz')
+ self.assertEqual(avr.locations[0].values, [8, 6, 10])
+ self.assertEqual(avr.names[0].string, 'Caption')
+
+ def test_stat_axis_value_format2_bad_range(self): # STAT AxisValue
+ self.assertRaisesRegex(
+ FeatureLibError,
+ 'Default value 5 is outside of specified range 6-10.',
+ self.parse, 'table STAT { DesignAxis opsz 0 '
+ '{name "Optical Size";}; '
+ 'AxisValue {location opsz 5 6 10; name "Caption";}; } '
+ 'STAT;')
+
+ def test_stat_axis_value_format4(self): # STAT AxisValue
+ self.assertRaisesRegex(
+ FeatureLibError,
+ 'Only one value is allowed in a Format 4 Axis Value Record, but 3 were found.',
+ self.parse, 'table STAT { '
+ 'DesignAxis opsz 0 {name "Optical Size";}; '
+ 'DesignAxis wdth 0 {name "Width";}; '
+ 'AxisValue {'
+ 'location opsz 8 6 10; '
+ 'location wdth 400; '
+ 'name "Caption";}; } '
+ 'STAT;')
+
+ def test_stat_elidedfallbackname(self): # STAT ElidedFallbackName
+ doc = self.parse('table STAT { ElidedFallbackName {name "Roman"; '
+ 'name 3 1 0x0411 "ローマン"; }; '
+ '} STAT;')
+ nameRecord = doc.statements[0].statements[0]
+ self.assertIsInstance(nameRecord, ast.ElidedFallbackName)
+ self.assertEqual(nameRecord.names[0].string, 'Roman')
+ self.assertEqual(nameRecord.names[1].string, 'ローマン')
+
+ def test_stat_elidedfallbacknameid(self): # STAT ElidedFallbackNameID
+ doc = self.parse('table name { nameid 278 "Roman"; } name; '
+ 'table STAT { ElidedFallbackNameID 278; '
+ '} STAT;')
+ nameRecord = doc.statements[0].statements[0]
+ self.assertIsInstance(nameRecord, ast.NameRecord)
+ self.assertEqual(nameRecord.string, 'Roman')
+
def test_sub_single_format_a(self): # GSUB LookupType 1
doc = self.parse("feature smcp {substitute a by a.sc;} smcp;")
sub = doc.statements[0].statements[0]