Exemplo n.º 1
0
 def test_no_for(self):
     a = "hello"
     l = [1, 2, 3, 4, 5, 6, 7, [1, 2, 3, 4, 5, 6, 7, [1, 2, 3, 4, 5, 6, 7, 8]]]
     q = None
     d = locals()
     try:
         d.update(__builtins__.__dict__)
     except AttributeError:
         d.update(__builtins__)
     flwr = symbols.flwrSequence([symbols.attributeValue("hello", scalar=True)])
     self.assertEquals(flwr(d), ("hello",))
     self.assertEquals(
         exe(
             """
         return l
       """,
             d,
         ),
         (l,),
     )
     self.assertEquals(
         exe(
             """
         let f = function(l) {
           if (isinstance(l, list))
           then {for j in l return f(j)}
           else l
         }
         return flatten f(l)
       """,
             d,
         ),
         (1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8),
     )
Exemplo n.º 2
0
 def test_no_for(self):
     a = 'hello'
     l = [1,2,3,4,5,6,7,[1,2,3,4,5,6,7,[1,2,3,4,5,6,7,8]]]
     q = None
     d = locals()
     try: d.update(__builtins__.__dict__)
     except AttributeError: d.update(__builtins__)
     flwr = symbols.flwrSequence([symbols.attributeValue('hello', scalar=True)])
     self.assertEquals(flwr(d), ('hello',))
     self.assertEquals(exe('''
         return l
       ''', d), (l,))
     self.assertEquals(exe('''
         let f = function(l) {
           if (isinstance(l, list))
           then {for j in l return f(j)}
           else l
         }
         return flatten f(l)
       ''', d), (1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8))
Exemplo n.º 3
0
 def p_SetExpr__2(self, t):
     'SetExpr : ArithExpr NOT IN AttributeValue'
     t[0] = symbols.setexprValue1(t[1], symbols.setexprOperator1('not in'), symbols.attributeValue(t[4]))
Exemplo n.º 4
0
 def p_SetExpr__1(self, t):
     'SetExpr : ArithExpr IN AttributeValue'
     t[0] = symbols.setexprValue1(t[1], symbols.setexprOperator1('in'), symbols.attributeValue(t[3]))
Exemplo n.º 5
0
 def p_Value4(self, t):
     'Value : AttributeValue'
     t[0] = symbols.attributeValue(t[1])
Exemplo n.º 6
0
 def p_Value2(self, t):
     'Value : STRING'
     t[0] = symbols.attributeValue(t[1], scalar=True)
Exemplo n.º 7
0
 def p_Value1(self, t):
     'Value : NUMBER'
     t[0] = symbols.attributeValue(t[1], scalar=True)
Exemplo n.º 8
0
 def p_ArithUnary2(self, t):
     'ArithUnary : DASH Atomic'
     t[0] = symbols.arithValue(symbols.attributeValue(-1.0, scalar=True), symbols.arith_operator('*'), t[2])
Exemplo n.º 9
0
 def p_CollectFunction1(self, t):
     'CollectFunction : AttributeValue'
     t[0] = symbols.attributeValue(t[1])
Exemplo n.º 10
0
 def p_SetExpr__2(self, t):
     'SetExpr : ArithExpr NOT IN AttributeValue'
     t[0] = symbols.setexprValue1(t[1], symbols.setexprOperator1('not in'),
                                  symbols.attributeValue(t[4]))
Exemplo n.º 11
0
 def p_SetExpr__1(self, t):
     'SetExpr : ArithExpr IN AttributeValue'
     t[0] = symbols.setexprValue1(t[1], symbols.setexprOperator1('in'),
                                  symbols.attributeValue(t[3]))
Exemplo n.º 12
0
 def p_Value4(self, t):
     'Value : AttributeValue'
     t[0] = symbols.attributeValue(t[1])
Exemplo n.º 13
0
 def p_Value2(self, t):
     'Value : STRING'
     t[0] = symbols.attributeValue(t[1], scalar=True)
Exemplo n.º 14
0
 def p_Value1(self, t):
     'Value : NUMBER'
     t[0] = symbols.attributeValue(t[1], scalar=True)
Exemplo n.º 15
0
 def p_ArithUnary2(self, t):
     'ArithUnary : DASH Atomic'
     t[0] = symbols.arithValue(symbols.attributeValue(-1.0, scalar=True),
                               symbols.arith_operator('*'), t[2])
Exemplo n.º 16
0
 def p_CollectFunction1(self, t):
     'CollectFunction : AttributeValue'
     t[0] = symbols.attributeValue(t[1])