Import error corpus entries from grammar repos
Now that error recovery requires no input for the grammar author, it shouldn't be tested in the individual grammar repos.
This commit is contained in:
parent
1e353381ff
commit
e1a3a1daeb
9 changed files with 300 additions and 16 deletions
94
spec/fixtures/error_corpus/c_errors.txt
vendored
Normal file
94
spec/fixtures/error_corpus/c_errors.txt
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
========================================
|
||||
Errors inside ifdefs
|
||||
========================================
|
||||
|
||||
#ifdef something
|
||||
int x // no semicolon
|
||||
#endif
|
||||
|
||||
int a;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int b;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int c;
|
||||
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(preproc_ifdef
|
||||
(identifier)
|
||||
(ERROR (identifier) (identifier) (comment)))
|
||||
|
||||
(declaration (identifier) (identifier))
|
||||
|
||||
(preproc_ifdef
|
||||
(identifier)
|
||||
(ERROR (storage_class_specifier) (string_literal)))
|
||||
|
||||
(declaration (identifier) (identifier))
|
||||
|
||||
(preproc_ifdef
|
||||
(identifier)
|
||||
(ERROR))
|
||||
|
||||
(declaration (identifier) (identifier)))
|
||||
|
||||
========================================
|
||||
Errors inside blocks
|
||||
========================================
|
||||
|
||||
int main() {
|
||||
int x;
|
||||
int %$#@
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(function_definition
|
||||
(identifier)
|
||||
(function_declarator (identifier))
|
||||
(compound_statement
|
||||
(declaration (identifier) (identifier))
|
||||
(ERROR (identifier) (UNEXPECTED '$')))))
|
||||
|
||||
========================================
|
||||
Errors inside expressions
|
||||
========================================
|
||||
|
||||
int main() {
|
||||
int x = (123 123);
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(function_definition
|
||||
(identifier)
|
||||
(function_declarator (identifier))
|
||||
(compound_statement
|
||||
(declaration (identifier) (init_declarator
|
||||
(identifier)
|
||||
(ERROR (number_literal))
|
||||
(number_literal))))))
|
||||
|
||||
========================================
|
||||
Errors in declarations
|
||||
========================================
|
||||
|
||||
float x WTF;
|
||||
int y = 5;
|
||||
|
||||
---
|
||||
|
||||
(translation_unit
|
||||
(declaration (identifier) (identifier) (ERROR (identifier)))
|
||||
(declaration (identifier) (init_declarator (identifier) (number_literal))))
|
||||
127
spec/fixtures/error_corpus/javascript_errors.txt
vendored
Normal file
127
spec/fixtures/error_corpus/javascript_errors.txt
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
============================================
|
||||
Invalid statements
|
||||
============================================
|
||||
|
||||
what the heck !
|
||||
y();
|
||||
|
||||
if (x) {
|
||||
>>>
|
||||
var y = right
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement
|
||||
(identifier)
|
||||
(ERROR (identifier) (identifier)))
|
||||
(expression_statement (function_call (identifier)))
|
||||
(if_statement (identifier) (statement_block
|
||||
(ERROR)
|
||||
(var_declaration (var_assignment (identifier) (identifier))))))
|
||||
|
||||
============================================
|
||||
Invalid if conditions
|
||||
============================================
|
||||
|
||||
if (uh oh)
|
||||
hmm();
|
||||
|
||||
ok();
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(if_statement (identifier) (ERROR (identifier))
|
||||
(expression_statement (function_call (identifier))))
|
||||
(expression_statement (function_call (identifier))))
|
||||
|
||||
============================================
|
||||
Invalid for loops
|
||||
============================================
|
||||
|
||||
ok1;
|
||||
|
||||
for (a b c; d; e)
|
||||
wat();
|
||||
|
||||
ok2;
|
||||
|
||||
for (a; b; c d ef)
|
||||
wat();
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement (identifier))
|
||||
|
||||
(for_statement
|
||||
(ERROR (identifier) (identifier))
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression_statement (function_call (identifier))))
|
||||
|
||||
(expression_statement (identifier))
|
||||
|
||||
(for_statement
|
||||
(identifier)
|
||||
(identifier)
|
||||
(ERROR (identifier) (identifier))
|
||||
(identifier)
|
||||
(expression_statement (function_call (identifier)))))
|
||||
|
||||
============================================
|
||||
Invalid statement blocks
|
||||
============================================
|
||||
|
||||
function() { ^ & * }
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement (function (statement_block (ERROR)))))
|
||||
|
||||
============================================
|
||||
Invalid objects
|
||||
============================================
|
||||
|
||||
x = {
|
||||
key1: value1,
|
||||
|
||||
abc efg,
|
||||
|
||||
key2: value2
|
||||
};
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement (assignment
|
||||
(identifier)
|
||||
(object
|
||||
(pair (identifier) (identifier))
|
||||
(ERROR (identifier) (identifier))
|
||||
(pair (identifier) (identifier))))))
|
||||
|
||||
============================================
|
||||
Invalid items in var declarations
|
||||
============================================
|
||||
|
||||
var
|
||||
a = 1,
|
||||
-b,
|
||||
c = 2,
|
||||
d = = = = =,
|
||||
e;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(var_declaration
|
||||
(var_assignment (identifier) (number))
|
||||
(ERROR (UNEXPECTED '-') (identifier))
|
||||
(var_assignment (identifier) (number))
|
||||
(ERROR (identifier) (UNEXPECTED '='))
|
||||
(identifier)))
|
||||
56
spec/fixtures/error_corpus/json_errors.txt
vendored
Normal file
56
spec/fixtures/error_corpus/json_errors.txt
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
==========================================
|
||||
top-level errors
|
||||
==========================================
|
||||
|
||||
[}
|
||||
|
||||
---
|
||||
|
||||
(ERROR)
|
||||
|
||||
==========================================
|
||||
unexpected tokens
|
||||
==========================================
|
||||
|
||||
barf
|
||||
|
||||
---
|
||||
|
||||
(ERROR (UNEXPECTED 'b'))
|
||||
|
||||
==========================================
|
||||
errors inside arrays
|
||||
==========================================
|
||||
|
||||
[1, , 2]
|
||||
|
||||
---
|
||||
(array
|
||||
(number)
|
||||
(ERROR)
|
||||
(number))
|
||||
|
||||
==========================================
|
||||
errors inside objects
|
||||
==========================================
|
||||
|
||||
{ "key1": 1, oops }
|
||||
|
||||
---
|
||||
|
||||
(object (pair (string) (number)) (ERROR (UNEXPECTED 'o')))
|
||||
|
||||
==========================================
|
||||
errors inside nested objects
|
||||
==========================================
|
||||
|
||||
{ "key1": { "key2": 1, 2 }, [, "key3": 3 }
|
||||
|
||||
---
|
||||
|
||||
(object
|
||||
(pair (string) (object
|
||||
(pair (string) (number))
|
||||
(ERROR (number))))
|
||||
(ERROR)
|
||||
(pair (string) (number)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue