UnitTest assertEqual doesn't work for bigint

I thought I’d try the UnitTest module. As ever this means testing various implementations of the factorial function. However on compilation:

test/factorial_test.chpl:36: error: unresolved call 'assertEqual(bigint, bigint)'
$CHPL_HOME/modules/packages/UnitTest.chpl:516: note: this candidate did not match: Test.assertEqual(first, second)
test/factorial_test.chpl:36: note: because call is not written as a method call
$CHPL_HOME/modules/packages/UnitTest.chpl:516: note: but candidate function is a method

anyone any ideas as to how to “fix” this?

Hi Russel,

Thanks for giving it a try. When writing these tests, the assert functions are methods on the test object passed to the test routine.

e.g.

  proc test3(test: borrowed Test) throws {
    test.assertEqual(2, 3.0);
  }
1 Like

OK. It would have helped if I had read the examples in more detail. :slight_smile:

I think this issue is now closed, but another has arisen. New topic though.

@Russel - here’s a full working example for you:

// RusselsTest.chpl
use BigInteger;
use UnitTest;

proc testFoo(test: borrowed Test) throws {
  test.assertEqual(new bigint(2), new bigint(3));
}

UnitTest.main();
> mason test RusselsTest.chpl

======================================================================
FAIL RusselsTest.chpl: testFoo()
----------------------------------------------------------------------
AssertionError: assert failed - '2' != '3'

----------------------------------------------------------------------
Ran 1 test in 8.6196 seconds

FAILED (failures = 1 )