diff --git a/libs/remix-tests/sol/tests.sol.ts b/libs/remix-tests/sol/tests.sol.ts index a5158481b2..890ae9b460 100644 --- a/libs/remix-tests/sol/tests.sol.ts +++ b/libs/remix-tests/sol/tests.sol.ts @@ -43,6 +43,13 @@ library Assert { bytes32 expected ); + event AssertionEventString( + bool passed, + string message, + string returned, + string expected + ); + function ok(bool a, string memory message) public returns (bool result) { result = a; emit AssertionEvent(result, message); @@ -87,7 +94,7 @@ library Assert { function equal(string memory a, string memory b, string memory message) public returns (bool result) { result = (keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b))); - emit AssertionEvent(result, message); + emit AssertionEventString(result, message, a, b); } function notEqual(uint256 a, uint256 b, string memory message) public returns (bool result) { @@ -129,7 +136,7 @@ library Assert { function notEqual(string memory a, string memory b, string memory message) public returns (bool result) { result = (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b))); - emit AssertionEvent(result, message); + emit AssertionEventString(result, message, a, b); } /*----------------- Greater than --------------------*/ diff --git a/libs/remix-tests/src/assertionEvents.ts b/libs/remix-tests/src/assertionEvents.ts index 9b3deb70dc..6fdb1ce8d7 100644 --- a/libs/remix-tests/src/assertionEvents.ts +++ b/libs/remix-tests/src/assertionEvents.ts @@ -22,6 +22,10 @@ const assertionEvents = [ { name: 'AssertionEventBytes32', params: ['bool', 'string', 'bytes32', 'bytes32'] + }, + { + name: 'AssertionEventString', + params: ['bool', 'string', 'string', 'string'] } ] diff --git a/libs/remix-tests/tests/examples_0/assert_equal_test.sol b/libs/remix-tests/tests/examples_0/assert_equal_test.sol index 87589cae4c..79ebc33b78 100644 --- a/libs/remix-tests/tests/examples_0/assert_equal_test.sol +++ b/libs/remix-tests/tests/examples_0/assert_equal_test.sol @@ -45,4 +45,12 @@ contract AssertEqualTest { bytes32 r = 0x72656d6979000000000000000000000000000000000000000000000000000000; Assert.equal(r, e, "equalBytes32FailTest fails"); } + + function equalStringPassTest() public { + Assert.equal(string("remix"), string("remix"), "equalStringPassTest passes"); + } + + function equalStringFailTest() public { + Assert.equal(string("remix"), string("remix-tests"), "equalStringFailTest fails"); + } } \ No newline at end of file diff --git a/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol b/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol index d399d20ae3..f8f6a01fb6 100644 --- a/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol +++ b/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol @@ -45,4 +45,12 @@ contract AssertNotEqualTest { bytes32 r = 0x72656d6978000000000000000000000000000000000000000000000000000000; Assert.notEqual(r, e, "notEqualBytes32FailTest fails"); } + + function notEqualStringPassTest() public { + Assert.notEqual(string("remix"), string("remix-tests"), "notEqualStringPassTest passes"); + } + + function notEqualStringFailTest() public { + Assert.notEqual(string("remix"), string("remix"), "notEqualStringFailTest fails"); + } } diff --git a/libs/remix-tests/tests/testRunner.spec.ts b/libs/remix-tests/tests/testRunner.spec.ts index e27e9be835..c8ec2425d6 100644 --- a/libs/remix-tests/tests/testRunner.spec.ts +++ b/libs/remix-tests/tests/testRunner.spec.ts @@ -143,12 +143,12 @@ describe('testRunner', () => { afterAll(() => { tests = [] }) - it('should have 5 passing test', () => { - assert.equal(results.passingNum, 5) + it('should have 6 passing test', () => { + assert.equal(results.passingNum, 6) }) - it('should have 5 failing test', () => { - assert.equal(results.failureNum, 5) + it('should have 6 failing test', () => { + assert.equal(results.failureNum, 6) }) it('should return', () => { @@ -164,7 +164,9 @@ describe('testRunner', () => { { type: 'testPass', value: 'Equal address pass test', context: 'AssertEqualTest' }, { type: 'testFailure', value: 'Equal address fail test', errMsg: 'equalAddressFailTest fails', context: 'AssertEqualTest', expected: '0x1c6637567229159d1eFD45f95A6675e77727E013', returned: '0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9'}, { type: 'testPass', value: 'Equal bytes32 pass test', context: 'AssertEqualTest' }, - { type: 'testFailure', value: 'Equal bytes32 fail test', errMsg: 'equalBytes32FailTest fails', context: 'AssertEqualTest', expected: '0x72656d6978000000000000000000000000000000000000000000000000000000', returned: '0x72656d6979000000000000000000000000000000000000000000000000000000'} + { type: 'testFailure', value: 'Equal bytes32 fail test', errMsg: 'equalBytes32FailTest fails', context: 'AssertEqualTest', expected: '0x72656d6978000000000000000000000000000000000000000000000000000000', returned: '0x72656d6979000000000000000000000000000000000000000000000000000000'}, + { type: 'testPass', value: 'Equal string pass test', context: 'AssertEqualTest' }, + { type: 'testFailure', value: 'Equal string fail test', errMsg: 'equalStringFailTest fails', context: 'AssertEqualTest', expected: 'remix-tests', returned: 'remix'} ], ['time']) }) }) @@ -180,12 +182,12 @@ describe('testRunner', () => { afterAll(() => { tests = [] }) - it('should have 5 passing test', () => { - assert.equal(results.passingNum, 5) + it('should have 6 passing test', () => { + assert.equal(results.passingNum, 6) }) - it('should have 5 failing test', () => { - assert.equal(results.failureNum, 5) + it('should have 6 failing test', () => { + assert.equal(results.failureNum, 6) }) it('should return', () => { @@ -201,7 +203,9 @@ describe('testRunner', () => { { type: 'testPass', value: 'Not equal address pass test', context: 'AssertNotEqualTest' }, { type: 'testFailure', value: 'Not equal address fail test', errMsg: 'notEqualAddressFailTest fails', context: 'AssertNotEqualTest', expected: 0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9, returned: 0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9}, { type: 'testPass', value: 'Not equal bytes32 pass test', context: 'AssertNotEqualTest' }, - { type: 'testFailure', value: 'Not equal bytes32 fail test', errMsg: 'notEqualBytes32FailTest fails', context: 'AssertNotEqualTest', expected: '0x72656d6978000000000000000000000000000000000000000000000000000000', returned: '0x72656d6978000000000000000000000000000000000000000000000000000000'} + { type: 'testFailure', value: 'Not equal bytes32 fail test', errMsg: 'notEqualBytes32FailTest fails', context: 'AssertNotEqualTest', expected: '0x72656d6978000000000000000000000000000000000000000000000000000000', returned: '0x72656d6978000000000000000000000000000000000000000000000000000000'}, + { type: 'testPass', value: 'Not equal string pass test', context: 'AssertNotEqualTest' }, + { type: 'testFailure', value: 'Not equal string fail test', errMsg: 'notEqualStringFailTest fails', context: 'AssertNotEqualTest', expected: 'remix', returned: 'remix'}, ], ['time']) }) })