-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proptest based differential contract testing
- Loading branch information
Showing
11 changed files
with
423 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,43 @@ | ||
contract Foo: | ||
|
||
pub fn add(val1: i8, val2: i8) -> i8: | ||
return val1 + val2 | ||
|
||
pub fn subtract(val1: i8, val2: i8) -> i8: | ||
return val1 - val2 | ||
|
||
pub fn multiply(val1: i8, val2: i8) -> i8: | ||
return val1 * val2 | ||
|
||
pub fn divide(val1: i8, val2: i8) -> i8: | ||
return val1 / val2 | ||
|
||
pub fn pow(val1: i8, val2: u8) -> i8: | ||
return val1 ** val2 | ||
|
||
pub fn modulo(val1: i8, val2: i8) -> i8: | ||
return val1 % val2 | ||
|
||
pub fn rightshift(val1: i8, val2: u8) -> i8: | ||
return val1 >> val2 | ||
|
||
pub fn leftshift(val1: i8, val2: u8) -> i8: | ||
return val1 << val2 | ||
|
||
pub fn invert(val1: i8) -> i8: | ||
return ~val1 | ||
|
||
pub fn cast1(val1: i8) -> u8: | ||
return u8(val1) | ||
|
||
pub fn cast2(val1: i8) -> u16: | ||
return u16(u8(val1)) | ||
|
||
pub fn cast3(val1: i8) -> u16: | ||
return u16(i16(val1)) | ||
|
||
pub fn order_of_operation(val1: i8, val2: i8, val3: u8) -> i8: | ||
return val1 - val2 * (val1 + val2 / 4 * val1 - val2**val3) + val1 | ||
|
||
pub fn negate(val1: i8) -> i8: | ||
return -val1 |
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,58 @@ | ||
contract Foo { | ||
|
||
function add(int8 val1, int8 val2) public pure returns (int8){ | ||
return val1 + val2; | ||
} | ||
|
||
function subtract(int8 val1, int8 val2) public pure returns (int8){ | ||
return val1 - val2; | ||
} | ||
|
||
function multiply(int8 val1, int8 val2) public pure returns (int8){ | ||
return val1 * val2; | ||
} | ||
|
||
function divide(int8 val1, int8 val2) public pure returns (int8){ | ||
return val1 / val2; | ||
} | ||
|
||
function pow(int8 val1, uint8 val2) public pure returns (int8) { | ||
return int8(uint8(val1) ** val2); | ||
} | ||
|
||
function modulo(int8 val1, int8 val2) public pure returns (int8){ | ||
return val1 % val2; | ||
} | ||
|
||
function leftshift(int8 val1, uint8 val2) public pure returns (int8){ | ||
return val1 << val2; | ||
} | ||
|
||
function rightshift(int8 val1, uint8 val2) public pure returns (int8){ | ||
return val1 >> val2; | ||
} | ||
|
||
function invert(int8 val1) public pure returns (int8){ | ||
return ~val1; | ||
} | ||
|
||
function cast1(int8 val1) public pure returns (uint8){ | ||
return uint8(val1); | ||
} | ||
|
||
function cast2(int8 val1) public pure returns (uint16){ | ||
return uint16(uint8(val1)); | ||
} | ||
|
||
function cast3(int8 val1) public pure returns (uint16){ | ||
return uint16(int16(val1)); | ||
} | ||
|
||
function order_of_operation(int8 val1, int8 val2, uint8 val3) public pure returns (int8) { | ||
return val1 - val2 * (val1 + val2 / 4 * val1 - val2**val3) + val1; | ||
} | ||
|
||
function negate(int8 val1) public pure returns (int8){ | ||
return -val1; | ||
} | ||
} |
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,49 @@ | ||
contract Foo: | ||
|
||
pub fn add(val1: u8, val2: u8) -> u8: | ||
return val1 + val2 | ||
|
||
pub fn subtract(val1: u8, val2: u8) -> u8: | ||
return val1 - val2 | ||
|
||
pub fn multiply(val1: u8, val2: u8) -> u8: | ||
return val1 * val2 | ||
|
||
pub fn divide(val1: u8, val2: u8) -> u8: | ||
return val1 / val2 | ||
|
||
pub fn pow(val1: u8, val2: u8) -> u8: | ||
return val1 ** val2 | ||
|
||
pub fn modulo(val1: u8, val2: u8) -> u8: | ||
return val1 % val2 | ||
|
||
pub fn rightshift(val1: u8, val2: u8) -> u8: | ||
return val1 >> val2 | ||
|
||
pub fn leftshift(val1: u8, val2: u8) -> u8: | ||
return val1 << val2 | ||
|
||
pub fn invert(val1: u8) -> u8: | ||
return ~val1 | ||
|
||
pub fn bit_and(val1: u8, val2: u8) -> u8: | ||
return val1 & val2 | ||
|
||
pub fn bit_or(val1: u8, val2: u8) -> u8: | ||
return val1 | val2 | ||
|
||
pub fn bit_xor(val1: u8, val2: u8) -> u8: | ||
return val1 ^ val2 | ||
|
||
pub fn cast1(val1: u8) -> i8: | ||
return i8(val1) | ||
|
||
pub fn cast2(val1: u8) -> i16: | ||
return i16(i8(val1)) | ||
|
||
pub fn cast3(val1: u8) -> i16: | ||
return i16(u16(val1)) | ||
|
||
pub fn order_of_operation(val1: u8, val2: u8) -> u8: | ||
return val1 - val2 * (val1 + val2 / 4 * val1 - val2**val1) + val1 |
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,66 @@ | ||
contract Foo { | ||
|
||
function add(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 + val2; | ||
} | ||
|
||
function subtract(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 - val2; | ||
} | ||
|
||
function multiply(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 * val2; | ||
} | ||
|
||
function divide(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 / val2; | ||
} | ||
|
||
function pow(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 ** val2; | ||
} | ||
|
||
function modulo(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 % val2; | ||
} | ||
|
||
function leftshift(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 << val2; | ||
} | ||
|
||
function rightshift(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 >> val2; | ||
} | ||
|
||
function invert(uint8 val1) public pure returns (uint8){ | ||
return ~val1; | ||
} | ||
|
||
function bit_and(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 & val2; | ||
} | ||
|
||
function bit_or(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 | val2; | ||
} | ||
|
||
function bit_xor(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 ^ val2; | ||
} | ||
|
||
function cast1(uint8 val1) public pure returns (int8){ | ||
return int8(val1); | ||
} | ||
|
||
function cast2(uint8 val1) public pure returns (int16){ | ||
return int16(int8(val1)); | ||
} | ||
|
||
function cast3(uint8 val1) public pure returns (int16){ | ||
return int16(uint16(val1)); | ||
} | ||
|
||
function order_of_operation(uint8 val1, uint8 val2) public pure returns (uint8){ | ||
return val1 - val2 * (val1 + val2 / 4 * val1 - val2**val1) + val1; | ||
} | ||
} |
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,8 @@ | ||
# Seeds for failure cases proptest has generated in the past. It is | ||
# automatically read and these particular cases re-run before any | ||
# novel cases are generated. | ||
# | ||
# It is recommended to check this file in to source control so that | ||
# everyone who runs the test benefits from these saved cases. | ||
cc 71897591107cbd3f0d248e1ecbece406820f797206e4f43ea02d53a1ebc5ad92 # shrinks to val = 0, val2 = 0, val3 = 128, val4 = 0 | ||
cc 6f70182204124ed76e435a25baf2365d922abac6cb4647dcb86cdd4b339fab31 # shrinks to val = -128, val2 = 0, val3 = 0, val4 = 0 |
Oops, something went wrong.