init
This commit is contained in:
75
test/corpus/booleans.txt
Normal file
75
test/corpus/booleans.txt
Normal file
@@ -0,0 +1,75 @@
|
||||
===============================================================================
|
||||
Booleans
|
||||
===============================================================================
|
||||
|
||||
func boolean() bool {
|
||||
right = true;
|
||||
wrong = false;
|
||||
right_or_wrong = right || wrong;
|
||||
right_and_wrong = right && wrong;
|
||||
return true;
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
(identifier)
|
||||
(parameters)
|
||||
(primitive_type)
|
||||
(block
|
||||
(assign_statement
|
||||
(identifier)
|
||||
(boolean_literal))
|
||||
(assign_statement
|
||||
(identifier)
|
||||
(boolean_literal))
|
||||
(assign_statement
|
||||
(identifier)
|
||||
(binary_expression
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(assign_statement
|
||||
(identifier)
|
||||
(binary_expression
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(return_statement (boolean_literal)))))
|
||||
|
||||
===============
|
||||
literal 'true'
|
||||
===============
|
||||
|
||||
func a() bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
(identifier)
|
||||
(parameters)
|
||||
(primitive_type)
|
||||
(block
|
||||
(return_statement
|
||||
(boolean_literal)))))
|
||||
|
||||
===============================================================================
|
||||
literal 'false'
|
||||
===============================================================================
|
||||
|
||||
func a() bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
(identifier)
|
||||
(parameters)
|
||||
(primitive_type)
|
||||
(block
|
||||
(return_statement
|
||||
(boolean_literal)))))
|
114
test/corpus/function_parameters.txt
Normal file
114
test/corpus/function_parameters.txt
Normal file
@@ -0,0 +1,114 @@
|
||||
===============================================================================
|
||||
No parameters
|
||||
===============================================================================
|
||||
|
||||
func one() int {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
return_type: (primitive_type)
|
||||
body: (block)))
|
||||
|
||||
===============================================================================
|
||||
1 parameter
|
||||
===============================================================================
|
||||
|
||||
func one(x int) int {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters
|
||||
(parameter
|
||||
(identifier)
|
||||
(primitive_type)))
|
||||
return_type: (primitive_type)
|
||||
body: (block)))
|
||||
|
||||
===============================================================================
|
||||
1 parameter with trailing comma
|
||||
===============================================================================
|
||||
|
||||
func one(
|
||||
x int,
|
||||
) int {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters
|
||||
(parameter
|
||||
(identifier)
|
||||
(primitive_type)))
|
||||
return_type: (primitive_type)
|
||||
body: (block)))
|
||||
|
||||
===============================================================================
|
||||
2 parameters
|
||||
===============================================================================
|
||||
|
||||
func one(x int, y int) int {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters
|
||||
(parameter
|
||||
(identifier)
|
||||
(primitive_type))
|
||||
(parameter
|
||||
(identifier)
|
||||
(primitive_type)))
|
||||
return_type: (primitive_type)
|
||||
body: (block)))
|
||||
|
||||
===============================================================================
|
||||
2 parameters with trailing comma
|
||||
===============================================================================
|
||||
|
||||
func one(
|
||||
x int,
|
||||
y int,
|
||||
) int {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters
|
||||
(parameter
|
||||
(identifier)
|
||||
(primitive_type))
|
||||
(parameter
|
||||
(identifier)
|
||||
(primitive_type)))
|
||||
return_type: (primitive_type)
|
||||
body: (block)))
|
||||
|
||||
===============================================================================
|
||||
[Error] No space between parameter name and type
|
||||
===============================================================================
|
||||
|
||||
func one(xint) int {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters
|
||||
(ERROR
|
||||
(identifier)))
|
||||
return_type: (primitive_type)
|
||||
body: (block)))
|
95
test/corpus/if.txt
Normal file
95
test/corpus/if.txt
Normal file
@@ -0,0 +1,95 @@
|
||||
====================================================
|
||||
if statement
|
||||
====================================================
|
||||
|
||||
func main() {
|
||||
if true {
|
||||
false
|
||||
};
|
||||
}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
body: (block
|
||||
(if_statement
|
||||
condition: (boolean_literal)
|
||||
body: (block
|
||||
(boolean_literal))))))
|
||||
|
||||
====================================================
|
||||
if else expression
|
||||
====================================================
|
||||
|
||||
func main() {
|
||||
return if true {
|
||||
false
|
||||
} else {
|
||||
true
|
||||
};
|
||||
}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
body: (block
|
||||
(return_statement
|
||||
(if_expression
|
||||
condition: (boolean_literal)
|
||||
body: (block
|
||||
(boolean_literal))
|
||||
else: (block
|
||||
(boolean_literal)))))))
|
||||
|
||||
====================================================
|
||||
if else expression (no brackets in else)
|
||||
====================================================
|
||||
|
||||
func main() {
|
||||
return if true {
|
||||
false
|
||||
} else true;
|
||||
}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
body: (block
|
||||
(return_statement
|
||||
(if_expression
|
||||
condition: (boolean_literal)
|
||||
body: (block
|
||||
(boolean_literal))
|
||||
else: (boolean_literal))))))
|
||||
|
||||
====================================================
|
||||
[Error] if expression (missing else)
|
||||
====================================================
|
||||
|
||||
func main() {
|
||||
return if true {
|
||||
false
|
||||
};
|
||||
}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
body: (block
|
||||
(return_statement
|
||||
(ERROR
|
||||
(boolean_literal)
|
||||
(block
|
||||
(boolean_literal)))))))
|
56
test/corpus/return.txt
Normal file
56
test/corpus/return.txt
Normal file
@@ -0,0 +1,56 @@
|
||||
===============================================================================
|
||||
Return int literal
|
||||
===============================================================================
|
||||
|
||||
func x() int {
|
||||
return 1;
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
return_type: (primitive_type)
|
||||
body:
|
||||
(block
|
||||
(return_statement (integer_literal)))))
|
||||
|
||||
===============================================================================
|
||||
Return nothing
|
||||
===============================================================================
|
||||
|
||||
func x() int {
|
||||
return;
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
return_type: (primitive_type)
|
||||
body:
|
||||
(block
|
||||
(return_statement))))
|
||||
|
||||
===============================================================================
|
||||
[Error] Return nothing with missing ';'
|
||||
===============================================================================
|
||||
|
||||
func x() int {
|
||||
return
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
return_type: (primitive_type)
|
||||
body:
|
||||
(block
|
||||
(ERROR))))
|
30
test/corpus/return_types.txt
Normal file
30
test/corpus/return_types.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
===============================================================================
|
||||
int return type
|
||||
===============================================================================
|
||||
|
||||
func a() int {
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
return_type: (primitive_type)
|
||||
body: (block)))
|
||||
|
||||
===============================================================================
|
||||
No return type
|
||||
===============================================================================
|
||||
|
||||
func a() {
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(function_definition
|
||||
name: (identifier)
|
||||
parameters: (parameters)
|
||||
body: (block)))
|
Reference in New Issue
Block a user