Add tests for implcit conversions from literals to fixed-point numbers.

This commit is contained in:
Yi Huang
2018-12-10 17:31:20 +01:00
committed by chriseth
parent 687382ae09
commit 81f703427e
5 changed files with 86 additions and 55 deletions
@@ -10,4 +10,5 @@ contract test {
}
}
// ----
// Warning: (20-707): Function state mutability can be restricted to pure
// TypeError: (153-250): Type rational_const 9208...(70 digits omitted)...7637 / 1000...(71 digits omitted)...0000 is not implicitly convertible to expected type ufixed256x77, but it can be explicitly converted.
// TypeError: (470-566): Type rational_const -933...(70 digits omitted)...0123 / 1000...(70 digits omitted)...0000 is not implicitly convertible to expected type fixed256x76, but it can be explicitly converted.
@@ -0,0 +1,15 @@
contract C {
function literalToUFixed() public pure {
ufixed8x2 a = 0.10;
ufixed8x2 b = 0.00;
ufixed8x2 c = 2.55;
a; b; c;
}
function literalToFixed() public pure {
fixed8x1 a = 0.1;
fixed8x1 b = 12.7;
fixed8x1 c = -12.8;
a; b; c;
}
}
// ----
@@ -2,3 +2,4 @@ contract C {
fixed8x80 a = -1e-100;
}
// ----
// TypeError: (29-36): Type rational_const -1 / 1000...(93 digits omitted)...0000 is not implicitly convertible to expected type fixed8x80, but it can be explicitly converted.