67 lines
1.6 KiB
Plaintext
67 lines
1.6 KiB
Plaintext
|
|
;- Compiler Directives
|
|
EnableExplicit
|
|
|
|
;XIncludeFile "../Commons/HashMap/HashMap.pbi"
|
|
XIncludeFile "./test/Object.pbi"
|
|
|
|
|
|
#DefsFolder = "C:\Users\Herwin\Desktop\Projects\Yass13"
|
|
|
|
|
|
;- Tests
|
|
|
|
; Parses every definition file in the given folder, returns #False if any of them failed.
|
|
Procedure.b Test_ParseDefsFolder(Folder.s)
|
|
Protected Directory.i
|
|
Protected FilePath.s
|
|
Protected *Object.YassObject
|
|
Protected Success.b = #True
|
|
|
|
Directory = ExamineDirectory(#PB_Any, Folder, "*.ini")
|
|
If Not Directory
|
|
PrintN("FAIL: Can't examine folder: " + Folder)
|
|
ProcedureReturn #False
|
|
EndIf
|
|
|
|
While NextDirectoryEntry(Directory)
|
|
If DirectoryEntryType(Directory) <> #PB_DirectoryEntry_File
|
|
Continue
|
|
EndIf
|
|
|
|
FilePath = Folder + DirectoryEntryName(Directory)
|
|
*Object = FromDefinitionFile(FilePath)
|
|
|
|
If *Object = #Null
|
|
PrintN("FAIL: " + FilePath)
|
|
Success = #False
|
|
Else
|
|
PrintN("OK: " + FilePath + " -> '" + *Object\Id + "' (" + *Object\Type + ")")
|
|
FreeYassObject(*Object)
|
|
EndIf
|
|
Wend
|
|
|
|
FinishDirectory(Directory)
|
|
ProcedureReturn Success
|
|
EndProcedure
|
|
|
|
|
|
;- Entry Point
|
|
|
|
If Not OpenConsole("YASS13")
|
|
DebuggerError("Failed to open console !")
|
|
End 1
|
|
EndIf
|
|
|
|
Define TestsPassed.b = #True
|
|
If Not Test_ParseDefsFolder(#DefsFolder + "\defs\items\") : TestsPassed = #False : EndIf
|
|
If Not Test_ParseDefsFolder(#DefsFolder + "\defs\reagents\") : TestsPassed = #False : EndIf
|
|
|
|
If Not TestsPassed
|
|
DebuggerError("Definition parsing tests failed !")
|
|
End 1
|
|
EndIf
|
|
|
|
|
|
Debug "Done :)"
|