Ejemplo n.º 1
0
 def test_invalid_id_lex(self):
     for wrongID in [
             u"é.€ = 1.23", u"பதிப்பி é.€", "Raj.Reddy", "Edsger.Dijkstra"
     ]:
         TestEzhilException.create_and_test(wrongID, ScannerException,
                                            "Lexical error")
     return
Ejemplo n.º 2
0
 def test_lexer_error(self):
     for wrongID in [
             u"Turing'", u"babb@ge", u"Ada'", u"Grace'", u"Hopper\"",
             u"Li$kov", u"sch@figoldw@$$er"
     ]:
         TestEzhilException.create_and_test(wrongID, ScannerException,
                                            "is not valid for identifier")
     return
Ejemplo n.º 3
0
    def test_missing_end(self):        
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம்
நிரல்பாகம்  fact ( n )
  @( n == 0 ) ஆனால்
            பின்கொடு  1
     இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி""" #missing end function statement
        TestEzhilException.create_and_test(exprCode,ParseException,"cannot find token END")
Ejemplo n.º 4
0
    def test_missing_ifstmt(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம்
நிரல்பாகம்  fact ( n )
  @( n == 0 )  இல்லை
            பின்கொடு  1
     ஆனால்
            பின்கொடு    n*fact( n - 1 )
    முடி""" #missing end function statement
        TestEzhilException.create_and_test(exprCode,ParseException,"parsing Statement, unknown operators")
Ejemplo n.º 5
0
    def test_missing_ifstmt(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம்
நிரல்பாகம்  fact ( n )
  @( n == 0 )  இல்லை
            பின்கொடு  1
     ஆனால்
            பின்கொடு    n*fact( n - 1 )
    முடி""" #missing end function statement
        TestEzhilException.create_and_test(exprCode,ParseException,"parsing Statement, unknown operators")
Ejemplo n.º 6
0
    def test_missing_end(self):        
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம்
நிரல்பாகம்  fact ( n )
  @( n == 0 ) ஆனால்
            பின்கொடு  1
     இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி""" #missing end function statement
        TestEzhilException.create_and_test(exprCode,ParseException,"cannot find token END")
Ejemplo n.º 7
0
    def test_nested_fn(self):
        exprCode = u""" நிரல்பாகம்  fact2 ( n )
    @( n == 0 ) ஆனால்      
            பின்கொடு  1
    இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி
    நிரல்பாகம்  fact ( n )
        1+1 #nested function
    முடி
முடி""" #error message is bad for nested function case. but alteast it errors out.
        TestEzhilException.create_and_test(exprCode,ParseException,u"Parse error: cannot find token END")
Ejemplo n.º 8
0
    def test_nested_fn(self):
        exprCode = u""" நிரல்பாகம்  fact2 ( n )
    @( n == 0 ) ஆனால்      
            பின்கொடு  1
    இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி
    நிரல்பாகம்  fact ( n )
        1+1 #nested function
    முடி
முடி""" #error message is bad for nested function case. but alteast it errors out.
        TestEzhilException.create_and_test(exprCode,ParseException,[r"Expected Number, found something","Line=7, Col=5"])
Ejemplo n.º 9
0
    def test_nested_fn(self):
        exprCode = u""" நிரல்பாகம்  fact2 ( n )
    @( n == 0 ) ஆனால்      
            பின்கொடு  1
    இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி
    நிரல்பாகம்  fact ( n )
        1+1 #nested function
    முடி
முடி""" #error message is bad for nested function case. but alteast it errors out.
        TestEzhilException.create_and_test(exprCode,ParseException,u"Parse error: cannot find token END")
Ejemplo n.º 10
0
    def test_return_stmt_dangling_function(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம்
    நிரல்பாகம்  fact2 ( n )
       1+1 #nested function
    முடி
    @( n == 0 ) ஆனால்
            பின்கொடு  1
    இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி"""
        TestEzhilException.create_and_test(exprCode,ParseException,"return statement outside of function body")
Ejemplo n.º 11
0
    def test_return_stmt_dangling_function(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
# இது ஒரு எழில் தமிழ் நிரலாக்க மொழி உதாரணம்
    நிரல்பாகம்  fact2 ( n )
       1+1 #nested function
    முடி
    @( n == 0 ) ஆனால்
            பின்கொடு  1
    இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி"""
        TestEzhilException.create_and_test(exprCode,ParseException,"return statement outside of function body")
Ejemplo n.º 12
0
 def test_lexer_error(self):
     for wrongID in [u"Turing'", u"babb@ge", u"Ada'", u"Grace'", u'Hopper"', u"Li$kov", u"sch@figoldw@$$er"]:
         TestEzhilException.create_and_test(wrongID, ScannerException, "is not valid for identifier")
     return
Ejemplo n.º 13
0
 def test_neg_lex(self):
     for wrongID in [u"λஃ = 5", u"x☺ = 5 #not legal"]:
         TestEzhilException.create_and_test(wrongID, ScannerException, "Lexical error")
     return
Ejemplo n.º 14
0
 def test_run_addition(self):
     from  ezhil.errors import ParseException        
     for exprCode in ["1--","+1+","2-4/5%","5%5%"]:
         TestEzhilException.create_and_test(exprCode,ParseException,"Expected Number")
Ejemplo n.º 15
0
 def test_neg_lex(self):
     for wrongID in [u"λஃ = 5", u"x☺ = 5 #not legal"]:
         TestEzhilException.create_and_test(wrongID, ScannerException,
                                            "Lexical error")
     return
Ejemplo n.º 16
0
 def test_run_addition(self):
     from  ezhil.errors import ParseException        
     for exprCode in ["1--","+1+","2-4/5%","5%5%"]:
         TestEzhilException.create_and_test(exprCode,ParseException,"Expected Number")
Ejemplo n.º 17
0
 def test_invalid_id_lex(self):
     for wrongID in [u"é.€ = 1.23", u"பதிப்பி é.€", "Raj.Reddy", "Edsger.Dijkstra"]:
         TestEzhilException.create_and_test(wrongID, ScannerException, "Lexical error")
     return