calling 'setTimeout' on bad self (cpp class not export)
This commit is contained in:
rusefi 2022-11-06 20:08:25 -05:00
parent b303764a88
commit 80e02de00b
3 changed files with 15 additions and 1 deletions

View File

@ -419,6 +419,11 @@ struct LuaSensor final : public StoredValueSensor {
return m_isRedundant;
}
// do we need method defined exactly on LuaSensor for Luaa to be happy?
void setTimeout(int timeoutMs) override {
StoredValueSensor::setTimeout(timeoutMs);
}
void setRedundant(bool value) {
m_isRedundant = value;
}

View File

@ -77,7 +77,7 @@ public:
void showInfo(const char*) const override { }
void setTimeout(int timeoutMs) {
virtual void setTimeout(int timeoutMs) {
m_timeoutPeriod = MS2NT(timeoutMs);
}

View File

@ -109,6 +109,15 @@ TEST(LuaBasic, ExpectNumOrNilReturnsNothing) {
)"), unexpected);
}
TEST(LuaSensor, Timeout) {
EXPECT_FLOAT_EQ(0.0f, testLuaReturnsNumberOrNil(R"(
function testFunc()
cltSensor = Sensor.new("clt")
cltSensor:setTimeout(3000)
end
)").value_or(0));
}
TEST(SystemLua, ScriptLoads) {
startLua();
}