mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-15 15:19:52 +00:00
Codechange: introduce regression script for GS
This commit is contained in:
@@ -22,3 +22,4 @@
|
||||
|
||||
add_subdirectory(regression)
|
||||
add_subdirectory(stationlist)
|
||||
add_subdirectory(gs)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
include(CreateRegression)
|
||||
create_regression("game"
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/info.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/require.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/result.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test.sav
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
class Regression extends GSInfo {
|
||||
function GetAuthor() { return "OpenTTD GS Developers Team"; }
|
||||
function GetName() { return "Regression"; }
|
||||
function GetShortName() { return "REGR"; }
|
||||
function GetDescription() { return "This runs regression-tests on some commands. On the same map the result should always be the same."; }
|
||||
function GetVersion() { return 1; }
|
||||
function GetAPIVersion() { return "16"; }
|
||||
function GetDate() { return "2026-05-19"; }
|
||||
function CreateInstance() { return "Regression"; }
|
||||
function UseAsRandomAI() { return false; }
|
||||
}
|
||||
|
||||
RegisterGS(Regression());
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
class Regression extends GSController {
|
||||
function Start();
|
||||
};
|
||||
|
||||
|
||||
|
||||
function Regression::TestInit()
|
||||
{
|
||||
print("");
|
||||
print("--TestInit--");
|
||||
print(" Ops: " + this.GetOpsTillSuspend());
|
||||
print(" TickTest: " + this.GetTick());
|
||||
this.Sleep(1);
|
||||
print(" TickTest: " + this.GetTick());
|
||||
print(" Ops: " + this.GetOpsTillSuspend());
|
||||
print(" SetCommandDelay: " + GSController.SetCommandDelay(1));
|
||||
print(" IsValid(vehicle.plane_speed): " + GSGameSettings.IsValid("vehicle.plane_speed"));
|
||||
print(" vehicle.plane_speed: " + GSGameSettings.GetValue("vehicle.plane_speed"));
|
||||
require("require.nut");
|
||||
print(" TestEnum.value1: " + ::TestEnum.value1);
|
||||
print(" test_constant: " + ::test_constant);
|
||||
print(" TestEnum.value2: " + TestEnum.value2);
|
||||
print(" test_constant: " + test_constant);
|
||||
print(" min(6, 3): " + min(6, 3));
|
||||
print(" min(3, 6): " + min(3, 6));
|
||||
print(" max(6, 3): " + max(6, 3));
|
||||
print(" max(3, 6): " + max(3, 6));
|
||||
}
|
||||
|
||||
function Regression::Company()
|
||||
{
|
||||
print("");
|
||||
print("--Company--");
|
||||
|
||||
/* Test GSXXXMode() in scopes */
|
||||
{
|
||||
local test = GSTestMode();
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
{
|
||||
local exec = GSExecMode();
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
print(" GetLastErrorString(): " + GSError.GetLastErrorString());
|
||||
}
|
||||
}
|
||||
|
||||
print(" GetName(): " + GSCompany.GetName(GSCompany.COMPANY_SELF));
|
||||
print(" GetPresidentName(): " + GSCompany.GetPresidentName(GSCompany.COMPANY_SELF));
|
||||
print(" SetPresidentName(): " + GSCompany.SetPresidentName("Regression GS"));
|
||||
print(" GetPresidentName(): " + GSCompany.GetPresidentName(GSCompany.COMPANY_SELF));
|
||||
|
||||
print("");
|
||||
print("--CompanyMode--");
|
||||
|
||||
local company = GSCompanyMode(GSCompany.COMPANY_FIRST);
|
||||
{
|
||||
local test = GSTestMode();
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
{
|
||||
local exec = GSExecMode();
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
print(" SetName(): " + GSCompany.SetName("Regression"));
|
||||
print(" GetLastErrorString(): " + GSError.GetLastErrorString());
|
||||
}
|
||||
}
|
||||
|
||||
print(" GetName(): " + GSCompany.GetName(GSCompany.COMPANY_SELF));
|
||||
print(" GetPresidentName(): " + GSCompany.GetPresidentName(GSCompany.COMPANY_SELF));
|
||||
print(" SetPresidentName(): " + GSCompany.SetPresidentName("Regression GS"));
|
||||
print(" GetPresidentName(): " + GSCompany.GetPresidentName(GSCompany.COMPANY_SELF));
|
||||
}
|
||||
|
||||
function Regression::Start()
|
||||
{
|
||||
this.TestInit();
|
||||
this.Company();
|
||||
|
||||
print("");
|
||||
print("Done...");
|
||||
print("");
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
print(" Required this file");
|
||||
|
||||
const test_constant = 1;
|
||||
|
||||
enum TestEnum {
|
||||
value0,
|
||||
value1,
|
||||
value2
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
--TestInit--
|
||||
Ops: 9988
|
||||
TickTest: 1
|
||||
TickTest: 2
|
||||
Ops: 9990
|
||||
SetCommandDelay: (null : 0x00000000)
|
||||
IsValid(vehicle.plane_speed): true
|
||||
vehicle.plane_speed: 4
|
||||
Required this file
|
||||
TestEnum.value1: 1
|
||||
test_constant: 1
|
||||
TestEnum.value2: 2
|
||||
test_constant: 1
|
||||
min(6, 3): 3
|
||||
min(3, 6): 3
|
||||
max(6, 3): 6
|
||||
max(3, 6): 6
|
||||
|
||||
--Company--
|
||||
SetName(): false
|
||||
SetName(): false
|
||||
SetName(): false
|
||||
SetName(): false
|
||||
GetLastErrorString(): ERR_PRECONDITION_INVALID_COMPANY
|
||||
GetName(): (null : 0x00000000)
|
||||
GetPresidentName(): (null : 0x00000000)
|
||||
SetPresidentName(): false
|
||||
GetPresidentName(): (null : 0x00000000)
|
||||
|
||||
--CompanyMode--
|
||||
SetName(): true
|
||||
SetName(): true
|
||||
SetName(): true
|
||||
SetName(): false
|
||||
GetLastErrorString(): ERR_NAME_IS_NOT_UNIQUE
|
||||
GetName(): Regression
|
||||
GetPresidentName(): S. G. Bloggs
|
||||
SetPresidentName(): true
|
||||
GetPresidentName(): Regression GS
|
||||
|
||||
Done...
|
||||
|
||||
ERROR: The script died unexpectedly.
|
||||
Binary file not shown.
Reference in New Issue
Block a user