Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusaaguiar committed Jul 11, 2023
1 parent d21d31a commit e93bb7f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/libsolidity/syntaxTests/metaTypes/type_max.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
contract C {
function max() public pure returns (uint8) {
return type(uint8).max;
}
}
// ----
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract C {
function max(bool isUint) public returns (uint8) {
return (isUint ? type(uint8) : type(int8)).max;
}
}
// ----
// TypeError 9717: (93-104): Invalid mobile type in true expression.
// TypeError 3703: (107-117): Invalid mobile type in false expression.
11 changes: 11 additions & 0 deletions test/libsolidity/syntaxTests/metaTypes/type_runtimecode.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
contract A {
function f() public {}
}

contract C {
function f() public returns (bytes memory) {
return type(A).runtimeCode;
}
}
// ----
// Warning 2018: (60-146): Function state mutability can be restricted to pure
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
contract A {
function f() public {}
}

contract B {
function g() public {}
}

contract C {
function f(bool getA) public returns (bytes memory) {
return (getA ? type(A) : type(B)).runtimeCode;
}
}
// ----
// TypeError 9717: (180-187): Invalid mobile type in true expression.
// TypeError 3703: (190-197): Invalid mobile type in false expression.

0 comments on commit e93bb7f

Please sign in to comment.