Move corpus files to fixtures/corpus directory
This commit is contained in:
parent
bc0e290c17
commit
eb8ef59869
16 changed files with 1 additions and 1 deletions
199
spec/fixtures/corpus/javascript/control_flow.txt
vendored
Normal file
199
spec/fixtures/corpus/javascript/control_flow.txt
vendored
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
==========================================
|
||||
multiple statements
|
||||
==========================================
|
||||
|
||||
var x = {}, z, i = 0;
|
||||
firstFunction(x)
|
||||
secondFunction(x);
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(var_declaration
|
||||
(var_assignment (identifier) (object))
|
||||
(identifier)
|
||||
(var_assignment (identifier) (number)))
|
||||
(expression_statement (function_call (identifier) (arguments (identifier))))
|
||||
(expression_statement (function_call (identifier) (arguments (identifier)))))
|
||||
|
||||
==========================================
|
||||
if statements
|
||||
==========================================
|
||||
|
||||
if (isReady()) {
|
||||
console.log(theData)
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (if_statement (function_call (identifier) (arguments))
|
||||
(statement_block (expression_statement
|
||||
(function_call (member_access (identifier) (identifier)) (arguments (identifier)))))))
|
||||
|
||||
==========================================
|
||||
if-else statements
|
||||
==========================================
|
||||
|
||||
if (theCondition) {
|
||||
firstFunction();
|
||||
} else {
|
||||
secondFunction();
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (if_statement
|
||||
(identifier)
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments))))
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments))))))
|
||||
|
||||
==================================================
|
||||
if-else statements with multiple conditions
|
||||
==================================================
|
||||
|
||||
if (firstValue) {
|
||||
firstFunction();
|
||||
} else if (secondValue)
|
||||
secondFunction();
|
||||
else {
|
||||
thirdFunction();
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (if_statement (identifier)
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments))))
|
||||
(if_statement (identifier)
|
||||
(expression_statement (function_call (identifier) (arguments)))
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments)))))))
|
||||
|
||||
==========================================
|
||||
for loops
|
||||
==========================================
|
||||
|
||||
for (var i = 1; someCondition(i); i = next()) {
|
||||
doSomething();
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (for_statement
|
||||
(var_declaration (var_assignment (identifier) (number)))
|
||||
(function_call (identifier) (arguments (identifier)))
|
||||
(assignment (identifier) (function_call (identifier) (arguments)))
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments))))))
|
||||
|
||||
==========================================
|
||||
for-in loops
|
||||
==========================================
|
||||
|
||||
for (var key in someObject)
|
||||
doSomething();
|
||||
for (key in someObject)
|
||||
doSomethingElse();
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(for_in_statement
|
||||
(identifier) (identifier)
|
||||
(expression_statement (function_call (identifier) (arguments))))
|
||||
(for_in_statement
|
||||
(identifier) (identifier)
|
||||
(expression_statement (function_call (identifier) (arguments)))))
|
||||
|
||||
==========================================
|
||||
while loops
|
||||
==========================================
|
||||
|
||||
while (someCondition(i)) {
|
||||
doSomething();
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (while_statement
|
||||
(function_call (identifier) (arguments (identifier)))
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments))))))
|
||||
|
||||
==========================================
|
||||
try/catch statements
|
||||
==========================================
|
||||
|
||||
try {
|
||||
doSomething();
|
||||
} catch (e) {
|
||||
logError(e);
|
||||
}
|
||||
|
||||
try {
|
||||
doSomething();
|
||||
} finally {
|
||||
logError();
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(try_statement
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments))))
|
||||
(catch (identifier)
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments (identifier)))))))
|
||||
(try_statement
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments))))
|
||||
(finally
|
||||
(statement_block (expression_statement (function_call (identifier) (arguments)))))))
|
||||
|
||||
===========================================
|
||||
throw statements
|
||||
===========================================
|
||||
|
||||
throw new Error("wtf");
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(throw_statement (constructor_call (identifier) (arguments (string)))))
|
||||
|
||||
===========================================
|
||||
indented code after blocks
|
||||
===========================================
|
||||
|
||||
function x() {}
|
||||
return z;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement
|
||||
(function_expression (identifier) (statement_block)))
|
||||
(return_statement (identifier)))
|
||||
|
||||
===========================================
|
||||
switch statements
|
||||
===========================================
|
||||
|
||||
switch(x) {
|
||||
case "hello":
|
||||
print("one");
|
||||
break;
|
||||
case z():
|
||||
print("two");
|
||||
break;
|
||||
default:
|
||||
print("three");
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (switch_statement (identifier)
|
||||
(case
|
||||
(string)
|
||||
(expression_statement (function_call (identifier) (arguments (string))))
|
||||
(break_statement))
|
||||
(case
|
||||
(function_call (identifier) (arguments))
|
||||
(expression_statement (function_call (identifier) (arguments (string))))
|
||||
(break_statement))
|
||||
(default
|
||||
(expression_statement (function_call (identifier) (arguments (string)))))))
|
||||
30
spec/fixtures/corpus/javascript/errors.txt
vendored
Normal file
30
spec/fixtures/corpus/javascript/errors.txt
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
==========================================
|
||||
errors in function calls
|
||||
==========================================
|
||||
|
||||
stuff(|||);
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement (function_call (identifier) (arguments (ERROR (UNEXPECTED '|'))))))
|
||||
|
||||
==========================================
|
||||
errors in if statements
|
||||
==========================================
|
||||
|
||||
stuff();
|
||||
if (*nonsense*) {
|
||||
*more-nonsense*;
|
||||
}
|
||||
moreStuff();
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement (function_call (identifier) (arguments)))
|
||||
(if_statement
|
||||
(ERROR (UNEXPECTED '*') (identifier))
|
||||
(statement_block
|
||||
(expression_statement (ERROR (UNEXPECTED '*') (identifier) (identifier)))))
|
||||
(expression_statement (function_call (identifier) (arguments))))
|
||||
98
spec/fixtures/corpus/javascript/literals.txt
vendored
Normal file
98
spec/fixtures/corpus/javascript/literals.txt
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
==========================================
|
||||
regexes
|
||||
==========================================
|
||||
|
||||
theFunction(/regex1/, /regex2/g);
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(function_call (identifier) (arguments (regex) (regex)))))
|
||||
|
||||
==========================================
|
||||
numbers
|
||||
==========================================
|
||||
|
||||
theFunction(100.0, 200);
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(function_call (identifier) (arguments (number) (number)))))
|
||||
|
||||
==========================================
|
||||
strings
|
||||
==========================================
|
||||
|
||||
theFunction('', "", 'single-quoted-string', "double-quoted-string");
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(function_call (identifier)
|
||||
(arguments (string) (string) (string) (string)))))
|
||||
|
||||
==========================================
|
||||
function expressions
|
||||
==========================================
|
||||
|
||||
var x = {
|
||||
theMethod: function(argA, argB) {
|
||||
var x = argA;
|
||||
}
|
||||
};
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(object (pair (identifier) (function_expression
|
||||
(formal_parameters (identifier) (identifier))
|
||||
(statement_block
|
||||
(var_declaration (var_assignment (identifier) (identifier))))))))))
|
||||
|
||||
==========================================
|
||||
comments
|
||||
==========================================
|
||||
|
||||
// this is the beginning of the script.
|
||||
// here we go.
|
||||
var thing = {
|
||||
|
||||
// this is a property.
|
||||
// its value is a function.
|
||||
key: function(x /* this is a parameter */) {
|
||||
|
||||
// this is a statement
|
||||
doStuff();
|
||||
}
|
||||
};
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(comment)
|
||||
(comment)
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(object
|
||||
(comment)
|
||||
(comment)
|
||||
(pair (identifier) (function_expression
|
||||
(formal_parameters (identifier) (comment))
|
||||
(statement_block
|
||||
(comment)
|
||||
(expression_statement (function_call (identifier) (arguments))))))))))
|
||||
|
||||
==========================================
|
||||
comments within expressions
|
||||
==========================================
|
||||
|
||||
y // comment
|
||||
* z;
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(math_op (identifier) (comment) (identifier))))
|
||||
177
spec/fixtures/corpus/javascript/operators.txt
vendored
Normal file
177
spec/fixtures/corpus/javascript/operators.txt
vendored
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
==========================================
|
||||
function calls
|
||||
==========================================
|
||||
|
||||
x.theMethod(5, 6);
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(function_call
|
||||
(member_access (identifier) (identifier))
|
||||
(arguments (number) (number)))))
|
||||
|
||||
==========================================
|
||||
constructor calls
|
||||
==========================================
|
||||
|
||||
var x = new Node(5, new Node(3, null));
|
||||
new Thing;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(constructor_call (identifier) (arguments
|
||||
(number)
|
||||
(constructor_call (identifier) (arguments
|
||||
(number)
|
||||
(null)))))))
|
||||
(expression_statement (constructor_call (identifier))))
|
||||
|
||||
==========================================
|
||||
property access with dot notation
|
||||
==========================================
|
||||
|
||||
object.property = "the-value";
|
||||
object.property;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement
|
||||
(assignment (member_access (identifier) (identifier)) (string)))
|
||||
(expression_statement
|
||||
(member_access (identifier) (identifier))))
|
||||
|
||||
==========================================
|
||||
property access across lines
|
||||
==========================================
|
||||
|
||||
object
|
||||
.someProperty
|
||||
.otherProperty
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(member_access
|
||||
(member_access (identifier) (identifier))
|
||||
(identifier))))
|
||||
|
||||
===========================================
|
||||
dynamic property access
|
||||
==========================================
|
||||
|
||||
object[propertName()] = propertyValue();
|
||||
object[propertyName()];
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement
|
||||
(assignment
|
||||
(subscript_access (identifier) (function_call (identifier) (arguments)))
|
||||
(function_call (identifier) (arguments))))
|
||||
(expression_statement
|
||||
(subscript_access (identifier) (function_call (identifier) (arguments)))))
|
||||
|
||||
==========================================
|
||||
ternary expressions
|
||||
==========================================
|
||||
|
||||
isDone() ? stuff : otherStuff;
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(ternary (function_call (identifier) (arguments)) (identifier) (identifier))))
|
||||
|
||||
==========================================
|
||||
mathematical operators
|
||||
==========================================
|
||||
|
||||
a++ + b * c - d / e--
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(math_op
|
||||
(math_op
|
||||
(math_op (identifier))
|
||||
(math_op (identifier) (identifier)))
|
||||
(math_op
|
||||
(identifier)
|
||||
(math_op (identifier))))))
|
||||
|
||||
==========================================
|
||||
boolean operators
|
||||
=========================================
|
||||
|
||||
!a || !(b && c)
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(bool_op
|
||||
(bool_op (identifier))
|
||||
(bool_op
|
||||
(bool_op (identifier) (identifier))))))
|
||||
|
||||
===========================================
|
||||
type operators
|
||||
===========================================
|
||||
|
||||
(x instanceof Array) || (typeof x === "string")
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(bool_op
|
||||
(type_op (identifier) (identifier))
|
||||
(rel_op (type_op (identifier)) (string)))))
|
||||
|
||||
============================================
|
||||
the 'in' operator
|
||||
===========================================
|
||||
|
||||
print(x in y)
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(function_call
|
||||
(identifier)
|
||||
(arguments (type_op (identifier) (identifier))))))
|
||||
|
||||
============================================
|
||||
assignment operators
|
||||
============================================
|
||||
|
||||
x += 1;
|
||||
x -= 1;
|
||||
x *= 2;
|
||||
x /= 2;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(expression_statement (math_assignment (identifier) (number)))
|
||||
(expression_statement (math_assignment (identifier) (number)))
|
||||
(expression_statement (math_assignment (identifier) (number)))
|
||||
(expression_statement (math_assignment (identifier) (number))))
|
||||
|
||||
============================================
|
||||
property access and operators
|
||||
============================================
|
||||
|
||||
print(x.y.z && a.b.c)
|
||||
|
||||
---
|
||||
|
||||
(program (expression_statement
|
||||
(function_call (identifier)
|
||||
(arguments (bool_op
|
||||
(member_access (member_access (identifier) (identifier)) (identifier))
|
||||
(member_access (member_access (identifier) (identifier)) (identifier)))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue