def test_getenv_OS_module_fcn(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
getenv("SHELL") #not avaiable in safe mode
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(
            exprCode, RuntimeException, "getenv")
Exemplo n.º 2
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
    def test_globals_deleted_fcn(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
globals() #not avaiable in safe mode
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(
            exprCode, RuntimeException, "globals")
    def test_safe_mode_neg(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2014
raw_input("How old is the earth?>> ")
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(
            exprCode, RuntimeException, "may not be used in SAFE MODE")
    def test_system_OS_function(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2014
system("ls -lrt")
system("cat /etc/passwd")
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(exprCode,RuntimeException,"system")
    def test_system_OS_function(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2014
system("ls -lrt")
system("cat /etc/passwd")
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(
            exprCode, RuntimeException, "system")
Exemplo n.º 7
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
Exemplo n.º 8
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")
Exemplo n.º 9
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")
Exemplo n.º 10
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")
Exemplo n.º 11
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")
Exemplo n.º 12
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")
Exemplo n.º 13
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")
Exemplo n.º 14
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"])
Exemplo n.º 15
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")
Exemplo n.º 16
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")
    def test_dupe_fcns(self):        
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013

நிரல்பாகம்  fact ( n )
  @( n == 0 ) ஆனால்
            பின்கொடு  1
     இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி
முடி

நிரல்பாகம்  fact ( n )
  @( n == 0 ) ஆனால்
            பின்கொடு  1
     இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி
முடி

பதிப்பி fact(5)
""" #we raise exception on duplicate fcns
        TestEzhilException.create_and_test_spl_safe_mode(exprCode,Exception,"multiply defined")
Exemplo n.º 18
0
    def test_dupe_fcns(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013

நிரல்பாகம்  fact ( n )
  @( n == 0 ) ஆனால்
            பின்கொடு  1
     இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி
முடி

நிரல்பாகம்  fact ( n )
  @( n == 0 ) ஆனால்
            பின்கொடு  1
     இல்லை
            பின்கொடு    n*fact( n - 1 )
    முடி
முடி

பதிப்பி fact(5)
""" #we raise exception on duplicate fcns
        TestEzhilException.create_and_test_spl_safe_mode(
            exprCode, Exception, "multiply defined")
Exemplo n.º 19
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")
Exemplo n.º 20
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
    def test_safe_mode_neg(self):
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2014
raw_input("How old is the earth?>> ")
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(exprCode,RuntimeException,"may not be used in SAFE MODE")
    def test_globals_deleted_fcn(self):        
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
globals() #not avaiable in safe mode
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(exprCode,RuntimeException,"globals")
    def test_getenv_OS_module_fcn(self):        
        exprCode  = u"""
# (C) முத்தையா அண்ணாமலை 2013
getenv("SHELL") #not avaiable in safe mode
""" #missing end function statement
        TestEzhilException.create_and_test_spl_safe_mode(exprCode,RuntimeException,"getenv")
Exemplo n.º 24
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
Exemplo n.º 25
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
Exemplo n.º 26
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
Exemplo n.º 27
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")