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
|
|
@ -102,7 +102,7 @@ static string src_dir() {
|
|||
|
||||
vector<TestEntry> test_entries_for_language(string language) {
|
||||
vector<TestEntry> result;
|
||||
string language_dir = src_dir() + "/spec/runtime/languages/" + language;
|
||||
string language_dir = src_dir() + "/spec/fixtures/corpus/" + language;
|
||||
vector<string> filenames = list_directory(language_dir);
|
||||
|
||||
for (string &filename : filenames) {
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
=====================================================
|
||||
errors at the top level
|
||||
=====================================================
|
||||
|
||||
x * * y
|
||||
|
||||
---
|
||||
|
||||
(ERROR (variable) (UNEXPECTED '*') (variable))
|
||||
|
||||
=====================================================
|
||||
errors inside parenthesized expressions
|
||||
=====================================================
|
||||
|
||||
x + (y * + z) * 5
|
||||
|
||||
---
|
||||
|
||||
(program (sum
|
||||
(variable)
|
||||
(product
|
||||
(group (ERROR (variable) (UNEXPECTED '+') (variable))) (number))))
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
====================
|
||||
numbers
|
||||
===================
|
||||
|
||||
5
|
||||
|
||||
---
|
||||
|
||||
(program (number))
|
||||
|
||||
===================
|
||||
variables
|
||||
===================
|
||||
|
||||
x
|
||||
|
||||
---
|
||||
|
||||
(program (variable))
|
||||
|
||||
====================================
|
||||
variables with greek letters
|
||||
====================================
|
||||
|
||||
φ123
|
||||
|
||||
---
|
||||
|
||||
(program (variable))
|
||||
|
||||
===================
|
||||
products
|
||||
===================
|
||||
|
||||
x * x
|
||||
|
||||
---
|
||||
|
||||
(program (product (variable) (variable)))
|
||||
|
||||
===================
|
||||
sums
|
||||
===================
|
||||
|
||||
x + x
|
||||
|
||||
---
|
||||
|
||||
(program (sum (variable) (variable)))
|
||||
|
||||
===============================================
|
||||
operators of different precedence
|
||||
===============================================
|
||||
|
||||
a * b + c * d
|
||||
|
||||
---
|
||||
|
||||
(program (sum
|
||||
(product (variable) (variable))
|
||||
(product (variable) (variable))))
|
||||
|
||||
============================
|
||||
exponents
|
||||
============================
|
||||
|
||||
x + y * z^(a + b)
|
||||
|
||||
---
|
||||
|
||||
(program (sum
|
||||
(variable)
|
||||
(product
|
||||
(variable)
|
||||
(exponent
|
||||
(variable)
|
||||
(group (sum (variable) (variable)))))))
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
==========================================
|
||||
simple declarations
|
||||
==========================================
|
||||
|
||||
int x;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(declaration (type_name (identifier)) (declarator (identifier))))
|
||||
|
||||
==========================================
|
||||
simple functions
|
||||
==========================================
|
||||
|
||||
int main() {
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (function_definition
|
||||
(type_name (identifier))
|
||||
(declarator (identifier))
|
||||
(compound_statement)))
|
||||
|
||||
==========================================
|
||||
ambiguous declarations
|
||||
==========================================
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
someTypeOrValue * pointerOrMultiplicand();
|
||||
float y;
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (function_definition
|
||||
(type_name (identifier))
|
||||
(declarator (identifier))
|
||||
(compound_statement
|
||||
(declaration (type_name (identifier)) (declarator (identifier)))
|
||||
(declaration (type_name (identifier)) (declarator (pointer) (identifier)))
|
||||
(declaration (type_name (identifier)) (declarator (identifier))))))
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
==========================================
|
||||
simple declarations
|
||||
==========================================
|
||||
|
||||
package trivial
|
||||
|
||||
type x int64
|
||||
var y = ""
|
||||
func z() {}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(type_declaration (type_name) (type_name))
|
||||
(var_declaration (var_name) (string))
|
||||
(func_declaration (var_name) (block_statement)))
|
||||
|
||||
==========================================
|
||||
var declarations
|
||||
==========================================
|
||||
|
||||
package trivial
|
||||
|
||||
var X struct { Y int64 }
|
||||
var Z = ""
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(var_declaration (var_name) (struct_type (var_name) (type_name)))
|
||||
(var_declaration (var_name) (string)))
|
||||
|
||||
==========================================
|
||||
comments
|
||||
==========================================
|
||||
|
||||
package trivial
|
||||
|
||||
var x = 1 // on variable
|
||||
|
||||
func main() {
|
||||
// in function
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(var_declaration (var_name) (number) (comment))
|
||||
(func_declaration (var_name) (block_statement (comment))))
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
==========================================
|
||||
indented code after blocks
|
||||
=========================================
|
||||
|
||||
package trivial
|
||||
|
||||
func one() {}
|
||||
func two() {}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(func_declaration (var_name) (block_statement))
|
||||
(func_declaration (var_name) (block_statement)))
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
==========================================
|
||||
function calls
|
||||
==========================================
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
println("1", 2)
|
||||
println()
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(func_declaration (var_name) (block_statement
|
||||
(expression_statement (call_expression (var_name) (string) (number)))
|
||||
(expression_statement (call_expression (var_name))))))
|
||||
|
||||
============================================
|
||||
selector expressions
|
||||
============================================
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
x.SomeMethod(x.SomeField, x.OtherField.NestedField);
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(func_declaration (var_name) (block_statement
|
||||
(expression_statement (call_expression
|
||||
(selector_expression (var_name) (var_name))
|
||||
(selector_expression (var_name) (var_name))
|
||||
(selector_expression (selector_expression (var_name) (var_name)) (var_name)))))))
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
============================================
|
||||
return statements
|
||||
============================================
|
||||
package main
|
||||
|
||||
func main() {
|
||||
return
|
||||
}
|
||||
|
||||
func helper() {
|
||||
return 1, two, "three"
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (package_directive (package_name))
|
||||
(func_declaration (var_name) (block_statement
|
||||
(return_statement)))
|
||||
(func_declaration (var_name) (block_statement
|
||||
(return_statement (number) (var_name) (string)))))
|
||||
|
||||
============================================
|
||||
variable declarations
|
||||
============================================
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
x, y := stuff()
|
||||
var z = 10
|
||||
println(x, y, z)
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (package_directive (package_name))
|
||||
(func_declaration (var_name) (block_statement
|
||||
(short_var_declaration (var_name) (var_name) (call_expression (var_name)))
|
||||
(var_declaration (var_name) (number))
|
||||
(expression_statement (call_expression (var_name) (var_name) (var_name) (var_name))))))
|
||||
|
||||
============================================
|
||||
if statements
|
||||
============================================
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
if condition1() {
|
||||
}
|
||||
|
||||
if condition2() {
|
||||
} else {
|
||||
}
|
||||
|
||||
if condition3() {
|
||||
} else if condition4() {
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (package_directive (package_name))
|
||||
(func_declaration (var_name) (block_statement
|
||||
(if_statement (call_expression (var_name))
|
||||
(block_statement))
|
||||
(if_statement (call_expression (var_name))
|
||||
(block_statement) (block_statement))
|
||||
(if_statement (call_expression (var_name))
|
||||
(block_statement)
|
||||
(if_statement (call_expression (var_name))
|
||||
(block_statement))))))
|
||||
|
||||
=============================================
|
||||
range statements
|
||||
=============================================
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
for k := range theMap() {
|
||||
println(k)
|
||||
}
|
||||
|
||||
for k, v := range theMap() {
|
||||
println(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program (package_directive (package_name))
|
||||
(func_declaration (var_name) (block_statement
|
||||
(range_statement (var_name) (call_expression (var_name)) (block_statement
|
||||
(expression_statement (call_expression (var_name) (var_name)))))
|
||||
(range_statement (var_name) (var_name) (call_expression (var_name)) (block_statement
|
||||
(expression_statement (call_expression (var_name) (var_name) (var_name))))))))
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
==========================================
|
||||
composite types
|
||||
==========================================
|
||||
|
||||
package main
|
||||
|
||||
type x *struct {
|
||||
field1 []int64
|
||||
field2 map[string]interface{
|
||||
DoStuff()
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(type_declaration
|
||||
(type_name)
|
||||
(pointer_type (struct_type
|
||||
(var_name) (slice_type (type_name))
|
||||
(var_name) (map_type (type_name) (interface_type (var_name)))))))
|
||||
|
||||
============================================
|
||||
functions arguments
|
||||
============================================
|
||||
|
||||
package main
|
||||
|
||||
func oneArg(arg1 interface{}) {}
|
||||
func argsOfSameType(arg1, arg2 string) {}
|
||||
func argsOfDifferentTypes() (arg1 string, arg2 int64) {}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(func_declaration (var_name) (var_name) (interface_type) (block_statement))
|
||||
(func_declaration (var_name) (var_name) (var_name) (type_name) (block_statement))
|
||||
(func_declaration (var_name) (var_name) (type_name) (var_name) (type_name) (block_statement)))
|
||||
|
||||
============================================
|
||||
functions with unnamed return values
|
||||
============================================
|
||||
|
||||
package main
|
||||
|
||||
func oneReturnValue() string {}
|
||||
func multipleReturnValues() (string, int64, error) {}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(func_declaration (var_name) (type_name)
|
||||
(block_statement))
|
||||
(func_declaration (var_name) (type_name) (type_name) (type_name)
|
||||
(block_statement)))
|
||||
|
||||
============================================
|
||||
functions with named return values
|
||||
============================================
|
||||
|
||||
package main
|
||||
|
||||
func oneReturnValue() (result string) {}
|
||||
func multipleReturnValues() (result string, count int64, err error) {}
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(func_declaration (var_name) (var_name) (type_name)
|
||||
(block_statement))
|
||||
(func_declaration (var_name) (var_name) (type_name) (var_name) (type_name) (var_name) (type_name)
|
||||
(block_statement)))
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
==========================================
|
||||
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)))))))
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
==========================================
|
||||
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))))
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
==========================================
|
||||
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))))
|
||||
|
|
@ -1,177 +0,0 @@
|
|||
==========================================
|
||||
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)))))))
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
==========================================
|
||||
top-level errors
|
||||
==========================================
|
||||
|
||||
[}
|
||||
|
||||
---
|
||||
|
||||
(ERROR (UNEXPECTED '}'))
|
||||
|
||||
==========================================
|
||||
unexpected tokens
|
||||
==========================================
|
||||
|
||||
barf
|
||||
|
||||
---
|
||||
|
||||
(ERROR (UNEXPECTED 'b'))
|
||||
|
||||
==========================================
|
||||
errors inside arrays
|
||||
==========================================
|
||||
|
||||
[1, , 2]
|
||||
|
||||
---
|
||||
(array
|
||||
(number)
|
||||
(ERROR (UNEXPECTED ','))
|
||||
(number))
|
||||
|
||||
==========================================
|
||||
errors inside objects
|
||||
==========================================
|
||||
|
||||
{ "key1": 1, oops }
|
||||
|
||||
---
|
||||
|
||||
(object (string) (number) (ERROR (UNEXPECTED 'o')))
|
||||
|
||||
==========================================
|
||||
errors inside nested objects
|
||||
==========================================
|
||||
|
||||
{ "key1": { "key2": 1, 2 }, [, "key3": 3 }
|
||||
|
||||
---
|
||||
|
||||
(object
|
||||
(string) (object
|
||||
(string) (number)
|
||||
(ERROR (UNEXPECTED '2') (number)))
|
||||
(ERROR (UNEXPECTED '['))
|
||||
(string) (number))
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
=============================
|
||||
floating point numbers
|
||||
=============================
|
||||
|
||||
3.14
|
||||
|
||||
---
|
||||
|
||||
(number)
|
||||
|
||||
===================
|
||||
empty arrays
|
||||
===================
|
||||
|
||||
[]
|
||||
|
||||
---
|
||||
|
||||
(array)
|
||||
|
||||
===================
|
||||
arrays
|
||||
===================
|
||||
|
||||
[
|
||||
333,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
{ "stuff": "good" }
|
||||
]
|
||||
|
||||
---
|
||||
|
||||
(array
|
||||
(number)
|
||||
(null)
|
||||
(true)
|
||||
(false)
|
||||
(object (string) (string)))
|
||||
|
||||
====================
|
||||
empty objects
|
||||
====================
|
||||
|
||||
{}
|
||||
|
||||
---
|
||||
|
||||
(object)
|
||||
|
||||
===================
|
||||
long objects
|
||||
===================
|
||||
|
||||
{
|
||||
"key1": "value1",
|
||||
"key2": 1
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(object
|
||||
(string) (string)
|
||||
(string) (number))
|
||||
Loading…
Add table
Add a link
Reference in a new issue