示例#1
0
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     expected = [('python is fun', FILTER),
                 ('&&', AND),
                 ('python is simple', FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#2
0
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     expected = [('python is fun', FILTER),
                 ('||', OR),
                 ('python is the best', FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#3
0
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     expected = [
         ('python is fun', FILTER),
         ('||', OR),
         ('python is the best', FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#4
0
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     expected = [
         ('python is fun', FILTER),
         ('&&', AND),
         ('python is simple', FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#5
0
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     expected = [('python is fun', FILTER),
                 ('&&', AND),
                 ('python is simple', FILTER),
                 ('||', OR),
                 ('python is the best', FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#6
0
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     expected = [
         ('python is fun', FILTER),
         ('&&', AND),
         ('python is simple', FILTER),
         ('||', OR),
         ('python is the best', FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#7
0
 def test_mixed_grouping(self):
     test_str = 'python is fun && (python is simple || python is the best)'
     expected = [('python is fun', FILTER),
                 ('&&', AND),
                 ('(', LPAREN),
                 ('python is simple', FILTER),
                 ('||', OR),
                 ('python is the best', FILTER),
                 (')', RPAREN),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#8
0
 def test_mixed_grouping(self):
     test_str = 'python is fun && (python is simple || python is the best)'
     expected = [
         ('python is fun', FILTER),
         ('&&', AND),
         ('(', LPAREN),
         ('python is simple', FILTER),
         ('||', OR),
         ('python is the best', FILTER),
         (')', RPAREN),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#9
0
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     expected = [('a', FILTER),
                 ('&&', AND),
                 ('(', LPAREN),
                 ('b', FILTER),
                 ('||', OR),
                 ('(', LPAREN),
                 ('c', FILTER),
                 ('&&', AND),
                 ('d', FILTER),
                 (')', RPAREN),
                 (')', RPAREN),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#10
0
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     expected = [
         ('a', FILTER),
         ('&&', AND),
         ('(', LPAREN),
         ('b', FILTER),
         ('||', OR),
         ('(', LPAREN),
         ('c', FILTER),
         ('&&', AND),
         ('d', FILTER),
         (')', RPAREN),
         (')', RPAREN),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#11
0
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     expected = [('a', FILTER),
                 ('&&', AND),
                 ('(', LPAREN),
                 ('b', FILTER),
                 ('||', OR),
                 ('(', LPAREN),
                 ('c', FILTER),
                 ('&&', AND),
                 ('d', FILTER),
                 (')', RPAREN),
                 (')', RPAREN),
                 ('||', OR),
                 ("'(e)'", QUOTED_FILTER),
                 ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#12
0
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     expected = [
         ('a', FILTER),
         ('&&', AND),
         ('(', LPAREN),
         ('b', FILTER),
         ('||', OR),
         ('(', LPAREN),
         ('c', FILTER),
         ('&&', AND),
         ('d', FILTER),
         (')', RPAREN),
         (')', RPAREN),
         ('||', OR),
         ("'(e)'", QUOTED_FILTER),
     ]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#13
0
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(python is fun), FilterExpr(python is simple))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#14
0
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     expected = [('python is the best', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#15
0
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d)))), QuotedFilterExpr((e)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#16
0
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d))))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#17
0
 def test_mixed_grouping_not(self):
     test_str = '!python is not fun && (python is simple || python is the best)'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(NotExpr(FilterExpr(python is not fun)), OrExpr(FilterExpr(python is simple), FilterExpr(python is the best)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#18
0
 def test_simple(self):
     test_str = 'python'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#19
0
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(python is fun), FilterExpr(python is simple)), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#20
0
 def test_simple(self):
     test_str = 'python'
     expected = [('python', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#21
0
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(FilterExpr(python is fun), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#22
0
 def test_simple(self):
     test_str = 'python'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#23
0
 def test_mixed_AND_and_OR(self):
     test_str = 'python is fun && python is simple || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(python is fun), FilterExpr(python is simple)), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#24
0
 def test_simple(self):
     test_str = 'python'
     expected = [('python', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#25
0
 def test_mixed_grouping_not(self):
     test_str = '!python is not fun && (python is simple || python is the best)'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(NotExpr(FilterExpr(python is not fun)), OrExpr(FilterExpr(python is simple), FilterExpr(python is the best)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#26
0
 def test_multi_tier(self):
     test_str = 'a && (b || (c && d))'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d))))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#27
0
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     expected = [('python is the best', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
示例#28
0
 def test_simple_AND(self):
     test_str = 'python is fun && python is simple'
     tokens = filter_lex(test_str)
     expected = 'AndExpr(FilterExpr(python is fun), FilterExpr(python is simple))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#29
0
 def test_simple_OR(self):
     test_str = 'python is fun || python is the best'
     tokens = filter_lex(test_str)
     expected = 'OrExpr(FilterExpr(python is fun), FilterExpr(python is the best))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#30
0
 def test_quoted_filter(self):
     test_str = "a && (b || (c && d)) || '(e)'"
     tokens = filter_lex(test_str)
     expected = 'OrExpr(AndExpr(FilterExpr(a), OrExpr(FilterExpr(b), AndExpr(FilterExpr(c), FilterExpr(d)))), QuotedFilterExpr((e)))'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#31
0
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python is the best)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)
示例#32
0
 def test_simple_with_spaces(self):
     test_str = 'python is the best'
     tokens = filter_lex(test_str)
     expected = 'FilterExpr(python is the best)'
     actual = str(TokenParser(tokens).E())
     self.assertEqual(expected, actual)