diff --git a/test/libsolidity/semanticTests/literals/fractional_denominations.sol b/test/libsolidity/semanticTests/literals/fractional_denominations.sol new file mode 100644 index 000000000..6bc448f09 --- /dev/null +++ b/test/libsolidity/semanticTests/literals/fractional_denominations.sol @@ -0,0 +1,15 @@ +contract C { + uint public g = 1.5 gwei; + uint public e = 1.5 ether; + uint public m = 1.5 minutes; + uint public h = 1.5 hours; + uint public d = 1.5 days; + uint public w = 1.5 weeks; +} +// ---- +// g() -> 1500000000 +// e() -> 1500000000000000000 +// m() -> 90 +// h() -> 5400 +// d() -> 129600 +// w() -> 907200 diff --git a/test/libsolidity/syntaxTests/denominations/invalid_denomination_address.sol b/test/libsolidity/syntaxTests/denominations/invalid_denomination_address.sol new file mode 100644 index 000000000..8eec22dee --- /dev/null +++ b/test/libsolidity/syntaxTests/denominations/invalid_denomination_address.sol @@ -0,0 +1,5 @@ +contract C { + address a = 0x11111122222333334444455555666667777788888 wei; +} +// ---- +// TypeError 5145: (26-73): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead. diff --git a/test/libsolidity/syntaxTests/denominations/invalid_denomination_on_bool.sol b/test/libsolidity/syntaxTests/denominations/invalid_denomination_on_bool.sol new file mode 100644 index 000000000..58d7d205e --- /dev/null +++ b/test/libsolidity/syntaxTests/denominations/invalid_denomination_on_bool.sol @@ -0,0 +1,5 @@ +contract C { + bool constant x = true ether; +} +// ---- +// ParserError 2314: (37-42): Expected ';' but got 'ether' diff --git a/test/libsolidity/syntaxTests/denominations/invalid_denomination_on_string.sol b/test/libsolidity/syntaxTests/denominations/invalid_denomination_on_string.sol new file mode 100644 index 000000000..9d27c5d3d --- /dev/null +++ b/test/libsolidity/syntaxTests/denominations/invalid_denomination_on_string.sol @@ -0,0 +1,5 @@ +contract C { + string s = "abc" ether; +} +// ---- +// ParserError 2314: (31-36): Expected ';' but got 'ether'