From 0b06570d332e26d13c7fc4c5d0622fac5646c416 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 14 Aug 2020 20:37:52 +0530 Subject: [PATCH] lesserthan uint done --- libs/remix-tests/sol/tests.sol.ts | 4 +-- .../examples_0/assert_lesserThan_test.sol | 13 +++++++++ libs/remix-tests/tests/testRunner.spec.ts | 29 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 libs/remix-tests/tests/examples_0/assert_lesserThan_test.sol diff --git a/libs/remix-tests/sol/tests.sol.ts b/libs/remix-tests/sol/tests.sol.ts index 3739107bf8..a859e370f1 100644 --- a/libs/remix-tests/sol/tests.sol.ts +++ b/libs/remix-tests/sol/tests.sol.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) { diff --git a/libs/remix-tests/tests/examples_0/assert_lesserThan_test.sol b/libs/remix-tests/tests/examples_0/assert_lesserThan_test.sol new file mode 100644 index 0000000000..7ac7955dd0 --- /dev/null +++ b/libs/remix-tests/tests/examples_0/assert_lesserThan_test.sol @@ -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"); + } +} \ No newline at end of file diff --git a/libs/remix-tests/tests/testRunner.spec.ts b/libs/remix-tests/tests/testRunner.spec.ts index 3efc59bccb..00eabc5c93 100644 --- a/libs/remix-tests/tests/testRunner.spec.ts +++ b/libs/remix-tests/tests/testRunner.spec.ts @@ -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'