Ejemplo n.º 1
0
    def test_noconstraints(self):
        string = "shape [4, 4]"
        fname = to_file_in_tmp(string, self.test_noconstraints)

        # we expect this to pass
        ConstraintsToCnf._read_data(fname)

        cleanup(fname)
Ejemplo n.º 2
0
    def test_negativeindexshape(self):
        string = "shape [4, -4]"
        fname = to_file_in_tmp(string, self.test_negativeindexshape)

        with self.assertRaises(AssertionError):
            ConstraintsToCnf._read_data(fname)

        cleanup(fname)
Ejemplo n.º 3
0
    def test_noshape(self):
        string = "X1 >> X2"
        fname = to_file_in_tmp(string, self.test_noshape)

        with self.assertRaises(AssertionError):
            ConstraintsToCnf._read_data(fname)

        cleanup(fname)
Ejemplo n.º 4
0
    def test_badshape3(self):
        string = "shape [4; 4]"
        fname = to_file_in_tmp(string, self.test_badshape3)

        with self.assertRaises(AssertionError):
            ConstraintsToCnf._read_data(fname)

        cleanup(fname)
Ejemplo n.º 5
0
    def test_check_correct_result4(self):
        string = "# X1 >> X2\n"
        string += "shape [4, 4]\n"
        string += "# X1 >> X2\n"
        string += "# X1 >> X2\n"
        string += "# X1 >> X2\n"
        string += "X1 >> X2\n"
        string += "# X1 >> X2\n"
        string += "X1 >> X2\n"
        string += "# X1 >> X2\n"
        string += "X1 >> X2\n"
        string += "X1 >> X2\n"
        string += "# X1 >> X2\n"
        string += "X1 >> X2\n"
        string += "# X1 >> X2\n"
        string += "# X1 >> X2\n"
        fname = to_file_in_tmp(string, self.test_check_correct_result4)

        # we expect this line to pass
        shape, constr = ConstraintsToCnf._read_data(fname)
        assert shape == [4, 4]
        assert type(constr) == list and len(constr) == 5
        for c in constr:
            assert c == "X1 >> X2"

        cleanup(fname)