2024-12-03 22:20:29 +00:00
|
|
|
use dust_lang::*;
|
2024-12-25 15:04:35 +00:00
|
|
|
use smallvec::smallvec;
|
2024-12-03 22:20:29 +00:00
|
|
|
|
|
|
|
#[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
|
|
|
},
|
2024-12-25 15:04:35 +00:00
|
|
|
smallvec![
|
|
|
|
Instruction::load_boolean(0, true, false),
|
|
|
|
Instruction::test(0, false),
|
|
|
|
Instruction::jump(1, true),
|
|
|
|
Instruction::load_boolean(1, false, false),
|
|
|
|
Instruction::r#return(true),
|
2024-12-03 22:20:29 +00:00
|
|
|
],
|
2024-12-25 15:04:35 +00:00
|
|
|
smallvec![
|
|
|
|
Span(0, 4),
|
|
|
|
Span(5, 7),
|
|
|
|
Span(5, 7),
|
|
|
|
Span(8, 13),
|
|
|
|
Span(13, 13),
|
|
|
|
],
|
|
|
|
smallvec![],
|
|
|
|
smallvec![],
|
2024-12-03 22:20:29 +00:00
|
|
|
vec![]
|
|
|
|
))
|
|
|
|
);
|
|
|
|
|
2024-12-25 15:04:35 +00:00
|
|
|
assert_eq!(run(source), Ok(Some(Value::boolean(true))));
|
2024-12-03 22:20:29 +00:00
|
|
|
}
|