Right-aligns hex numbers and introduces alignment built-ins.

This commit is contained in:
Erik Kundt
2019-03-06 18:24:13 +01:00
parent eb5bde95b3
commit a40fbf0fc4
8 changed files with 359 additions and 112 deletions
+11 -9
View File
@@ -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)