mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixed point conversion tests.
This commit is contained in:
parent
45fc4baafa
commit
97c0c8337f
@ -0,0 +1,2 @@
|
||||
fixed constant x = fixed(bytes16(fixed(1)));
|
||||
ufixed16x1 constant y = ufixed16x1(bytes2(ufixed16x1(1)));
|
@ -0,0 +1,18 @@
|
||||
fixed constant a = fixed(bytes17(0));
|
||||
bytes17 constant b = bytes17(fixed(0));
|
||||
fixed constant c = fixed(bytes15(0));
|
||||
bytes15 constant d = bytes15(fixed(0));
|
||||
|
||||
fixed16x1 constant e = fixed16x1(bytes3(0));
|
||||
bytes3 constant f = bytes3(fixed16x1(0));
|
||||
fixed16x1 constant g = fixed16x1(bytes1(0));
|
||||
bytes1 constant h = bytes1(fixed16x1(0));
|
||||
// ----
|
||||
// TypeError 9640: (19-36): Explicit type conversion not allowed from "bytes17" to "fixed128x18".
|
||||
// TypeError 9640: (59-76): Explicit type conversion not allowed from "fixed128x18" to "bytes17".
|
||||
// TypeError 9640: (97-114): Explicit type conversion not allowed from "bytes15" to "fixed128x18".
|
||||
// TypeError 9640: (137-154): Explicit type conversion not allowed from "fixed128x18" to "bytes15".
|
||||
// TypeError 9640: (180-200): Explicit type conversion not allowed from "bytes3" to "fixed16x1".
|
||||
// TypeError 9640: (222-242): Explicit type conversion not allowed from "fixed16x1" to "bytes3".
|
||||
// TypeError 9640: (267-287): Explicit type conversion not allowed from "bytes1" to "fixed16x1".
|
||||
// TypeError 9640: (309-329): Explicit type conversion not allowed from "fixed16x1" to "bytes1".
|
@ -0,0 +1,13 @@
|
||||
// implicit conversions
|
||||
fixed128x2 constant a = fixed64x1(0);
|
||||
fixed128x1 constant b = fixed64x1(0);
|
||||
fixed128x1 constant c = ufixed64x1(0);
|
||||
fixed128x3 constant d = ufixed64x1(0);
|
||||
// explicit conversions
|
||||
// precision reduction
|
||||
ufixed64x1 constant r = ufixed64x1(ufixed64x2(0));
|
||||
// sign change
|
||||
ufixed64x2 constant s = ufixed64x2(fixed64x2(0));
|
||||
// bit reduction
|
||||
fixed32x2 constant t = fixed32x2(fixed64x2(0));
|
||||
// ----
|
@ -0,0 +1,26 @@
|
||||
// implicit conversions
|
||||
// precision reduction
|
||||
fixed128x1 constant a = fixed64x2(0);
|
||||
// sign change
|
||||
fixed64x1 constant b = ufixed64x1(0);
|
||||
ufixed256x3 constant c = fixed64x1(0);
|
||||
// width reduction
|
||||
fixed32x1 constant d = ufixed64x1(0);
|
||||
|
||||
// explicit conversions
|
||||
// precision and sign
|
||||
fixed256x1 constant e = fixed256x1(ufixed64x2(0));
|
||||
// precision and value range
|
||||
ufixed32x1 constant f = ufixed32x1(ufixed64x2(0));
|
||||
// value range and sign
|
||||
fixed32x2 constant g = fixed32x2(ufixed64x2(0));
|
||||
ufixed32x2 constant h = ufixed32x2(fixed64x2(0));
|
||||
// ----
|
||||
// TypeError 7407: (71-83): Type fixed64x2 is not implicitly convertible to expected type fixed128x1. Conversion would incur precision loss - use explicit conversion instead.
|
||||
// TypeError 7407: (123-136): Type ufixed64x1 is not implicitly convertible to expected type fixed64x1.
|
||||
// TypeError 7407: (163-175): Type fixed64x1 is not implicitly convertible to expected type ufixed256x3.
|
||||
// TypeError 7407: (219-232): Type ufixed64x1 is not implicitly convertible to expected type fixed32x1.
|
||||
// TypeError 9640: (305-330): Explicit type conversion not allowed from "ufixed64x2" to "fixed256x1". Can only change one of precision, number of bits and signedness at the same time.
|
||||
// TypeError 9640: (385-410): Explicit type conversion not allowed from "ufixed64x2" to "ufixed32x1". Can only change one of precision, number of bits and signedness at the same time.
|
||||
// TypeError 9640: (459-483): Explicit type conversion not allowed from "ufixed64x2" to "fixed32x2". Can only change one of precision, number of bits and signedness at the same time.
|
||||
// TypeError 9640: (509-533): Explicit type conversion not allowed from "fixed64x2" to "ufixed32x2". Can only change one of precision, number of bits and signedness at the same time.
|
@ -0,0 +1,2 @@
|
||||
ufixed32x1 constant x = ufixed32x1(uint8(0));
|
||||
fixed32x1 constant y = fixed32x1(uint8(0));
|
@ -0,0 +1,5 @@
|
||||
ufixed16x1 constant x = ufixed16x1(uint16(0));
|
||||
ufixed64x1 constant y = ufixed64x1(int8(0));
|
||||
// ----
|
||||
// TypeError 9640: (24-45): Explicit type conversion not allowed from "uint16" to "ufixed16x1".
|
||||
// TypeError 9640: (71-90): Explicit type conversion not allowed from "int8" to "ufixed64x1".
|
@ -0,0 +1,7 @@
|
||||
// implicit conversions
|
||||
fixed64x2 constant a = 1.23;
|
||||
ufixed64x2 constant b = 1.23;
|
||||
|
||||
// explicit conversions
|
||||
fixed constant c = fixed(1/3);
|
||||
// ----
|
@ -0,0 +1,21 @@
|
||||
// implicit conversions
|
||||
fixed64x2 constant a = 1.123;
|
||||
ufixed64x2 constant b = -1.123;
|
||||
fixed64x28 constant c = 1;
|
||||
fixed64x28 constant d = -1;
|
||||
ufixed256x77 constant e = 1/3;
|
||||
ufixed256x77 constant f = -1;
|
||||
|
||||
// explicit conversions
|
||||
fixed64x2 constant g = fixed64x2(2**64);
|
||||
ufixed64x2 constant h = ufixed64x2(-1);
|
||||
|
||||
// ----
|
||||
// TypeError 2326: (47-52): Type rational_const 1123 / 1000 is not implicitly convertible to expected type fixed64x2. Try converting to type ufixed16x3 or use an explicit conversion.
|
||||
// TypeError 2326: (78-84): Type rational_const -1123 / 1000 is not implicitly convertible to expected type ufixed64x2. Try converting to type fixed16x3 or use an explicit conversion.
|
||||
// TypeError 7407: (110-111): Type int_const 1 is not implicitly convertible to expected type fixed64x28.
|
||||
// TypeError 7407: (137-139): Type int_const -1 is not implicitly convertible to expected type fixed64x28.
|
||||
// TypeError 4426: (167-170): Type rational_const 1 / 3 is not implicitly convertible to expected type ufixed256x77, but it can be explicitly converted.
|
||||
// TypeError 7407: (198-200): Type int_const -1 is not implicitly convertible to expected type ufixed256x77.
|
||||
// TypeError 9640: (250-266): Explicit type conversion not allowed from "int_const 18446744073709551616" to "fixed64x2". Value is too large.
|
||||
// TypeError 9640: (292-306): Explicit type conversion not allowed from "int_const -1" to "ufixed64x2". Value is too small.
|
@ -0,0 +1,2 @@
|
||||
uint constant x = uint(ufixed(0));
|
||||
int constant y = int(fixed(0));
|
@ -0,0 +1,5 @@
|
||||
uint constant x = uint(fixed8x1(0));
|
||||
uint248 constant y = uint248(ufixed256x1(0));
|
||||
// ----
|
||||
// TypeError 9640: (18-35): Explicit type conversion not allowed from "fixed8x1" to "uint256".
|
||||
// TypeError 9640: (58-81): Explicit type conversion not allowed from "ufixed256x1" to "uint248".
|
@ -0,0 +1,5 @@
|
||||
bytes32 constant x = ufixed256x5(0);
|
||||
bytes16 constant y = fixed(0);
|
||||
// ----
|
||||
// TypeError 7407: (21-35): Type ufixed256x5 is not implicitly convertible to expected type bytes32.
|
||||
// TypeError 7407: (58-66): Type fixed128x18 is not implicitly convertible to expected type bytes16.
|
Loading…
Reference in New Issue
Block a user