test<E> method

void test<E>(
  1. String testName,
  2. E ax(),
  3. E? expected
)

the most basic test function possible LOL, im sorry, not gonna use a testing framework for this, not necessary imo (yuh)

Implementation

void test<E>(String testName, E Function() ax, E? expected) {
  E res = ax();
  logger.info(// oh YEA WE LOVE INTERPOLATION WITHIN INTERPOLATION
      "${expected == null || res == expected ? "[OK] ${kShowSuccessfulTestResults ? "'$res'" : ""}" : "[XX] got '$res', expected '$expected' "} - $testName ");
  if (res != expected && expected != null && kFailedTestsPanic) {
    // panic due to failed test
    logger.info("Program exited due to failed test: $testName");
    exit(-1);
  }
}