mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixes source extraction from docs.
This commit is contained in:
parent
abf1aa74cf
commit
ec53899a10
@ -456,7 +456,7 @@ New version:
|
|||||||
// Throw is now disallowed.
|
// Throw is now disallowed.
|
||||||
require(x > 100);
|
require(x > 100);
|
||||||
int y = -3 >> 1;
|
int y = -3 >> 1;
|
||||||
// y == -2 (correct)
|
require(y == -2);
|
||||||
do {
|
do {
|
||||||
x += 1;
|
x += 1;
|
||||||
if (x > 10) continue;
|
if (x > 10) continue;
|
||||||
@ -473,7 +473,7 @@ New version:
|
|||||||
|
|
||||||
using address_make_payable for address;
|
using address_make_payable for address;
|
||||||
// Data location for 'arr' must be specified
|
// Data location for 'arr' must be specified
|
||||||
function g(uint[] memory arr, bytes8 x, OtherContract otherContract, address unknownContract) public payable {
|
function g(uint[] memory /* arr */, bytes8 x, OtherContract otherContract, address unknownContract) public payable {
|
||||||
// 'otherContract.transfer' is not provided.
|
// 'otherContract.transfer' is not provided.
|
||||||
// Since the code of 'OtherContract' is known and has the fallback
|
// Since the code of 'OtherContract' is known and has the fallback
|
||||||
// function, address(otherContract) has type 'address payable'.
|
// function, address(otherContract) has type 'address payable'.
|
||||||
|
@ -158,13 +158,13 @@ to write a function, for example:
|
|||||||
|
|
||||||
// Getter function generated by the compiler
|
// Getter function generated by the compiler
|
||||||
/*
|
/*
|
||||||
function myArray(uint i) returns (uint) {
|
function myArray(uint i) public view returns (uint) {
|
||||||
return myArray[i];
|
return myArray[i];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// function that returns entire array
|
// function that returns entire array
|
||||||
function getArray() returns (uint[] memory) {
|
function getArray() public view returns (uint[] memory) {
|
||||||
return myArray;
|
return myArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ types.
|
|||||||
|
|
||||||
pragma solidity >=0.5.0;
|
pragma solidity >=0.5.0;
|
||||||
pragma experimental SMTChecker;
|
pragma experimental SMTChecker;
|
||||||
// This will not compile
|
// This will report a warning
|
||||||
contract Aliasing
|
contract Aliasing
|
||||||
{
|
{
|
||||||
uint[] array;
|
uint[] array;
|
||||||
|
@ -39,6 +39,7 @@ def extract_test_cases(path):
|
|||||||
# and abort a line not indented properly.
|
# and abort a line not indented properly.
|
||||||
def extract_docs_cases(path):
|
def extract_docs_cases(path):
|
||||||
inside = False
|
inside = False
|
||||||
|
extractedLines = []
|
||||||
tests = []
|
tests = []
|
||||||
|
|
||||||
# Collect all snippets of indented blocks
|
# Collect all snippets of indented blocks
|
||||||
@ -46,15 +47,23 @@ def extract_docs_cases(path):
|
|||||||
if l != '':
|
if l != '':
|
||||||
if not inside and l.startswith(' '):
|
if not inside and l.startswith(' '):
|
||||||
# start new test
|
# start new test
|
||||||
tests += ['']
|
extractedLines += ['']
|
||||||
inside = l.startswith(' ')
|
inside = l.startswith(' ')
|
||||||
if inside:
|
if inside:
|
||||||
tests[-1] += l + '\n'
|
extractedLines[-1] += l + '\n'
|
||||||
# Filter all tests that do not contain Solidity
|
|
||||||
return [
|
codeStart = "(pragma solidity|contract.*{|library.*{|interface.*{)"
|
||||||
test for test in tests
|
|
||||||
if re.search(r'^ [ ]*(pragma solidity|contract |library |interface )', test, re.MULTILINE)
|
# Filter all tests that do not contain Solidity or are intended incorrectly.
|
||||||
]
|
for lines in extractedLines:
|
||||||
|
if re.search(r'^\s{0,3}' + codeStart, lines, re.MULTILINE):
|
||||||
|
print("Intendation error in " + path + ":")
|
||||||
|
print(lines)
|
||||||
|
exit(1)
|
||||||
|
if re.search(r'^\s{4}' + codeStart, lines, re.MULTILINE):
|
||||||
|
tests.append(lines)
|
||||||
|
|
||||||
|
return tests
|
||||||
|
|
||||||
def write_cases(f, tests):
|
def write_cases(f, tests):
|
||||||
cleaned_filename = f.replace(".","_").replace("-","_").replace(" ","_").lower()
|
cleaned_filename = f.replace(".","_").replace("-","_").replace(" ","_").lower()
|
||||||
|
Loading…
Reference in New Issue
Block a user