Add test case for skimming

This commit is contained in:
Sasha Koshka 2022-09-05 14:52:37 -04:00
parent 2295e3bd32
commit cc1eaa2c11
9 changed files with 73 additions and 8 deletions

View File

@ -3,7 +3,7 @@ package parser
import "testing"
func TestData (test *testing.T) {
checkTree ("../tests/parser/data",
checkTree ("../tests/parser/data", false,
`:arf
---
data ro aInteger:Int 3202

View File

@ -3,7 +3,7 @@ package parser
import "testing"
func TestEnum (test *testing.T) {
checkTree ("../tests/parser/enum",
checkTree ("../tests/parser/enum", false,
`:arf
---
enum ro AffrontToGod:Int:4

View File

@ -3,7 +3,7 @@ package parser
import "testing"
func TestFunc (test *testing.T) {
checkTree ("../tests/parser/func",
checkTree ("../tests/parser/func", false,
`:arf
---
func ro aBasicExternal

View File

@ -3,7 +3,7 @@ package parser
import "testing"
func TestMeta (test *testing.T) {
checkTree ("../tests/parser/meta",
checkTree ("../tests/parser/meta", false,
`:arf
author "Sasha Koshka"
license "GPLv3"

View File

@ -3,7 +3,7 @@ package parser
import "testing"
func TestObjt (test *testing.T) {
checkTree ("../tests/parser/objt",
checkTree ("../tests/parser/objt", false,
`:arf
---
objt ro Basic:Obj

27
parser/skim_test.go Normal file
View File

@ -0,0 +1,27 @@
package parser
import "testing"
func TestSkim (test *testing.T) {
checkTree ("../tests/parser/skim", true,
`:arf
---
data ro aExternalData:Int
external
data ro bSingleValue:Int
external
data ro cNestedObject:Obj
external
data ro dUninitialized:Int:16:mut
external
data ro eIntegerArrayInitialized:Int:16:mut
external
func ro fComplexFunction
---
external
func ro gExternalFunction
> x:Int
---
external
`, test)
}

View File

@ -6,11 +6,11 @@ import "strings"
import "testing"
import "path/filepath"
func checkTree (modulePath string, correct string, test *testing.T) {
func checkTree (modulePath string, skim bool, correct string, test *testing.T) {
cwd, _ := os.Getwd()
modulePath = filepath.Join(cwd, modulePath)
println(modulePath)
tree, err := Fetch(modulePath, false)
tree, err := Fetch(modulePath, skim)
treeString := tree.ToString(0)
treeRunes := []rune(treeString)

View File

@ -3,7 +3,7 @@ package parser
import "testing"
func TestType (test *testing.T) {
checkTree ("../tests/parser/type",
checkTree ("../tests/parser/type", false,
`:arf
---
type ro Basic:Int

View File

@ -0,0 +1,38 @@
:arf
---
data ro aExternalData:Int
external
data ro bSingleValue:Int 342
data ro cNestedObject:Obj
.this
.bird0 324
.bird1 "hello world"
.that
.bird2 123.8439
.bird3 9328.21348239
data ro dUninitialized:Int:16:mut
data ro eIntegerArrayInitialized:Int:16:mut
3948 293 293049 948 912
340 0 2304 0 4785 92
func ro fComplexFunction
---
= x:Int 3
= y:{Int} [loc x]
= z:Int:8
398 9 2309 983 -2387
478 555 123
= bird:Bird
.that
.whenYou 99999
.this 324
func ro gExternalFunction
> x:Int
---
external