#[cfg(test)]
mod test {
use crate::{DiagnosticCode, VirtualWorkspace};
#[test]
fn test_issue_392() {
let mut ws = VirtualWorkspace::new();
assert!(ws.check_code_for(DiagnosticCode::UnnecessaryIf,
r#"
local a = false ---@type boolean|nil
if a == nil or a then -- Unnecessary `if` statement: this condition is always truthy [unnecessary-if]
print('a is not false')
end
"#
));
}
#[test]
fn test_issue_396() {
let mut ws = VirtualWorkspace::new();
assert!(ws.check_code_for(DiagnosticCode::UnnecessaryIf,
r#"
local a = false ---@type 'a'|'b'
if a ~= 'a' then -- Unnecessary `if` statement: this condition is always truthy [unnecessary-if]
end
"#
));
}
}