mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests
This commit is contained in:
parent
2beb87eb02
commit
a6f739f38d
22
test/libsolidity/semanticTests/fixedPoint/comparison.sol
Normal file
22
test/libsolidity/semanticTests/fixedPoint/comparison.sol
Normal file
@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
function test() public pure returns (bool) {
|
||||
fixed64x4 x = fixed64x4(-1.12346789);
|
||||
fixed64x4 y = -1.1235;
|
||||
ufixed32x4 z = 1;
|
||||
require(x == x);
|
||||
require(x > y);
|
||||
require(x >= y);
|
||||
require(x != y);
|
||||
require(y <= x);
|
||||
require(!(x < y));
|
||||
require(y < z);
|
||||
require(x < z);
|
||||
require(z >= x);
|
||||
require(z == z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> true
|
@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function test() public pure returns (bool) {
|
||||
require(1/2 == 1/2);
|
||||
require(fixed128x2(1/2 + 0.0000001) == 1/2);
|
||||
require(fixed128x2(1/3) < 1/2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> true
|
10
test/libsolidity/semanticTests/fixedPoint/conversion2.sol
Normal file
10
test/libsolidity/semanticTests/fixedPoint/conversion2.sol
Normal file
@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function test() public pure returns (fixed64x3, fixed128x4, ufixed64x4) {
|
||||
fixed64x4 x = fixed64x4(-1.12346789);
|
||||
return (fixed64x3(x), fixed128x4(x), ufixed64x4(x));
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> -1.123, -1.1234, 1844674407370954.0382
|
19
test/libsolidity/semanticTests/fixedPoint/encodepacked.sol
Normal file
19
test/libsolidity/semanticTests/fixedPoint/encodepacked.sol
Normal file
@ -0,0 +1,19 @@
|
||||
contract C {
|
||||
function f() public pure returns (bytes memory) {
|
||||
return abi.encodePacked(
|
||||
1.23,
|
||||
fixed64x4(-1.234)
|
||||
);
|
||||
}
|
||||
function g() public pure returns (bytes memory) {
|
||||
return abi.encode(
|
||||
1.23,
|
||||
fixed64x4(-1.234)
|
||||
);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() ->
|
||||
// g() ->
|
13
test/libsolidity/semanticTests/fixedPoint/getter.sol
Normal file
13
test/libsolidity/semanticTests/fixedPoint/getter.sol
Normal file
@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
fixed64x4 public a = -2.123;
|
||||
fixed64x4 public immutable b = -2.456;
|
||||
mapping(uint => fixed64x4) public m;
|
||||
constructor() { m[3] = 1.123; }
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// a() -> -2.1230
|
||||
// b() -> -2.4560
|
||||
// m(uint256): 2 -> 0.0000
|
||||
// m(uint256): 3 -> 1.1230
|
Loading…
Reference in New Issue
Block a user