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_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
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")
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")
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")
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")
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")
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"])
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")
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_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_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
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_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")
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_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")
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