2024-01-06 07:26:51 +00:00
|
|
|
use std::collections::BTreeMap;
|
|
|
|
|
|
|
|
use dust_lang::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn simple_structure() {
|
|
|
|
let result = interpret("struct { x <int> = 0 }");
|
|
|
|
|
|
|
|
let mut btree_map = BTreeMap::new();
|
|
|
|
|
|
|
|
btree_map.insert("x".to_string(), (Some(Value::Integer(0)), Type::Integer));
|
|
|
|
|
2024-01-30 18:43:18 +00:00
|
|
|
let expected = Ok(Value::Structure(Structure::new(btree_map)));
|
2024-01-23 20:20:19 +00:00
|
|
|
|
|
|
|
assert_eq!(expected, result);
|
2024-01-06 07:26:51 +00:00
|
|
|
}
|
2024-01-23 20:35:26 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn new_structure() {
|
2024-02-11 01:50:49 +00:00
|
|
|
let _result = interpret(
|
2024-01-23 20:35:26 +00:00
|
|
|
"
|
|
|
|
Coords = struct {
|
|
|
|
x <float> = 0.0
|
|
|
|
x <float> = 0.0
|
|
|
|
}
|
|
|
|
|
|
|
|
new Coords {
|
|
|
|
x = 1.5
|
|
|
|
y = 4.2
|
|
|
|
}
|
|
|
|
",
|
|
|
|
);
|
|
|
|
|
|
|
|
let mut map = BTreeMap::new();
|
|
|
|
|
|
|
|
map.insert("x".to_string(), (Some(Value::Integer(0)), Type::Integer));
|
|
|
|
|
2024-02-11 01:50:49 +00:00
|
|
|
// let expected = Value::Map(Map::from_structure(Structure::new(map)));
|
2024-01-23 20:35:26 +00:00
|
|
|
|
2024-02-11 01:50:49 +00:00
|
|
|
// assert_eq!(Ok(expected), result);
|
|
|
|
|
|
|
|
todo!()
|
2024-01-23 20:35:26 +00:00
|
|
|
}
|