2024-12-03 22:20:29 +00:00
|
|
|
use dust_lang::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn true_or_false() {
|
|
|
|
let source = "true || false";
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
compile(source),
|
|
|
|
Ok(Chunk::with_data(
|
|
|
|
None,
|
|
|
|
FunctionType {
|
|
|
|
type_parameters: None,
|
|
|
|
value_parameters: None,
|
2024-12-10 08:34:41 +00:00
|
|
|
return_type: Type::Boolean,
|
2024-12-03 22:20:29 +00:00
|
|
|
},
|
|
|
|
vec![
|
2024-12-10 08:34:41 +00:00
|
|
|
(Instruction::load_boolean(0, true, false), Span(0, 4)),
|
2024-12-03 22:20:29 +00:00
|
|
|
(Instruction::test(Argument::Register(0), false), Span(5, 7)),
|
|
|
|
(Instruction::jump(1, true), Span(5, 7)),
|
2024-12-10 08:34:41 +00:00
|
|
|
(Instruction::load_boolean(1, false, false), Span(8, 13)),
|
2024-12-03 22:20:29 +00:00
|
|
|
(Instruction::r#return(true), Span(13, 13)),
|
|
|
|
],
|
|
|
|
vec![],
|
|
|
|
vec![]
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(run(source), Ok(Some(ConcreteValue::Boolean(true))));
|
|
|
|
}
|