Ejemplo n.º 1
0
    def test_should_throw_with_contextual_error_message_wrong_args(self):
        with util.throws_with_message("Error on ListOfNumbers: expected List but was NoneType"):
            self.ListOfNumbers([])

        with util.throws_with_message("Error on ListOfNumbers[0]: expected Int or Float but was str"):
            self.ListOfNumbers("a")

        with util.throws_with_message("Error on ListOfNumbers[1]: expected Int or Float but was list"):
            self.ListOfNumbers([1, ["root"]])
Ejemplo n.º 2
0
    def test_list_type_combinator_then(self):
        with self.assertRaises(TypeError):
            t.list()

        with util.throws_with_message(
            "Error on List(Struct{x: Number, y: Number})[0]: expected Struct{x: Number, y: Number} but was int",
            "Error on List(Struct{y: Number, x: Number})[0]: expected Struct{y: Number, x: Number} but was int",
        ):
            t.list(self.Point)([1])