Update error corpus
This commit is contained in:
parent
21a88b1731
commit
13adfe4927
3 changed files with 135 additions and 105 deletions
143
test/fixtures/error_corpus/c_errors.txt
vendored
143
test/fixtures/error_corpus/c_errors.txt
vendored
|
|
@ -1,52 +1,97 @@
|
|||
========================================
|
||||
Errors inside ifdefs
|
||||
========================================
|
||||
=======================================
|
||||
Statements with missing semicolons
|
||||
=======================================
|
||||
|
||||
#ifdef something
|
||||
int x // no semicolon
|
||||
#endif
|
||||
int main() {
|
||||
puts("hello")
|
||||
puts("world")
|
||||
}
|
||||
|
||||
int a;
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(function_definition
|
||||
(primitive_type)
|
||||
(function_declarator (identifier) (parameter_list))
|
||||
(compound_statement
|
||||
(expression_statement (call_expression (identifier) (argument_list (string_literal))) (MISSING))
|
||||
(expression_statement (call_expression (identifier) (argument_list (string_literal))) (MISSING)))))
|
||||
|
||||
==============================================
|
||||
Top-level declarations with missing semicolons
|
||||
==============================================
|
||||
|
||||
int x
|
||||
static int b
|
||||
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(declaration (primitive_type) (identifier) (MISSING))
|
||||
(declaration (storage_class_specifier) (primitive_type) (identifier) (MISSING)))
|
||||
|
||||
==========================================
|
||||
Partial declaration lists inside ifdefs
|
||||
==========================================
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int c() { return 5; }
|
||||
|
||||
// ok
|
||||
int b;
|
||||
|
||||
int c() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int c;
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(preproc_ifdef (identifier)
|
||||
(linkage_specification (string_literal) (declaration_list
|
||||
(preproc_call (preproc_directive))
|
||||
(comment)
|
||||
(declaration (primitive_type) (identifier))
|
||||
(function_definition (primitive_type) (function_declarator (identifier) (parameter_list)) (compound_statement (return_statement (number_literal))))
|
||||
(preproc_ifdef (identifier) (MISSING))))))
|
||||
|
||||
==========================================
|
||||
If statements with incomplete expressions
|
||||
==========================================
|
||||
|
||||
int main() {
|
||||
if (a.) {
|
||||
b();
|
||||
c();
|
||||
|
||||
if () d();
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(preproc_ifdef
|
||||
(identifier)
|
||||
(ERROR (primitive_type) (identifier))
|
||||
(comment))
|
||||
(declaration (primitive_type) (identifier))
|
||||
(preproc_ifdef
|
||||
(identifier)
|
||||
(linkage_specification
|
||||
(string_literal)
|
||||
(declaration_list
|
||||
(preproc_call (preproc_directive))
|
||||
(function_definition
|
||||
(primitive_type)
|
||||
(function_declarator (identifier) (parameter_list))
|
||||
(compound_statement (return_statement (number_literal))))
|
||||
(declaration (primitive_type) (identifier))
|
||||
(ERROR (identifier)))))
|
||||
(declaration (primitive_type) (identifier)))
|
||||
(function_definition
|
||||
(primitive_type)
|
||||
(function_declarator (identifier) (parameter_list))
|
||||
(compound_statement
|
||||
(if_statement
|
||||
(field_expression (identifier) (MISSING))
|
||||
(compound_statement
|
||||
(expression_statement (call_expression (identifier) (argument_list)))
|
||||
(expression_statement (call_expression (identifier) (argument_list)))
|
||||
(if_statement
|
||||
(MISSING)
|
||||
(expression_statement (call_expression (identifier) (argument_list)))))))))
|
||||
|
||||
========================================
|
||||
Errors inside blocks
|
||||
========================================
|
||||
====================================
|
||||
Invalid characters in declarations
|
||||
====================================
|
||||
|
||||
int main() {
|
||||
int x;
|
||||
|
|
@ -63,9 +108,9 @@ int main() {
|
|||
(declaration (primitive_type) (identifier))
|
||||
(ERROR (primitive_type) (UNEXPECTED '$')))))
|
||||
|
||||
========================================
|
||||
Errors inside expressions
|
||||
========================================
|
||||
=========================================
|
||||
Extra values in parenthesized expressions
|
||||
=========================================
|
||||
|
||||
int main() {
|
||||
int x = (123 123);
|
||||
|
|
@ -85,7 +130,7 @@ int main() {
|
|||
(ERROR (number_literal))))))))
|
||||
|
||||
========================================
|
||||
Errors in declarations
|
||||
Extra identifiers in declarations
|
||||
========================================
|
||||
|
||||
float x WTF;
|
||||
|
|
@ -98,44 +143,28 @@ int y = 5;
|
|||
(declaration (primitive_type) (init_declarator (identifier) (number_literal))))
|
||||
|
||||
==========================================
|
||||
Errors at the beginnings of blocks
|
||||
Declarations with missing variable names
|
||||
==========================================
|
||||
|
||||
int a() {
|
||||
struct x = 1;
|
||||
struct y = 2;
|
||||
}
|
||||
|
||||
int b() {
|
||||
w x y z = 3;
|
||||
w x y z = 4;
|
||||
int = 2;
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(function_definition
|
||||
(primitive_type)
|
||||
(function_declarator (identifier) (parameter_list))
|
||||
(compound_statement
|
||||
(struct_specifier (type_identifier))
|
||||
(ERROR (number_literal))
|
||||
(struct_specifier (type_identifier))
|
||||
(ERROR (number_literal))))
|
||||
|
||||
(function_definition
|
||||
(primitive_type)
|
||||
(function_declarator (identifier) (parameter_list))
|
||||
(compound_statement
|
||||
(declaration
|
||||
(type_identifier)
|
||||
(ERROR (identifier) (identifier))
|
||||
(struct_specifier (type_identifier))
|
||||
(init_declarator
|
||||
(identifier)
|
||||
(MISSING)
|
||||
(number_literal)))
|
||||
(declaration
|
||||
(type_identifier)
|
||||
(ERROR (identifier) (identifier))
|
||||
(primitive_type)
|
||||
(init_declarator
|
||||
(identifier)
|
||||
(MISSING)
|
||||
(number_literal))))))
|
||||
|
|
|
|||
91
test/fixtures/error_corpus/javascript_errors.txt
vendored
91
test/fixtures/error_corpus/javascript_errors.txt
vendored
|
|
@ -1,5 +1,45 @@
|
|||
===================================================
|
||||
one invalid token right after the viable prefix
|
||||
Missing default values for function parameters
|
||||
===================================================
|
||||
|
||||
class A {
|
||||
constructor (a, b = ) {
|
||||
this.a = a
|
||||
}
|
||||
|
||||
foo() {}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(class (identifier) (class_body
|
||||
(method_definition
|
||||
(property_identifier)
|
||||
(formal_parameters (identifier) (identifier) (ERROR))
|
||||
(statement_block (expression_statement (assignment_expression (member_expression (this) (property_identifier)) (identifier)))))
|
||||
(method_definition
|
||||
(property_identifier)
|
||||
(formal_parameters)
|
||||
(statement_block)))))
|
||||
|
||||
===================================================
|
||||
Missing object-literal values
|
||||
===================================================
|
||||
|
||||
{
|
||||
a: b,
|
||||
c:
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement (object
|
||||
(pair (property_identifier) (identifier))
|
||||
(pair (property_identifier) (yield_expression (MISSING))))))
|
||||
|
||||
===================================================
|
||||
Extra identifiers in expressions
|
||||
===================================================
|
||||
|
||||
if (a b) {
|
||||
|
|
@ -17,33 +57,12 @@ e f;
|
|||
(statement_block
|
||||
(ERROR (identifier))
|
||||
(expression_statement (identifier))))
|
||||
(ERROR (identifier))
|
||||
(expression_statement (identifier)))
|
||||
|
||||
=======================================================
|
||||
multiple invalid tokens right after the viable prefix
|
||||
=======================================================
|
||||
|
||||
if (a b c) {
|
||||
d e f g;
|
||||
}
|
||||
h i j k;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(if_statement
|
||||
(parenthesized_expression
|
||||
(identifier)
|
||||
(ERROR (identifier) (identifier)))
|
||||
(statement_block
|
||||
(ERROR (identifier))
|
||||
(expression_statement (identifier) (ERROR (identifier) (identifier)))))
|
||||
(ERROR (identifier))
|
||||
(expression_statement (identifier) (ERROR (identifier) (identifier))))
|
||||
(expression_statement
|
||||
(identifier)
|
||||
(ERROR (identifier))))
|
||||
|
||||
===================================================
|
||||
one invalid subtree right after the viable prefix
|
||||
Extra complex literals in expressions
|
||||
===================================================
|
||||
|
||||
if ({a: 'b'} {c: 'd'}) {
|
||||
|
|
@ -68,7 +87,7 @@ if ({a: 'b'} {c: 'd'}) {
|
|||
(statement_block (expression_statement (identifier)))))))))
|
||||
|
||||
===================================================
|
||||
one invalid token at the end of the file
|
||||
Extra tokens at the end of the file
|
||||
===================================================
|
||||
|
||||
// skip the equals sign
|
||||
|
|
@ -79,24 +98,6 @@ a.b =
|
|||
(comment)
|
||||
(ERROR (member_expression (identifier) (property_identifier))))
|
||||
|
||||
=================================================================
|
||||
An invalid token at the end of a construct with extra line breaks
|
||||
=================================================================
|
||||
|
||||
a(
|
||||
b,
|
||||
c,.
|
||||
);
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement
|
||||
(call_expression (identifier) (arguments
|
||||
(identifier)
|
||||
(identifier)
|
||||
(ERROR)))))
|
||||
|
||||
===================================================
|
||||
Errors after a sequence of function declarations
|
||||
===================================================
|
||||
|
|
|
|||
6
test/fixtures/error_corpus/json_errors.txt
vendored
6
test/fixtures/error_corpus/json_errors.txt
vendored
|
|
@ -47,7 +47,7 @@ errors inside objects
|
|||
errors inside nested objects
|
||||
==========================================
|
||||
|
||||
{ "key1": { "key2": 1, 2 }, [, "key3": 3 }
|
||||
{ "key1": { "key2": 1, 2 }, "key3": 3 [ }
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -55,5 +55,5 @@ errors inside nested objects
|
|||
(pair (string) (object
|
||||
(pair (string) (number))
|
||||
(ERROR (number))))
|
||||
(ERROR)
|
||||
(pair (string) (number))))
|
||||
(pair (string) (number))
|
||||
(ERROR)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue