Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisma committed Jan 8, 2024
1 parent 9fb4fb3 commit 4eca527
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rds
**/.skillide.*
*.ils~
*.il~
tests/lint_reports
test/

# Virtue environment initialization scripts
virtue/virtue-environment.cdsinit.ils
Expand Down
34 changes: 33 additions & 1 deletion tests/data_types/test_Dpl.ils
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
let(((Dpl VrtImport['Dpl])
(Test VrtImport['Test])
(Virtue VrtImport['Virtue])
(example_dpl list(nil 'key1 "value1" 'key3 "value2"))
(example_dpl list(nil 'key1 "value1" 'key2 "value2"))
(example_dpl2 list(nil 'key3 "value3" 'key4 "value4"))
)

procedure(test_PropertyTable()
Expand All @@ -13,9 +14,40 @@ procedure(test_PropertyTable()
assert(table['key2] == "value2")
))

procedure(test_Cat()
let((ans)
ans = Dpl->Cat(example_dpl example_dpl2)
assert(listp(ans))
assert(length(ans) == 4)
assert(ans->key1 == "value1")
assert(ans->key2 == "value2")
assert(ans->key3 == "value3")
assert(ans->key4 == "value4")
))

procedure(test_lint_Dpl()
assert(sklint(
?file "/prj/ids_dev/work_libs/mayberc/skill/virtue/virtue/data_types/Dpl.ils"
?outputFile "/prj/ids_dev/work_libs/mayberc/skill/virtue/test/lint_report_Dpl.txt"
?prefixes '(Vrt VrtImport)
))
)

procedure(test_lint_test_Dpl()
createDirHier("/prj/ids_dev/work_libs/mayberc/skill/virtue/test/data_types")
assert(sklint(
?file "/prj/ids_dev/work_libs/mayberc/skill/virtue/tests/data_types/test_Dpl.ils"
?outputFile "/prj/ids_dev/work_libs/mayberc/skill/virtue/test/lint_report_test_Dpl.txt"
?prefixes '(Vrt VrtImport)
))
)

Test->RunFile(list(nil

'test_PropertyTable test_PropertyTable
'test_Cat test_Cat
'test_lint_Dpl test_lint_Dpl
'test_lint_test_Dpl test_lint_test_Dpl
)
?filepath Virtue->GetCurrentFilePath()
)
Expand Down
24 changes: 24 additions & 0 deletions tests/data_types/test_Lcv.ils
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ let(((Lcv VrtImport['Lcv])
(Virtue VrtImport['Virtue])
)

; Fixtures

procedure(lcv_list()
list("lib_name" "cell_name" "view_name")
)
Expand All @@ -14,6 +16,8 @@ procedure(lcvh_list()
Test->Fixtures['lcv_list] = lcv_list
Test->Fixtures['lcvh_list] = lcvh_list

; Tests

procedure(Test_lib(lcv_list, lcvh_list)
assert(Lcv->lib(lcv_list) == "lib_name")
assert(Lcv->lib(lcvh_list) == "lib_name")
Expand All @@ -33,10 +37,30 @@ procedure(Test_history(lcvh_list)
assert(Lcv->view(lcvh_list) == "history_name")
)

procedure(Test_lint_Lcv()
assert(sklint(
?file "/prj/ids_dev/work_libs/mayberc/skill/virtue/virtue/data_types/Lcv.ils"
?outputFile "/prj/ids_dev/work_libs/mayberc/skill/virtue/test/lint_report_Lcv.txt"
?prefixes '(Vrt VrtImport)
))
)

procedure(Test_lint_Test_Lcv()
assert(sklint(
?file "/prj/ids_dev/work_libs/mayberc/skill/virtue/tests/data_types/test_Lcv.ils"
?outputFile "/prj/ids_dev/work_libs/mayberc/skill/virtue/test/lint_report_test_Lcv.txt"
?prefixes '(Vrt VrtImport)
))
)


Test->RunFile(list(nil
'Test_lib Test_lib
'Test_cell Test_cell
'Test_view Test_view
'Test_history Test_history
'Test_lint_Lcv Test_lint_Lcv
'Test_lint_Test_Lcv Test_lint_Test_Lcv
)
?filepath Virtue->GetCurrentFilePath()
)
Expand Down
18 changes: 18 additions & 0 deletions tests/data_types/test_List.ils
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,30 @@ procedure(Test_assocKeys()
assert(!List->assocKeys(nil))
)

procedure(Test_lint_List()
assert(sklint(
?file "/prj/ids_dev/work_libs/mayberc/skill/virtue/virtue/data_types/List.ils"
?outputFile "/prj/ids_dev/work_libs/mayberc/skill/virtue/test/lint_report_List.txt"
?prefixes '(Vrt VrtImport)
))
)

procedure(Test_lint_test_List()
assert(sklint(
?file "/prj/ids_dev/work_libs/mayberc/skill/virtue/tests/data_types/test_List.ils"
?outputFile "/prj/ids_dev/work_libs/mayberc/skill/virtue/test/lint_report_test_List.txt"
?prefixes '(Vrt VrtImport)
))
)

Test->RunFile(list(nil
'Test_ensure Test_ensure
'Test_setDiff Test_setDiff
'Test_uniqueList Test_uniqueList
'Test_uniqueListOrdered Test_uniqueListOrdered
'Test_assocKeys Test_assocKeys
'Test_lint_List Test_lint_List
'Test_lint_test_List Test_lint_test_List
)
?filepath Virtue->GetCurrentFilePath()
)
Expand Down
104 changes: 104 additions & 0 deletions tests/data_types/test_Path.ils
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
let(((Path VrtImport['Path])
(Test VrtImport['Test])
(Virtue VrtImport['Virtue])
)

; Fixtures
; --------

procedure(directory_path()
Path->Concat("/absolute" "path" "to" "a" "directory")
)

procedure(file_path()
Path->Concat("/absolute" "path" "to" "a" "file.txt")
)

Test->Fixtures['directory_path] = directory_path
Test->Fixtures['file_path] = file_path

; Tests
; -----

procedure(Test_PathConcat()
assert(Path->Concat("/absolute" "path" "to" "a" "directory") ==
"/absolute/path/to/a/directory")
assert(Path->Concat("" "absolute" "path" "to" "a" "directory") ==
"/absolute/path/to/a/directory")
assert(Path->Concat("/absolute" "path" "to" "a" "file.txt") ==
"/absolute/path/to/a/file.txt")
)

procedure(Test_PathCat()
assert(Path->Cat("/absolute" "path" "to" "a" "directory") ==
"/absolute/path/to/a/directory")
assert(Path->Cat("" "absolute" "path" "to" "a" "directory") ==
"/absolute/path/to/a/directory")
assert(Path->Cat("/absolute" "path" "to" "a" "file.txt") ==
"/absolute/path/to/a/file.txt")
)

procedure(Test_FileName(file_path directory_path)
assert(Path->FileName(file_path) == "file.txt")
assert(Path->FileName(directory_path) == "directory")
)

procedure(Test_Folder(file_path directory_path)
assert(Path->FileName(file_path) == "/absolute/path/to/a")
assert(Path->FileName(directory_path) == "/absolute/path/to/a")
)

procedure(Test_RemoveExtension(file_path)
assert(Path->RemoveExtension(file_path) == "/absolute/path/to/a/file")
assert(Path->RemoveExtension(directory_path) == "/absolute/path/to/a/directory")
assert(Path->RemoveExtension("file.ext") == "file")
)

procedure(Test_UpdateExtension(file_path)
assert(Path->UpdateExtension(file_path "new") == "/absolute/path/to/a/file.new")
assert(Path->UpdateExtension(directory_path "new") == "/absolute/path/to/a/directory.new")
assert(Path->UpdateExtension("file.ext" "new") == "file.new")
)

procedure(Test_FileExtension(file_path)
assert(Path->FileExtension(file_path) == "txt")
assert(Path->FileExtension(directory_path) == "")
assert(Path->FileExtension("file.ext") == "ext")
assert(Path->FileExtension("file.myext") == "myext")
)

procedure(Test_lint_Path(lint_settings)
assert(sklint(
?file Path->Cat(lint_settings->testsDir
"data_types/Path.ils")
?outputFile Path->Cat(lint_settings->outputDir
"lint_report_Path.txt")
?prefixes lint_settings->prefixes
))
)

procedure(Test_lint_Test_Path(lint_settings)
assert(sklint(
?file Path->Cat(lint_settings->testsDir
"data_types/test_Path.ils")
?outputFile Path->Cat(lint_settings->outputDir
"lint_report_test_Path.txt")
?prefixes lint_settings->prefixes
))
)

Test->RunFile(list(nil
'Test_PathConcat Test_PathConcat
'Test_PathCat Test_PathCat
'Test_FileName Test_FileName
'Test_Folder Test_Folder
'Test_RemoveExtension Test_RemoveExtension
'Test_UpdateExtension Test_UpdateExtension
'Test_FileExtension Test_FileExtension
'Test_lint_Path Test_lint_Path
'Test_lint_Test_Path Test_lint_Test_Path
)
?filepath Virtue->GetCurrentFilePath()
)

)
15 changes: 8 additions & 7 deletions tests/data_types/test_Str.ils
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ procedure(Test_prefixp()
assert(!Str->prefixp("no" "pre"))
)

procedure(Test_PathConcat()
assert(Path->Concat("/absolute" "path" "to" "a" "directory") ==
"/absolute/path/to/a/directory")
assert(Path->Concat("" "absolute" "path" "to" "a" "directory") ==
"/absolute/path/to/a/directory")
assert(Path->Concat("/absolute" "path" "to" "a" "file.txt") ==
"/absolute/path/to/a/file.txt")
procedure(Test_lint_Str(lint_settings)
assert(lint_settings->RunLint("../virtue/Str.ils"))
)

procedure(Test_lint_test_Str(lint_settings)
assert(lint_settings->RunLint("data_types/test_Str.ils"))
)

Test->RunFile(list(nil
Expand All @@ -110,6 +109,8 @@ Test->RunFile(list(nil
'Test_startsWith Test_startsWith
'Test_endsWith Test_endsWith
'Test_prefixp Test_prefixp
'Test_lint_Str Test_lint_Str
'Test_lint_test_Str Test_lint_test_Str
)
?filepath Virtue->GetCurrentFilePath()
)
Expand Down
31 changes: 0 additions & 31 deletions tests/data_types/test_path.ils

This file was deleted.

35 changes: 0 additions & 35 deletions tests/lint_report.txt

This file was deleted.

47 changes: 44 additions & 3 deletions tests/run_tests.ils
Original file line number Diff line number Diff line change
@@ -1,9 +1,50 @@
let((dir_path
(Test VrtImport['Test])
(Path VrtImport['Path])
(Virtue VrtImport['Virtue])
(Str VrtImport['Str])
)

dir_path = Virtue->GetCurrentFileDirectory()
Test->RunDirectory(dir_path)

dir_path = Virtue->GetCurrentFileDirectory()
dir_path = Path->Cat(dir_path)

; Shared Test Fixtures
; --------------------

procedure(lint_settings()
"Test"
let(((outputDir simplifyFilename(Path->Cat(dir_path "../test")))
(prefixes '(Vrt VrtImport))
)


createDirHier(Path->Cat(outputDir "data_types"))

procedure(RunLint(relativeFilePath)
"Run lint on a file relative to the tests directory"
; funcall is necessary since sklint is an nlambda function and
; selectively evaluates the args in the function rather than
; within the lexical env before the function call.
funcall(sklint
?file Path->Cat(dir_path relativeFilePath)
?outputFile Path->Cat(outputDir strcat(
"lint_report_"
Path->RemoveExtension(Path->FileName(relativeFilePath))
".txt"))
?prefixes prefixes
)
)

list(nil
'RunLint RunLint
'outputDir outputDir
'prefixes prefixes
'testsDir dir_path
)
))

Test->Fixtures['lint_settings] = lint_settings

Test->RunDirectory(Path->Cat(dir_path "data_types"))
;Test->RunDirectory(dir_path)
)
Loading

0 comments on commit 4eca527

Please sign in to comment.