From cc1eaa2c111d3f7b5e72f5c03793c017ff7aa3a2 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 5 Sep 2022 14:52:37 -0400 Subject: [PATCH] Add test case for skimming --- parser/data_test.go | 2 +- parser/enum_test.go | 2 +- parser/func_test.go | 2 +- parser/meta_test.go | 2 +- parser/objt_test.go | 2 +- parser/skim_test.go | 27 +++++++++++++++++++++++++++ parser/test-common.go | 4 ++-- parser/type_test.go | 2 +- tests/parser/skim/main.arf | 38 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 parser/skim_test.go create mode 100644 tests/parser/skim/main.arf diff --git a/parser/data_test.go b/parser/data_test.go index aa01b6b..f6b7df3 100644 --- a/parser/data_test.go +++ b/parser/data_test.go @@ -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 diff --git a/parser/enum_test.go b/parser/enum_test.go index a695dfc..bdc57e5 100644 --- a/parser/enum_test.go +++ b/parser/enum_test.go @@ -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 diff --git a/parser/func_test.go b/parser/func_test.go index d7137b3..99facdf 100644 --- a/parser/func_test.go +++ b/parser/func_test.go @@ -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 diff --git a/parser/meta_test.go b/parser/meta_test.go index 36cc1f4..6e6466f 100644 --- a/parser/meta_test.go +++ b/parser/meta_test.go @@ -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" diff --git a/parser/objt_test.go b/parser/objt_test.go index 3a6775a..eda582d 100644 --- a/parser/objt_test.go +++ b/parser/objt_test.go @@ -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 diff --git a/parser/skim_test.go b/parser/skim_test.go new file mode 100644 index 0000000..e00d48e --- /dev/null +++ b/parser/skim_test.go @@ -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) +} diff --git a/parser/test-common.go b/parser/test-common.go index 8a8e918..918a86d 100644 --- a/parser/test-common.go +++ b/parser/test-common.go @@ -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) diff --git a/parser/type_test.go b/parser/type_test.go index 44219bc..db05b06 100644 --- a/parser/type_test.go +++ b/parser/type_test.go @@ -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 diff --git a/tests/parser/skim/main.arf b/tests/parser/skim/main.arf new file mode 100644 index 0000000..d5d389f --- /dev/null +++ b/tests/parser/skim/main.arf @@ -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