mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Syntax Tests: extract array_length_* tests.
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f(uint constant LEN) {
|
||||
uint[LEN] a;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (62-65): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
uint constant LEN = 10;
|
||||
function f() public pure {
|
||||
uint[LEN] memory a;
|
||||
a;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
uint constant LEN = 10;
|
||||
struct Test {
|
||||
uint[LEN] ids;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
uint constant L = 5;
|
||||
uint constant LEN = L + 4 * L;
|
||||
uint[LEN] ids;
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
function f() {}
|
||||
uint[f] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (42-43): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f(uint x) {}
|
||||
uint constant LEN = f();
|
||||
uint[LEN] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (77-80): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
uint constant L2 = LEN - 10;
|
||||
uint constant L1 = L2 / 10;
|
||||
uint constant LEN = 10 + L1 * 5;
|
||||
function f() {
|
||||
uint[LEN] a;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (36-39): Cyclic constant definition (or maximum recursion depth exhausted).
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
fixed constant L = 10.5;
|
||||
uint[L] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (51-52): Array with fractional length specified.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint constant LEN = 10;
|
||||
uint[LEN] ids;
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
uint constant LEN = LEN;
|
||||
function f() {
|
||||
uint[LEN] a;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (37-40): Cyclic constant definition (or maximum recursion depth exhausted).
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[-true] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (22-27): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[true/1] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (22-28): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[1/true] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (22-28): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[1.111111E1111111111111] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (22-44): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[3/0] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (22-25): Operator / not compatible with types int_const 3 and int_const 0
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
bool constant LEN = true;
|
||||
uint[LEN] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (52-55): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[true] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (22-26): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
uint constant LEN = keccak256(ripemd160(33));
|
||||
uint[LEN] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (72-75): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint[8**90] ids;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (22-27): Invalid array length, expected integer literal or constant expression.
|
||||
Reference in New Issue
Block a user