mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Right-aligns hex numbers and introduces alignment built-ins.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
function f() public returns (uint) {
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
function g(uint x, uint y) public returns (uint) {
|
||||
return x - y;
|
||||
@@ -8,18 +8,20 @@ contract C {
|
||||
function h() public payable returns (uint) {
|
||||
return f();
|
||||
}
|
||||
function x(bytes32 b) public returns (bytes32) {
|
||||
function i(bytes32 b) public returns (bytes32) {
|
||||
return b;
|
||||
}
|
||||
function t(bool b) public returns (bool) {
|
||||
function j(bool b) public returns (bool) {
|
||||
return !b;
|
||||
}
|
||||
function k(bytes32 b) public returns (bytes32) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 1
|
||||
// f() -> 2
|
||||
// g(uint256,uint256): 1, -2 -> 3
|
||||
// h(), 1 ether -> 1
|
||||
// j() -> FAILURE
|
||||
// i() # Does not exist. # -> FAILURE # Reverts. #
|
||||
// x(bytes32): 0x31 -> 0x31
|
||||
// t(bool): true -> false
|
||||
// h(), 1 ether -> 2
|
||||
// i() -> FAILURE
|
||||
// j(bool): true -> false
|
||||
// k(bytes32): 0x31 -> 0x31
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
contract C {
|
||||
uint256 public stateDecimal = 0x20;
|
||||
}
|
||||
|
||||
contract D {
|
||||
bool public stateBool = true;
|
||||
uint256 public stateDecimal = 42;
|
||||
bytes32 public stateBytes = "\x42\x00\xef";
|
||||
|
||||
function internalStateDecimal() public returns (uint256) {
|
||||
return (new C()).stateDecimal();
|
||||
}
|
||||
|
||||
function update(bool _bool, uint256 _decimal, bytes32 _bytes) public returns (bool, uint256, bytes32) {
|
||||
stateBool = _bool;
|
||||
stateDecimal = _decimal;
|
||||
stateBytes = _bytes;
|
||||
return (stateBool, stateDecimal, stateBytes);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// stateBool() -> true
|
||||
// stateBool() -> right(true)
|
||||
// stateDecimal() -> 42
|
||||
// stateDecimal() -> right(42)
|
||||
// stateBytes() -> left(0x4200ef)
|
||||
// internalStateDecimal() -> 0x20
|
||||
// update(bool,uint256,bytes32): false, -23, left(0x2300ef) -> false, -23, left(0x2300ef)
|
||||
Reference in New Issue
Block a user