Testing

Module

Implements various testing utils.

TestSuite

The class contains various assert methods.

Functions:

__init__

__init__(self: Self&, name: StringRef)

Constructs a new TestSuite with the specified name.

Args:

  • name (StringRef): The name of the test suite.

assertAlmostEqual

assertAlmostEqual[size: Int, type: DType](self: Self, lhs: SIMD[type, size], rhs: SIMD[type, size]) -> Bool

Asserts that the input values are equal up to a tolerance. If it is not then a message is printed.

Parameters:

  • size (Int): The width of the left- and right-hand-side SIMD vectors.
  • type (DType): The dtype of the left- and right-hand-side SIMD vectors.

Args:

  • lhs (SIMD[type, size]): The lhs of the equality.
  • rhs (SIMD[type, size]): The rhs of the equality.

Returns:

True if the assert succeeds and False otherwise.

assertEqual

assertEqual(self: Self, lhs: Int, rhs: Int) -> Bool

Asserts that the input values are equal. If it is not then a message is printed.

Args:

  • lhs (Int): The lhs of the equality.
  • rhs (Int): The rhs of the equality.

Returns:

True if the assert succeeds and False otherwise.

assertEqual(self: Self, lhs: String, rhs: String) -> Bool

Asserts that the input values are equal. If it is not then a message is printed.

Args:

  • lhs (String): The lhs of the equality.
  • rhs (String): The rhs of the equality.

Returns:

True if the assert succeeds and False otherwise.

assertEqual[size: Int, type: DType](self: Self, lhs: SIMD[type, size], rhs: SIMD[type, size]) -> Bool

Asserts that the input values are equal. If it is not then a message is printed.

Parameters:

  • size (Int): The width of the left- and right-hand-side SIMD vectors.
  • type (DType): The dtype of the left- and right-hand-side SIMD vectors.

Args:

  • lhs (SIMD[type, size]): The lhs of the equality.
  • rhs (SIMD[type, size]): The rhs of the equality.

Returns:

True if the assert succeeds and False otherwise.

assertFalse

assertFalse(self: Self, val: Bool, msg: StringRef) -> Bool

Asserts that the input value is False. If it is not then a message is printed which contains the input message.

Args:

  • val (Bool): The value to assert to be False.
  • msg (StringRef): The message to be printed if the assertion fails.

Returns:

True if the assert succeeds and False otherwise.

assertFalse(self: Self, val: Bool) -> Bool

Asserts that the input value is False. If it is not then a message is printed.

Args:

  • val (Bool): The value to assert to be False.

Returns:

True if the assert succeeds and False otherwise.

assertNotEqual

assertNotEqual(self: Self, lhs: Int, rhs: Int) -> Bool

Asserts that the input values are not equal. If it is not then a message is printed.

Args:

  • lhs (Int): The lhs of the inequality.
  • rhs (Int): The rhs of the inequality.

Returns:

True if the assert succeeds and False otherwise.

assertNotEqual(self: Self, lhs: String, rhs: String) -> Bool

Asserts that the input values are not equal. If it is not then a message is printed.

Args:

  • lhs (String): The lhs of the inequality.
  • rhs (String): The rhs of the inequality.

Returns:

True if the assert succeeds and False otherwise.

assertNotEqual[size: Int, type: DType](self: Self, lhs: SIMD[type, size], rhs: SIMD[type, size]) -> Bool

Asserts that the input values are not equal. If it is not then a message is printed.

Parameters:

  • size (Int): The width of the left- and right-hand-side SIMD vectors.
  • type (DType): The dtype of the left- and right-hand-side SIMD vectors.

Args:

  • lhs (SIMD[type, size]): The lhs of the inequality.
  • rhs (SIMD[type, size]): The rhs of the inequality.

Returns:

True if the assert succeeds and False otherwise.

assertTrue

assertTrue(self: Self, val: Bool, msg: StringRef) -> Bool

Asserts that the input value is True. If it is not then a message is printed which contains the input message.

Args:

  • val (Bool): The value to assert to be True.
  • msg (StringRef): The message to be printed if the assertion fails.

Returns:

True if the assert succeeds and False otherwise.

assertTrue(self: Self, val: Bool) -> Bool

Asserts that the input value is True. If it is not then a message is printed.

Args:

  • val (Bool): The value to assert to be True.

Returns:

True if the assert succeeds and False otherwise.