Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 20
0
 def test_simple(self):
     test_str = 'python'
     expected = [('python', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 24
0
 def test_simple(self):
     test_str = 'python'
     expected = [('python', FILTER)]
     actual = filter_lex(test_str)
     self.assertEqual(expected, actual)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)