Rename spec -> test

'Test' is a lot more straightforward of a name.
This commit is contained in:
Max Brunsfeld 2017-03-09 20:40:01 -08:00
parent 7d8daf573e
commit 6dc0ff359d
109 changed files with 44 additions and 44 deletions

130
test/fixtures/error_corpus/c_errors.txt vendored Normal file
View file

@ -0,0 +1,130 @@
========================================
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) (ERROR (identifier)) (identifier))
(declaration (identifier) (init_declarator (identifier) (number_literal))))
==========================================
Errors at the beginnings of blocks
==========================================
int a() {
struct x = 1;
struct y = 2;
}
int b() {
w x y z = 3;
w x y z = 4;
}
---
(translation_unit
(function_definition
(identifier) (function_declarator (identifier))
(compound_statement
(ERROR (struct_specifier (identifier)))
(expression_statement (number_literal))
(ERROR (struct_specifier (identifier)))
(expression_statement (number_literal))))
(function_definition
(identifier) (function_declarator (identifier))
(compound_statement
(declaration
(identifier)
(init_declarator
(ERROR (identifier) (identifier))
(identifier) (number_literal)))
(declaration
(ERROR (identifier) (identifier))
(identifier)
(init_declarator (identifier) (number_literal))))))

View file

@ -0,0 +1,157 @@
===================================================
one invalid token right after the viable prefix
===================================================
if (a b) {
c d;
}
e f;
---
(program
(if_statement
(ERROR (identifier))
(identifier)
(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
(ERROR (identifier) (identifier))
(identifier)
(statement_block
(ERROR (identifier) (identifier) (identifier))
(expression_statement (identifier))))
(expression_statement
(ERROR (identifier) (identifier) (identifier))
(identifier)))
===================================================
one invalid subtree right after the viable prefix
===================================================
if ({a: 'b'} {c: 'd'}) {
x = function(a) { b; } function(c) { d; }
}
---
(program
(if_statement
(object (pair (identifier) (string)))
(ERROR (object (pair (identifier) (string))))
(statement_block
(expression_statement (assignment
(identifier)
(ERROR (function
(formal_parameters (identifier))
(statement_block (expression_statement (identifier)))))
(function
(formal_parameters (identifier))
(statement_block (expression_statement (identifier)))))))))
===================================================
one invalid token at the end of the file
===================================================
// skip the equals sign
a.b =
---
(program
(comment)
(trailing_expression_statement
(member_access (identifier) (identifier)))
(ERROR))
=================================================================
An invalid token at the end of a construct with extra line breaks
=================================================================
a(
b,
c,,
);
---
(program
(expression_statement
(function_call (identifier) (arguments
(identifier)
(identifier)
(ERROR)))))
===================================================
Multi-line chained expressions in var declarations
===================================================
const one = two
.three(four)
.five()
---
(program
(var_declaration (var_assignment
(identifier)
(function_call
(member_access
(function_call
(member_access (identifier) (identifier))
(arguments (identifier)))
(identifier))
(arguments)))))
===================================================
Errors after a sequence of function declarations
===================================================
/*
* The JS grammar has an ambiguity such that these functions
* can be parsed either as function declarations or as
* function expressions. This ambiguity causes a lot of
* splitting and merging in the parse stack. When iterating
* the parse stack during an error repair, there would then
* be a very large number (> 2^16) of paths through the parse
* stack.
*/
function a() {}
function b() {}
function c() {}
function e() {}
function f() {}
function g() {}
function h() {}
function i() {}
var x = !!!
---
(program
(comment)
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(expression_statement (function (identifier) (formal_parameters) (statement_block)))
(trailing_var_declaration (identifier)) (ERROR))

View 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)))

View file

@ -0,0 +1,29 @@
==========================================
errors in if statements
==========================================
if a is:
print b
print c
---
(module
(if_statement (identifier) (ERROR)
(print_statement (identifier))
(print_statement (identifier))))
==========================================
errors in function definitions
==========================================
def a()::
b
c
---
(module
(function_definition (identifier) (parameters) (ERROR)
(expression_statement (identifier))
(expression_statement (identifier))))