-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for file-level function declarations (#858)
- Loading branch information
Showing
7 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
silent: process.env.SILENT ? true : false, | ||
skipFiles: [], | ||
istanbulReporter: ['json-summary', 'text'] | ||
} |
6 changes: 6 additions & 0 deletions
6
test/sources/projects/file-level-functions/contracts/FunctionA.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
function functionA(bool x) returns (bool) { | ||
bool a = false; | ||
if (a || x) return x; | ||
} |
6 changes: 6 additions & 0 deletions
6
test/sources/projects/file-level-functions/contracts/FunctionB.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
function functionB(bool x) returns (bool) { | ||
bool a = false; | ||
if (a || x) return x; | ||
} |
19 changes: 19 additions & 0 deletions
19
test/sources/projects/file-level-functions/contracts/UsesFunctions.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import "./FunctionA.sol"; | ||
import "./FunctionB.sol"; | ||
|
||
contract UsesFunctions { | ||
bool a; | ||
|
||
constructor() public {} | ||
|
||
function useLocalFunction(bool x) public { | ||
a = x; | ||
} | ||
|
||
function useImportedFunctions(bool x) public { | ||
a = functionA(x); | ||
a = functionB(x); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
test/sources/projects/file-level-functions/hardhat.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require("@nomiclabs/hardhat-truffle5"); | ||
require(__dirname + "/../plugins/nomiclabs.plugin"); | ||
|
||
module.exports = { | ||
solidity: { | ||
version: "0.8.17", | ||
settings: { | ||
optimizer: { | ||
enabled: true | ||
}, | ||
viaIR: process.env.VIA_IR === "true" | ||
} | ||
}, | ||
logger: process.env.SILENT ? { log: () => {} } : console, | ||
}; |
14 changes: 14 additions & 0 deletions
14
test/sources/projects/file-level-functions/test/usesFunctions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const UsesFunctions = artifacts.require("UsesFunctions"); | ||
|
||
contract("contracts", function(accounts) { | ||
let instance; | ||
|
||
before(async () => { | ||
instance = await UsesFunctions.new(); | ||
}); | ||
|
||
it('when false', async function(){ | ||
await instance.useLocalFunction(false); | ||
await instance.useImportedFunctions(false); | ||
}); | ||
}); |