lesserthan uint done

pull/5370/head
aniket-engg 5 years ago committed by Aniket
parent e3d29c81ee
commit 0b06570d33
  1. 4
      libs/remix-tests/sol/tests.sol.ts
  2. 13
      libs/remix-tests/tests/examples_0/assert_lesserThan_test.sol
  3. 29
      libs/remix-tests/tests/testRunner.spec.ts

@ -134,9 +134,9 @@ library Assert {
emit AssertionEvent(result, message);
}
/*----------------- Lesser than --------------------*/
function lesserThan(uint a, uint b, string memory message) public returns (bool result) {
function lesserThan(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a < b);
emit AssertionEvent(result, message);
emit AssertionEventUint(result, message, a, b);
}
function lesserThan(int a, int b, string memory message) public returns (bool result) {

@ -0,0 +1,13 @@
import "remix_tests.sol"; // this import is automatically injected by Remix.
contract AssertLesserThanTest {
function lesserThanUintPassTest() public {
Assert.lesserThan(uint(2), uint(5), "lesserThanUintPassTest passes");
}
function lesserThanUintFailTest() public {
Assert.lesserThan(uint(4), uint(2), "lesserThanUintFailTest fails");
}
}

@ -218,6 +218,35 @@ describe('testRunner', () => {
})
})
describe('assert library LESSERTHAN method tests', () => {
const filename: string = __dirname + '/examples_0/assert_lesserThan_test.sol'
beforeAll((done) => {
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => {
runTest('AssertLesserThanTest', contracts.AssertLesserThanTest, compilationData[filename]['AssertLesserThanTest'], asts[filename], { accounts }, testCallback, resultsCallback(done))
})
})
afterAll(() => { tests = [] })
it('should have 1 passing test', () => {
assert.equal(results.passingNum, 1)
})
it('should have 1 failing test', () => {
assert.equal(results.failureNum, 1)
})
it('should return', () => {
deepEqualExcluding(tests, [
{ type: 'accountList', value: accounts },
{ type: 'contract', value: 'AssertLesserThanTest', filename: __dirname + '/examples_0/assert_lesserThan_test.sol' },
{ type: 'testPass', value: 'Lesser than uint pass test', context: 'AssertLesserThanTest' },
{ type: 'testFailure', value: 'Lesser than uint fail test', errMsg: 'lesserThanUintFailTest fails', context: 'AssertLesserThanTest', expected: '2', returned: '4'}
], ['time'])
})
})
describe('test with beforeAll', () => {
const filename: string = __dirname + '/examples_1/simple_storage_test.sol'

Loading…
Cancel
Save