Move some parser tests to syntax tests

This commit is contained in:
Alex Beregszaszi
2018-05-02 21:21:11 +01:00
parent 5cce2e552b
commit 07e765a2f1
30 changed files with 183 additions and 319 deletions
@@ -0,0 +1,5 @@
contract Foo {
uint constant = 4;
}
// ----
// ParserError: (30-30): Expected identifier, got 'Assign'
@@ -0,0 +1,8 @@
contract C {
event A();
function f() {
emit A;
}
}
// ----
// ParserError: (49-49): Expected token LParen got 'Semicolon'
@@ -0,0 +1,5 @@
contract c {
enum foo { }
}
// ----
// ParserError: (25-25): enum with no members is not allowed.
@@ -0,0 +1,10 @@
contract test {
uint256 stateVar;
function functionName(bytes20 arg1, address addr) constant returns (int id) { }
}
// ----
// Warning: (36-115): No visibility specified. Defaulting to "public".
// Warning: (58-70): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (72-84): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (104-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (36-115): Function state mutability can be restricted to pure
@@ -0,0 +1,5 @@
contract c {
event e;
}
// ----
// ParserError: (21-21): Expected token LParen got 'Semicolon'
@@ -0,0 +1,5 @@
contract c {
uint external x;
}
// ----
// ParserError: (19-19): Expected identifier, got 'External'
@@ -0,0 +1,5 @@
contract A {
fixed40x40 pi = 3.14.15;
}
// ----
// ParserError: (34-34): Expected token Semicolon got 'Number'
@@ -0,0 +1,5 @@
contract test {
function (uint, uint) modifier1() returns (uint) f1;
}
// ----
// ParserError: (66-66): Expected token LBrace got 'Identifier'
@@ -0,0 +1,9 @@
contract c {
uint[] a;
function f() returns (uint) {
a = [,2,3];
return (a[0]);
}
}
// ----
// ParserError: (62-62): Expected expression (inline array elements cannot be omitted).
@@ -0,0 +1,8 @@
contract c {
uint[] a;
function f() returns (uint, uint) {
return ([3, ,4][0]);
}
}
// ----
// ParserError: (75-75): Expected expression (inline array elements cannot be omitted).
@@ -0,0 +1,7 @@
contract test {
function f() {
fixed a = 1.0x2;
}
}
// ----
// ParserError: (44-44): Expected primary expression.
@@ -0,0 +1,9 @@
contract Foo {
function localConst() returns (uint ret)
{
uint constant local = 4;
return local;
}
}
// ----
// ParserError: (67-67): Expected token Semicolon got 'Constant'
@@ -0,0 +1,5 @@
contract Foo {
uint[] memory x;
}
// ----
// ParserError: (23-23): Expected identifier, got 'Memory'
@@ -0,0 +1,5 @@
contract Foo {
function f() { var memory x; }
}
// ----
// ParserError: (35-35): Location specifier needs explicit type name.
@@ -0,0 +1,5 @@
contract c {
enum foo { WARNING,}
}
// ----
// ParserError: (33-33): Expected Identifier after ','
@@ -0,0 +1,6 @@
contract test {
function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }
function b() returns (uint r) { r = a({a: , b: , c: }); }
}
// ----
// ParserError: (146-146): Expected primary expression.
@@ -0,0 +1,6 @@
contract test {
function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }
function b() returns (uint r) { r = a({: 1, : 2, : 3}); }
}
// ----
// ParserError: (143-143): Expected identifier, got 'Colon'
@@ -0,0 +1,5 @@
contract c {
modifier mod { if (msg.sender == 0) _ }
}
// ----
// ParserError: (52-52): Expected token Semicolon got 'RBrace'
@@ -0,0 +1,7 @@
contract C {
function f() {
new var;
}
}
// ----
// ParserError: (35-35): Expected explicit type name.
@@ -0,0 +1,7 @@
contract test {
uint256 stateVar;
function functionName() {}
}
// ----
// Warning: (36-62): No visibility specified. Defaulting to "public".
// Warning: (36-62): Function state mutability can be restricted to pure
@@ -0,0 +1,5 @@
contract test {
uint payable x;
}
// ----
// ParserError: (22-22): Expected identifier, got 'Payable'
@@ -0,0 +1,7 @@
contract test {
uint256 a = 2e10;
uint256 b = 2E10;
uint256 c = 200e-2;
uint256 d = 2E10 wei;
uint256 e = 2.5e10;
}
@@ -0,0 +1,9 @@
contract test {
uint256 stateVar;
function functionName(bytes32 input) returns (bytes32 out) {}
}
// ----
// Warning: (36-97): No visibility specified. Defaulting to "public".
// Warning: (58-71): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (82-93): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (36-97): Function state mutability can be restricted to pure
@@ -0,0 +1,5 @@
contract test {
function(uint a,) {}
}
// ----
// ParserError: (32-32): Unexpected trailing comma in parameter list.
@@ -0,0 +1,5 @@
contract test {
function() returns (uint a,) {}
}
// ----
// ParserError: (43-43): Unexpected trailing comma in parameter list.
@@ -0,0 +1,6 @@
contract test {
function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }
function b() returns (uint r) { r = a({a: 1, b: 2, c: 3, }); }
}
// ----
// ParserError: (159-159): Unexpected trailing comma.
@@ -0,0 +1,7 @@
contract C {
function f() {
var a = (2 2);
}
}
// ----
// ParserError: (42-42): Expected token Comma got 'Number'
@@ -0,0 +1,5 @@
contract Foo {
function f() { var[] a; }
}
// ----
// ParserError: (34-34): Expected identifier, got 'LBrack'
@@ -0,0 +1,7 @@
contract test {
function fun() {
mapping(var=>bytes32) d;
}
}
// ----
// ParserError: (44-44): Expected elementary type name for mapping key type