Hi,
I am trying to compile my contracts on Remix IDE. I am getting error in the test contract:
STFB5.sol
pragma solidity ^0.5.3;
contract STFB5 {
function transferToFallback(address payable _to) public payable {
_to.transfer(msg.value);
}
function() external payable{
}
function getBalance() public view returns (uint) {
return address(this).balance;
}
constructor () payable public{
}
}
F5.sol
pragma solidity ^0.5.3;
contract F5 {
function() external payable {
// send / transfer (forwards 2300 gas to this fallback function)
// call (forwards all of the gas)
}
constructor () payable public {}
function getBalance() public view returns (uint) {
return address(this).balance;
}
}
STFB5_test.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
// This import is automatically injected by Remix
import "remix_tests.sol";
// This import is required to use custom transaction context
// Although it may fail compilation in 'Solidity Compiler' plugin
// But it will work fine in 'Solidity Unit Testing' plugin
import "remix_accounts.sol";
import "./STFB5.sol";
import "./F5.sol";
// File name has to end with '_test.sol', this file can contain more than one testSuite contracts
contract testSuite {
/// 'beforeAll' runs before all other tests
/// More special functions are: 'beforeEach', 'beforeAll', 'afterEach' & 'afterAll'
F5 obj1;
STFB5 obj2;
function beforeAll() public payable {
uint a = 100;
obj1 = new F5{value: a}();
obj2 = new STFB5{value: a}();
}
function initialValueofObj1ShouldBe100() public returns (bool) {
return Assert.equal(obj1.getBalance(), 100, "initial value is not correct");
}
function initialValueofObj2ShouldBe100() public returns (bool) {
return Assert.equal(obj2.getBalance(), 100, "initial value is not correct");
}
}
But I am getting the error:
contracts/STFB5_test.sol:28:21: ParserError: Expected ';' but got '{'
obj1 = new F5{value: a}();
^
Somebody please guide me.
Zulfi.