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

View File

@ -419,6 +419,11 @@ struct LuaSensor final : public StoredValueSensor {
return m_isRedundant; 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) { void setRedundant(bool value) {
m_isRedundant = value; m_isRedundant = value;
} }

View File

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

View File

@ -109,6 +109,15 @@ TEST(LuaBasic, ExpectNumOrNilReturnsNothing) {
)"), unexpected); )"), 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) { TEST(SystemLua, ScriptLoads) {
startLua(); startLua();
} }