Exemple #1
0
    def test_monops(self):
        monop_node1 = AST.NegNode(AST.BoolNode(True))
        self.validate_node(self.exp_parser, "!true", monop_node1)

        monop_node2 = AST.NegNode(monop_node1)
        self.validate_node(self.exp_parser, "!!true", monop_node2)

        monop_node3 = AST.MinNode(AST.IntNode(int("30")))
        self.validate_node(self.exp_parser, "-30", monop_node3)

        monop_node4 = AST.PlusNode(AST.IntNode(int("40")))
        self.validate_node(self.exp_parser, "+40", monop_node4)
Exemple #2
0
    def test_computed_questions(self):
        def format_question(q, n, var_type, expr):
            return "\"{}\" {}: {} = ({})".format(q, n, var_type, expr)

        question = "Did you sell a house in 2010?"
        name = "hasSoldHouse"
        q_type = AST.BoolTypeNode()
        q_expr = "-var >= 600"
        node_expr = AST.GTENode(AST.MinNode(AST.VarNode("var")),
                                AST.IntNode(int("600")))

        q_str = format_question(question, name, "boolean", q_expr)
        test_node = AST.ComputedQuestionNode(question, name, q_type, node_expr)
        self.validate_node(self.q_parser, q_str, test_node)