Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusaaguiar committed Jun 27, 2023
1 parent 5206451 commit 5d4520e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/libsolidity/syntaxTests/metaTypes/type_max.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contract C {
function max() public returns (uint8) {
return type(int8).max;
}
}
// ----
// TypeError 6359: (72-86): Return argument type int8 is not implicitly convertible to expected type (type of first return variable) uint8.
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 5d4520e

Please sign in to comment.