Merge pull request #4562 from ethereum/parser-tests

Add comprehensive tests for the parser
This commit is contained in:
Alex Beregszaszi 2018-07-25 16:38:54 +01:00 committed by GitHub
commit 05e608d778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,7 @@
contract C {
function f() public {
emit;
}
}
// ----
// ParserError: (45-46): Expected event name or path.

View File

@ -0,0 +1,5 @@
contract C {
function f() public pure {
assembly "evmasm" {}
}
}

View File

@ -0,0 +1,7 @@
contract C {
function f() public pure {
assembly "failasm" {}
}
}
// ----
// ParserError: (55-64): Only "evmasm" supported.

View File

@ -0,0 +1,3 @@
import {hello, world} from "hello";
// ----
// ParserError: (0-35): Source "hello" not found: File not supplied initially.

View File

@ -0,0 +1,3 @@
import {hello, world} from function;
// ----
// ParserError: (27-35): Expected import path.

View File

@ -0,0 +1,3 @@
import {hello, world};
// ----
// ParserError: (21-22): Expected "from".

View File

@ -0,0 +1,3 @@
import function;
// ----
// ParserError: (7-15): Expected string literal (path), "*" or alias list.

View File

@ -0,0 +1,3 @@
import "hello";
// ----
// ParserError: (0-15): Source "hello" not found: File not supplied initially.

View File

@ -0,0 +1,12 @@
contract Foo {
uint[] m_x;
function f() public view {
uint[] storage memory x = m_x;
uint[] memory storage calldata y;
x; y;
}
}
// ----
// ParserError: (85-91): Location already specified.
// ParserError: (123-130): Location already specified.
// ParserError: (131-139): Location already specified.

View File

@ -0,0 +1,6 @@
contract Foo {
function f(uint[] storage memory constant x, uint[] memory calldata y) internal { }
}
// ----
// ParserError: (45-51): Location already specified.
// ParserError: (78-86): Location already specified.

View File

@ -0,0 +1,5 @@
contract Foo {
uint[] memory storage calldata x;
}
// ----
// ParserError: (23-29): Expected identifier but got 'memory'

View File

@ -0,0 +1,4 @@
pragma ``;
// ----
// ParserError: (7-8): Token incompatible with Solidity parser as part of pragma directive.
// ParserError: (8-9): Token incompatible with Solidity parser as part of pragma directive.