-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from cgewecke/draft-tests
Draft test suite
- Loading branch information
Showing
43 changed files
with
1,298 additions
and
50 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,39 @@ | ||
var solc = require('solc'); | ||
var getInstrumentedVersion = require('./../instrumentSolidity.js'); | ||
var util = require('./util/util.js'); | ||
|
||
/** | ||
* NB: passing '1' to solc as an option activates the optimiser | ||
* NB: solc will throw if there is a compilation error, causing the test to fail | ||
* and passing the error to mocha. | ||
*/ | ||
describe('function declarations', function(){ | ||
|
||
it('should compile after instrumenting an ordinary function declaration', function(){ | ||
var contract = util.getCode('function/function.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting an abstract function declaration', function(){ | ||
var contract = util.getCode('function/abstract.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting a function declaration with an empty body', function(){ | ||
var contract = util.getCode('function/empty-body.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting lots of declarations in row', function(){ | ||
var contract = util.getCode('function/multiple.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
}) |
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,44 @@ | ||
var solc = require('solc'); | ||
var getInstrumentedVersion = require('./../instrumentSolidity.js'); | ||
var util = require('./util/util.js') | ||
|
||
/** | ||
* NB: passing '1' to solc as an option activates the optimiser | ||
*/ | ||
describe('if, else, and else if statements', function(){ | ||
|
||
it('should compile after instrumenting else statements with brackets',function(){ | ||
var contract = util.getCode('if/else-with-brackets.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting else statements without brackets',function(){ | ||
var contract = util.getCode('if/else-without-brackets.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting if statements with no brackets',function(){ | ||
var contract = util.getCode('if/if-no-brackets.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting if statements with brackets',function(){ | ||
var contract = util.getCode('if/if-with-brackets.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting nested if statements with missing else statements',function(){ | ||
var contract = util.getCode('if/nested-if-missing-else.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
var solc = require('solc'); | ||
var getInstrumentedVersion = require('./../instrumentSolidity.js'); | ||
var util = require('./util/util.js'); | ||
|
||
describe('return statements', function(){ | ||
|
||
it('should compile after instrumenting function that returns true',function(){ | ||
var contract = util.getCode('return/return.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
|
||
it('should compile after instrumenting function that returns without specifying val (null)',function(){ | ||
var contract = util.getCode('return/return-null.sol'); | ||
var info = getInstrumentedVersion(contract, "test.sol", true); | ||
var output = solc.compile(info.contract, 1); | ||
util.report(output.errors); | ||
}) | ||
}) |
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 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function abstractFn(uint x); | ||
} |
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 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function emptyBody(uint x){} | ||
} |
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,7 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(bytes32 x) { | ||
x; | ||
} | ||
} |
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 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function f1(bytes32 x) { | ||
x = 1; | ||
} | ||
|
||
function f2(uint x){ x = 2; } | ||
|
||
address a; | ||
|
||
function f3(uint y){ | ||
y = 1; | ||
} | ||
} |
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,11 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) { | ||
if (x == 1) { | ||
throw; | ||
} else { | ||
x = 5; | ||
} | ||
} | ||
} |
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,10 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) { | ||
if (x == 1) { | ||
throw; | ||
} else | ||
x = 5; | ||
} | ||
} |
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,7 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) { | ||
if (x == 1) throw; | ||
} | ||
} |
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,7 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) { | ||
if (x == 1) { throw; } | ||
} | ||
} |
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,11 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x,uint y, uint z) { | ||
if (x==y){ | ||
} else if (x==2){ | ||
if (y==z){ | ||
} | ||
} | ||
} | ||
} |
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,7 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) returns (bool) { | ||
return; | ||
} | ||
} |
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,7 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) returns (bool) { | ||
return true; | ||
} | ||
} |
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,22 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
|
||
function multiline( | ||
uint a, | ||
uint b, | ||
uint c, | ||
bytes32 d) | ||
{ | ||
var x = a; | ||
} | ||
|
||
function Test(){ | ||
multiline( | ||
1, | ||
2, | ||
3, | ||
sha3('hello') | ||
); | ||
} | ||
} |
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,11 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(bytes32 x) { | ||
x; | ||
} | ||
|
||
function b (){ | ||
a(sha3(0)); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/sources/statements/if-consequent-no-brackets-multiline.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,8 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) { | ||
if (x == 1) | ||
throw; | ||
} | ||
} |
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,8 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) { | ||
sha3(x); | ||
sha3(0); | ||
} | ||
} |
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,7 @@ | ||
pragma solidity ^0.4.3; | ||
|
||
contract Test { | ||
function a(uint x) { | ||
sha3(x); | ||
} | ||
} |
Oops, something went wrong.