Ejemplo n.º 1
0
    def testDictionaryEntry(self):
        parser = osp.OpenStepDecoder()
        line = '    /* some comments */ KEY-NAME   /* asd */ =   /* adfasdf */  value-1234    /* adfasdf */   ;'
        result = {}
        index = parser._parse_dictionary_entry(line, 0, result)

        assert result['KEY-NAME'] == 'value-1234'
Ejemplo n.º 2
0
    def testDictionaryEntryTabQuoted(self):
        parser = osp.OpenStepDecoder()
        line = '    /* some comments */ KEY-NAME   /* asd */ =   /* adfasdf */  "\\t pre\\t \\tsuf pre\\tsuf \\t"    /* adfasdf */   ;'
        result = {}
        index = parser._parse_dictionary_entry(line, 0, result)

        assert result['KEY-NAME'] == '\t pre\t \tsuf pre\tsuf \t'
Ejemplo n.º 3
0
 def testArrayEntry(self):
     parser = osp.OpenStepDecoder()
     line = '    /* some comments */ KEY-NAME   /* asd */  , '
     result = []
     index = parser._parse_array_entry(line, 0, result)
     assert result[0] == 'KEY-NAME'
     assert len(result) == 1
Ejemplo n.º 4
0
 def testIsWhitespace(self):
     parser = osp.OpenStepDecoder()
     assert not parser._is_whitespace('a')
     assert not parser._is_whitespace('0')
     assert parser._is_whitespace('\t')
     assert parser._is_whitespace('\r')
     assert parser._is_whitespace('\n')
     assert parser._is_whitespace(' ')
Ejemplo n.º 5
0
 def testDictionaryEntryMissingSemicolon(self):
     parser = osp.OpenStepDecoder()
     line = '    /* some comments */ KEY-NAME   /* asd */  =  /* adfasdf */  value-1234    /* adfasdf */   '
     result = {}
     try:
         index = parser._parse_dictionary_entry(line, 0, result)
         assert 1 == 0
     except Exception:
         pass
Ejemplo n.º 6
0
 def testFullDictionary(self):
     parser = osp.OpenStepDecoder()
     line = '{ ' \
            '    /* some comments */ KEY-NAME1   /* asd */  =  /* adfasdf */  value-1234    /* adfasdf */ ;  ' \
            '    /* some comments */ KEY-NAME2   /* asd */  =  /* adfasdf */  value-5678    /* adfasdf */ ;  ' \
            '}'
     result, index = parser._parse_dictionary(line, 0)
     assert len(result) == 2
     assert result['KEY-NAME1'] == 'value-1234'
     assert result['KEY-NAME2'] == 'value-5678'
Ejemplo n.º 7
0
 def testFullArray(self):
     parser = osp.OpenStepDecoder()
     line = '( ' \
            '    ABC,' \
            '    DEF,' \
            '    GHI,' \
            ')'
     result, index = parser._parse_array(line, 0)
     assert result[0] == 'ABC'
     assert result[1] == 'DEF'
     assert result[2] == 'GHI'
Ejemplo n.º 8
0
 def testFullDictionaryWithoutEndingSemicolon(self):
     # Note that there's no semicolon between value-5678 and "}".
     parser = osp.OpenStepDecoder()
     line = '{ ' \
            '    /* some comments */ KEY-NAME1   /* asd */  =  /* adfasdf */  value-1234    /* adfasdf */ ;  ' \
            '    /* some comments */ KEY-NAME2   /* asd */  =  /* adfasdf */  value-5678' \
            '}'
     result, index = parser._parse_dictionary(line, 0)
     assert len(result) == 2
     assert result['KEY-NAME1'] == 'value-1234'
     assert result['KEY-NAME2'] == 'value-5678'
Ejemplo n.º 9
0
 def testFullArrayWithoutEndingComma(self):
     # Note that there's no comma between GHI and ")".
     parser = osp.OpenStepDecoder()
     line = '( ' \
            '    ABC,' \
            '    DEF,' \
            '    GHI'  \
            ')'
     result, index = parser._parse_array(line, 0)
     assert len(result) == 3
     assert result[0] == 'ABC'
     assert result[1] == 'DEF'
     assert result[2] == 'GHI'
Ejemplo n.º 10
0
 def testParsingKeyQuoted(self):
     parser = osp.OpenStepDecoder()
     line = '    /* some comments */ "KEY-NAME" '
     key, index = parser._parse_key(line, 0)
     assert key == 'KEY-NAME'
     assert index == len(line)
Ejemplo n.º 11
0
 def testIgnoreFakeComment(self):
     parser = osp.OpenStepDecoder()
     index = parser._ignore_comment('/bin/sh/ ', 0)
     assert index == 0
Ejemplo n.º 12
0
 def testIgnoreComment(self):
     parser = osp.OpenStepDecoder()
     index = parser._ignore_comment('/*12345/67890*/ ', 0)
     assert index == 15
Ejemplo n.º 13
0
 def testIgnoreWhitespacesInTheMiddle(self):
     parser = osp.OpenStepDecoder()
     index = parser._ignore_whitespaces('0   3 ', 1)
     assert index == 4
Ejemplo n.º 14
0
 def testIgnoreWhitespacesFromBeginning(self):
     parser = osp.OpenStepDecoder()
     index = parser._ignore_whitespaces('   3 ', 0)
     assert index == 3
Ejemplo n.º 15
0
 def testParseNestedDictionary(self):
     line = '''{ a = { b = b1; }; };'''
     result = osp.OpenStepDecoder()._parse_dictionary(line, 0)
     assert result
Ejemplo n.º 16
0
 def testIgnoreComment(self):
     parser = osp.OpenStepDecoder()
     index = parser._parse_padding('/*12345/67890*/ a', 0)
     assert index == 16