Skip to content

Commit c3fe14d

Browse files
committed
Add a few parser tests for time codes
1 parent 805a9a7 commit c3fe14d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/test_parser.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Binding, PolyBinding, IfCondition
1717
)
1818
from flitter.model import Vector, Node
19-
from flitter.language.parser import parse
19+
from flitter.language.parser import parse, ParseError
2020

2121

2222
class ParserTestCase(unittest.TestCase):
@@ -47,6 +47,31 @@ def test_numbers(self):
4747
self.assertParsesTo("1.23456789E-99", Literal(1.23456789e-99))
4848
self.assertParsesTo("1.2_3_4_5_6_7_8_9E1_0_0_0", Literal(1.23456789e1000))
4949

50+
def test_timecodes(self):
51+
self.assertParsesTo("0:0", Literal(0))
52+
self.assertParsesTo("0:0.0", Literal(0))
53+
self.assertParsesTo("0:0:0", Literal(0))
54+
self.assertParsesTo("0:0:0.0", Literal(0))
55+
self.assertParsesTo("000:00:00.000", Literal(0))
56+
self.assertParsesTo("0:1", Literal(1))
57+
self.assertParsesTo("000:00:01.000", Literal(1))
58+
self.assertParsesTo("0:0.1", Literal(0.1))
59+
self.assertParsesTo("000:00:00.100", Literal(0.1))
60+
self.assertParsesTo("1:0", Literal(60))
61+
self.assertParsesTo("000:01:00.000", Literal(60))
62+
self.assertParsesTo("1:0:0", Literal(3600))
63+
self.assertParsesTo("001:00:00.000", Literal(3600))
64+
self.assertParsesTo("1:1:1", Literal(3661))
65+
self.assertParsesTo("001:01:01.000", Literal(3661))
66+
self.assertParsesTo("001:01:01.100", Literal(3661.1))
67+
self.assertParsesTo("999:59:59.999", Literal(3599999.999))
68+
with self.assertRaises(ParseError):
69+
parse("0:0:0:0")
70+
with self.assertRaises(ParseError):
71+
parse("0:60")
72+
with self.assertRaises(ParseError):
73+
parse("60:00")
74+
5075
def test_si_prefixes(self):
5176
self.assertParsesTo('1T', Literal(1e12))
5277
self.assertParsesTo('1G', Literal(1e9))

0 commit comments

Comments
 (0)