mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add syntax and semantic tests for underscore
This commit is contained in:
parent
7f1f192f8d
commit
b0864a4af9
20
test/libsolidity/semanticTests/underscore/as_function.sol
Normal file
20
test/libsolidity/semanticTests/underscore/as_function.sol
Normal file
@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function _() public pure returns (uint) {
|
||||
return 88;
|
||||
}
|
||||
|
||||
function g() public pure returns (uint){
|
||||
return _();
|
||||
}
|
||||
|
||||
function h() public pure returns (uint) {
|
||||
_;
|
||||
return 33;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// _() -> 88
|
||||
// g() -> 88
|
||||
// h() -> 33
|
16
test/libsolidity/semanticTests/underscore/in_function.sol
Normal file
16
test/libsolidity/semanticTests/underscore/in_function.sol
Normal file
@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
function f() public pure returns (uint) {
|
||||
uint _;
|
||||
return _;
|
||||
}
|
||||
|
||||
function g() public pure returns (uint) {
|
||||
uint _ = 1;
|
||||
return _;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0
|
||||
// g() -> 1
|
23
test/libsolidity/semanticTests/underscore/in_modifier.sol
Normal file
23
test/libsolidity/semanticTests/underscore/in_modifier.sol
Normal file
@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
modifier m() {
|
||||
_;
|
||||
}
|
||||
|
||||
modifier n() {
|
||||
string memory _ = "failed";
|
||||
_;
|
||||
revert(_);
|
||||
}
|
||||
|
||||
function f() m() public returns (uint) {
|
||||
return 88;
|
||||
}
|
||||
|
||||
function g() n() public returns (uint) {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// f() -> 88
|
||||
// g() -> FAILURE, hex"08c379a0", 0x20, 6, "failed"
|
12
test/libsolidity/syntaxTests/underscore/as_function.sol
Normal file
12
test/libsolidity/syntaxTests/underscore/as_function.sol
Normal file
@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function _() public pure {
|
||||
}
|
||||
|
||||
function g() public pure {
|
||||
_();
|
||||
}
|
||||
|
||||
function h() public pure {
|
||||
_;
|
||||
}
|
||||
}
|
17
test/libsolidity/syntaxTests/underscore/in_function.sol
Normal file
17
test/libsolidity/syntaxTests/underscore/in_function.sol
Normal file
@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f() public pure returns (uint) {
|
||||
uint _;
|
||||
return _;
|
||||
}
|
||||
|
||||
function g() public pure returns (uint) {
|
||||
uint _ = 1;
|
||||
return _;
|
||||
}
|
||||
|
||||
function h() public pure {
|
||||
_;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 7576: (230-231): Undeclared identifier.
|
18
test/libsolidity/syntaxTests/underscore/in_modifier.sol
Normal file
18
test/libsolidity/syntaxTests/underscore/in_modifier.sol
Normal file
@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
modifier m() {
|
||||
_;
|
||||
}
|
||||
|
||||
modifier n() {
|
||||
string memory _ = "";
|
||||
_;
|
||||
revert(_);
|
||||
}
|
||||
|
||||
function f() m() public {
|
||||
}
|
||||
|
||||
function g() n() public {
|
||||
}
|
||||
}
|
||||
// ----
|
Loading…
Reference in New Issue
Block a user