Code coverage for Solidity smart-contracts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
pragma solidity >=0.8.0 <0.9.0;
|
|
|
|
|
|
|
|
|
|
|
|
contract Contract_ternary {
|
|
|
|
|
|
|
|
// Sameline consequent
|
|
|
|
function a() public {
|
|
|
|
bool x = true;
|
|
|
|
bool y = true;
|
|
|
|
x && y ? y = false : y = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multiline consequent
|
|
|
|
function b() public {
|
|
|
|
bool x = false;
|
|
|
|
bool y = false;
|
|
|
|
(x)
|
|
|
|
? y = false
|
|
|
|
: y = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sameline w/ logicalOR
|
|
|
|
function c() public {
|
|
|
|
bool x = false;
|
|
|
|
bool y = true;
|
|
|
|
(x || y) ? y = false : y = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multiline w/ logicalOR
|
|
|
|
function d() public {
|
|
|
|
bool x = false;
|
|
|
|
bool y = true;
|
|
|
|
(x || y)
|
|
|
|
? y = false
|
|
|
|
: y = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sameline alternate
|
|
|
|
function e() public {
|
|
|
|
bool x = false;
|
|
|
|
bool y = false;
|
|
|
|
(x) ? y = false : y = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multiline w/ logicalOR (both false)
|
|
|
|
function f() public {
|
|
|
|
bool x = false;
|
|
|
|
bool y = false;
|
|
|
|
(x || y)
|
|
|
|
? y = false
|
|
|
|
: y = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|