Package jptests :: Package formalisms :: Package music_halfspan :: Module syntax
[hide private]
[frames] | no frames]

Source Code for Module jptests.formalisms.music_halfspan.syntax

 1  """Unit tests for jazzparser.formalisms.music_halfspan.syntax. 
 2   
 3  This doesn't include tests for the behaviour of the syntactic types under  
 4  rule applications or even the interfaces of the categories. At the moment,  
 5  this just tests building categories from string representations. This  
 6  does mean that we can add more tests now that rely on this method of building  
 7  categories. 
 8   
 9  """ 
10  """ 
11  ============================== License ======================================== 
12   Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding 
13    
14   This file is part of The Jazz Parser. 
15    
16   The Jazz Parser is free software: you can redistribute it and/or modify 
17   it under the terms of the GNU General Public License as published by 
18   the Free Software Foundation, either version 3 of the License, or 
19   (at your option) any later version. 
20    
21   The Jazz Parser is distributed in the hope that it will be useful, 
22   but WITHOUT ANY WARRANTY; without even the implied warranty of 
23   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
24   GNU General Public License for more details. 
25    
26   You should have received a copy of the GNU General Public License 
27   along with The Jazz Parser.  If not, see <http://www.gnu.org/licenses/>. 
28   
29  ============================ End license ====================================== 
30   
31  """ 
32  __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"  
33   
34  import unittest, os 
35   
36  from jazzparser.formalisms.music_halfspan.syntax import syntax_from_string, \ 
37              AtomicCategory, ComplexCategory 
38   
39 -class TestStringBuilder(unittest.TestCase):
40 """ 41 Tests for building categories using C{syntax_from_string}. 42 43 """
44 - def test_half_atomic(self):
45 cat = syntax_from_string("I^T") 46 self.assertIsInstance(cat, AtomicCategory) 47 48 cat = syntax_from_string("II^D") 49 self.assertIsInstance(cat, AtomicCategory) 50 51 cat = syntax_from_string("bV^S") 52 self.assertIsInstance(cat, AtomicCategory)
53
54 - def test_full_atomic(self):
55 cat = syntax_from_string("I^T-II^T") 56 self.assertIsInstance(cat, AtomicCategory) 57 58 cat = syntax_from_string("II^D - V^T") 59 self.assertIsInstance(cat, AtomicCategory) 60 61 cat = syntax_from_string("VII^S - I^T") 62 self.assertIsInstance(cat, AtomicCategory)
63
64 - def test_complex(self):
65 cat = syntax_from_string("V^D / I^T") 66 self.assertIsInstance(cat, ComplexCategory) 67 68 cat = syntax_from_string("II^D / I^TD") 69 self.assertIsInstance(cat, ComplexCategory) 70 71 cat = syntax_from_string(r"bVI^T \ I^S") 72 self.assertIsInstance(cat, ComplexCategory)
73
74 - def test_complex_modality(self):
75 cat = syntax_from_string(r"V^D /{c} I^TD") 76 self.assertIsInstance(cat, ComplexCategory)
77