mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Moving enum test to semanticTests
This commit is contained in:
parent
73fcd9b5f0
commit
3f60223c41
@ -73,28 +73,6 @@ BOOST_AUTO_TEST_CASE(value_types)
|
||||
)
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(enums)
|
||||
{
|
||||
string sourceCode = R"(
|
||||
contract C {
|
||||
enum E { A, B }
|
||||
function f(E e) public pure returns (uint x) {
|
||||
assembly { x := e }
|
||||
}
|
||||
}
|
||||
)";
|
||||
bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2;
|
||||
BOTH_ENCODERS(
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("f(uint8)", 0), encodeArgs(u256(0)));
|
||||
ABI_CHECK(callContractFunction("f(uint8)", 1), encodeArgs(u256(1)));
|
||||
// The old decoder was not as strict about enums
|
||||
ABI_CHECK(callContractFunction("f(uint8)", 2), (newDecoder ? encodeArgs() : encodeArgs(2)));
|
||||
ABI_CHECK(callContractFunction("f(uint8)", u256(-1)), (newDecoder? encodeArgs() : encodeArgs(u256(0xff))));
|
||||
newDecoder = true;
|
||||
)
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cleanup)
|
||||
{
|
||||
string sourceCode = R"(
|
||||
|
13
test/libsolidity/semanticTests/abiEncoderV1/enums.sol
Normal file
13
test/libsolidity/semanticTests/abiEncoderV1/enums.sol
Normal file
@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
enum E { A, B }
|
||||
function f(E e) public pure returns (uint x) {
|
||||
assembly { x := e }
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(uint8): 0 -> 0
|
||||
// f(uint8): 1 -> 1
|
||||
// f(uint8): 2 -> 2
|
||||
// f(uint8): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xff
|
15
test/libsolidity/semanticTests/abiEncoderV2/enums.sol
Normal file
15
test/libsolidity/semanticTests/abiEncoderV2/enums.sol
Normal file
@ -0,0 +1,15 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
enum E { A, B }
|
||||
function f(E e) public pure returns (uint x) {
|
||||
assembly { x := e }
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint8): 0 -> 0
|
||||
// f(uint8): 1 -> 1
|
||||
// f(uint8): 2 -> FAILURE
|
||||
// f(uint8): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> FAILURE
|
Loading…
Reference in New Issue
Block a user