native test framework
This commit is contained in:
@@ -40,7 +40,9 @@ module.exports = grammar({
|
||||
|
||||
_top_level_declaration: $ => choice(
|
||||
$.import_declaration,
|
||||
$.test_import_declaration,
|
||||
$.function_declaration,
|
||||
$.test_declaration,
|
||||
$.type_declaration,
|
||||
$.global_constant_declaration,
|
||||
$.global_variable_declaration,
|
||||
@@ -53,6 +55,20 @@ module.exports = grammar({
|
||||
field('path', $.string),
|
||||
),
|
||||
|
||||
test_import_declaration: $ => seq(
|
||||
'test',
|
||||
'import',
|
||||
repeat($._newline),
|
||||
field('path', $.string),
|
||||
),
|
||||
|
||||
test_declaration: $ => seq(
|
||||
field('name', $.identifier),
|
||||
'test',
|
||||
repeat($._newline),
|
||||
field('body', $.block),
|
||||
),
|
||||
|
||||
function_declaration: $ => seq(
|
||||
optional('hide'),
|
||||
field('name', $.identifier),
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
(type_declaration name: (identifier) @type)
|
||||
(function_declaration name: (identifier) @function)
|
||||
(test_declaration name: (identifier) @function)
|
||||
(parameter name: (identifier) @variable.parameter)
|
||||
|
||||
(intrinsic_call_expression function: (identifier) @function.builtin)
|
||||
@@ -53,6 +54,7 @@
|
||||
|
||||
[
|
||||
"func"
|
||||
"test"
|
||||
"c_func"
|
||||
"struct"
|
||||
"c_struct"
|
||||
|
||||
@@ -26,10 +26,18 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "import_declaration"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "test_import_declaration"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "function_declaration"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "test_declaration"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "type_declaration"
|
||||
@@ -100,6 +108,66 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"test_import_declaration": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "test"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "import"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "path",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "string"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"test_declaration": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "name",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "test"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "body",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "block"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"function_declaration": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
||||
@@ -1852,6 +1852,14 @@
|
||||
"type": "import_declaration",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "test_declaration",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "test_import_declaration",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "type_declaration",
|
||||
"named": true
|
||||
@@ -2000,6 +2008,48 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "test_declaration",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"body": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "test_import_declaration",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"path": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "string",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "tuple_literal",
|
||||
"named": true,
|
||||
@@ -2737,6 +2787,10 @@
|
||||
"type": "struct",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "true",
|
||||
"named": false
|
||||
|
||||
+140359
-139633
File diff suppressed because it is too large
Load Diff
@@ -364,7 +364,30 @@ main func() void {
|
||||
(expression
|
||||
(sink))
|
||||
(expression
|
||||
(identifier))))))))))
|
||||
(identifier))))))))))
|
||||
|
||||
==================
|
||||
Native tests
|
||||
==================
|
||||
|
||||
math :: import "../math"
|
||||
test import "../math"
|
||||
|
||||
addition test {}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(import_declaration
|
||||
(identifier)
|
||||
(string
|
||||
(string_content)))
|
||||
(test_import_declaration
|
||||
(string
|
||||
(string_content)))
|
||||
(test_declaration
|
||||
(identifier)
|
||||
(block)))
|
||||
|
||||
==================
|
||||
Expanded match arms
|
||||
@@ -373,7 +396,7 @@ Expanded match arms
|
||||
Kind :: enum { one, two }
|
||||
Value :: union(enum) { number i32, empty void }
|
||||
|
||||
test func(kind Kind, value Value) void {
|
||||
visit func(kind Kind, value Value) void {
|
||||
match kind {
|
||||
.one: {}
|
||||
expand |tag|: _ = tag
|
||||
|
||||
Reference in New Issue
Block a user