Пример #1
0
    def test_list_error(self):
        """ list error """
        the_string = "  a ]"

        compiler = Compiler()

        try:
            compiler.compile_list(the_string)
        except CompilerError, err:
            self.assertEqual(err.message, 'Expression "  a ]" cannot be converted as a list.')
Пример #2
0
 def test_list_error_2(self):
     """ unsupported char @ """
     the_string = " a @"
     
     compiler = Compiler()
     
     try:
         compiler.compile_list(the_string)
     except CompilerError, err:
         self.assertEqual(err.message, 'Unsupported token (type: @, value : OP) (line=1,col=3).')
Пример #3
0
    def test_list_error_2(self):
        """ unsupported char @ """
        the_string = " a @"

        compiler = Compiler()

        try:
            compiler.compile_list(the_string)
        except CompilerError, err:
            self.assertEqual(err.message, "Unsupported token (type: @, value : OP) (line=1,col=3).")
Пример #4
0
 def test_list_error(self):
     """ list error """
     the_string = "  a ]"
     
     compiler = Compiler()
     
     try:
         compiler.compile_list(the_string)
     except CompilerError, err:
         self.assertEqual(err.message, 'Expression "  a ]" cannot be converted as a list.')
Пример #5
0
 def test_negative_number_test(self):
     """ a negative number test """
     the_string = "         [ '-10.4',     1.435, 3 ]"
     
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, [ '-10.4', 1.435, 3])
Пример #6
0
    def test_list_without_bracket_ztest_2(self):
        """ list without bracket test with a list inside """
        the_string = " 'a', b, ['a thing', 2]"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["a", "b", ["a thing", 2]])
Пример #7
0
    def test_negative_number_test(self):
        """ a negative number test """
        the_string = "         [ '-10.4',     1.435, 3 ]"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["-10.4", 1.435, 3])
Пример #8
0
 def test_list_without_bracket_ztest_2(self):
     """ list without bracket test with a list inside """
     the_string = " 'a', b, ['a thing', 2]"
             
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, ['a','b', ['a thing', 2] ])
Пример #9
0
 def test_special_character_in_string(self):
     """ simple list without bracket test """
     
     the_string = " 'a@', b"
             
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, ['a@','b'])
Пример #10
0
    def test_list_without_bracket_test(self):
        """ simple list without bracket test """

        the_string = " 'a', b"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["a", "b"])
Пример #11
0
    def test_imbricated_lists_test(self):
        """ multiple lists within lists """

        the_string = "[a,b, [1,2,3,4, [456,6,'absdef'], 234, 2.456 ], aqwe, done]"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["a", "b", [1, 2, 3, 4, [456, 6, "absdef"], 234, 2.456], "aqwe", "done"])
Пример #12
0
    def test_simple_list_test(self):
        """ a first simple test with space and indent, dedents to eat"""

        the_string = "         [ 'a',     1.435, 3 ]"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["a", 1.435, 3])
Пример #13
0
    def test_everything(self):
        """ everything """

        the_string = "['a',1,'b',{2:3,4:[1,'hello', no quotes, [1,2,3,{1:2,3:4}]]} ]"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["a", 1, "b", {2: 3, 4: [1, "hello", "no quotes", [1, 2, 3, {1: 2, 3: 4}]]}])
Пример #14
0
    def test_list_with_dict(self):
        """ list with dict """

        the_string = "['a',1,'b',{2:3,4:5} ]"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["a", 1, "b", {2: 3, 4: 5}])
Пример #15
0
 def test_list_with_dict(self):
     """ list with dict """
     
     the_string = "['a',1,'b',{2:3,4:5} ]"
             
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, ['a', 1, 'b', { 2 : 3 , 4 : 5} ])
Пример #16
0
 def test_everything(self):
     """ everything """
     
     the_string = "['a',1,'b',{2:3,4:[1,'hello', no quotes, [1,2,3,{1:2,3:4}]]} ]"
             
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, ['a',1,'b',{2:3,4:[1,'hello', 'no quotes', [1,2,3,{1:2,3:4}]]} ])
Пример #17
0
 def test_simple_list_test(self):
     """ a first simple test with space and indent, dedents to eat"""
     
     the_string = "         [ 'a',     1.435, 3 ]"
     
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, [ 'a', 1.435, 3])
Пример #18
0
 def test_list_without_bracket_test(self):
     """ simple list without bracket test """
     
     the_string = " 'a', b"
             
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, ['a','b'])
Пример #19
0
 def test_imbricated_lists_test(self):
     """ multiple lists within lists """
     
     the_string = "[a,b, [1,2,3,4, [456,6,'absdef'], 234, 2.456 ], aqwe, done]"
             
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, ['a','b', [1,2,3,4, [456,6,'absdef'], 234, 2.456 ], 'aqwe', 'done'])
Пример #20
0
    def test_special_character_in_string(self):
        """ simple list without bracket test """

        the_string = " 'a@', b"

        compiler = Compiler()

        the_result = compiler.compile_list(the_string)

        self.assertEqual(the_result, ["a@", "b"])
Пример #21
0
 def test_list_with_tuple(self):
     """ compile tuple """
     
     the_string = "['a',1,'b', ('1','2','3'), 'd', 'e']"
     
     compiler = Compiler()
     
     the_result = compiler.compile_list(the_string)
     
     self.assertEqual(the_result, ['a',1,'b', ('1','2','3'), 'd', 'e'])