|
16 | 16 | # Binding, PolyBinding, IfCondition |
17 | 17 | ) |
18 | 18 | from flitter.model import Vector, Node |
19 | | -from flitter.language.parser import parse |
| 19 | +from flitter.language.parser import parse, ParseError |
20 | 20 |
|
21 | 21 |
|
22 | 22 | class ParserTestCase(unittest.TestCase): |
@@ -47,6 +47,31 @@ def test_numbers(self): |
47 | 47 | self.assertParsesTo("1.23456789E-99", Literal(1.23456789e-99)) |
48 | 48 | self.assertParsesTo("1.2_3_4_5_6_7_8_9E1_0_0_0", Literal(1.23456789e1000)) |
49 | 49 |
|
| 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 | + |
50 | 75 | def test_si_prefixes(self): |
51 | 76 | self.assertParsesTo('1T', Literal(1e12)) |
52 | 77 | self.assertParsesTo('1G', Literal(1e9)) |
|
0 commit comments