use vexity::parser::parse;
#[test]
fn test_var_defs() {
let script = r#"
let a = true
let b = false
let x = 2
let y = 8.5
let z = "Hello 🌎"
let xyz = [x, y, z]
let coordinates = { x_axis: x, y_axis: y }
"#;
parse(script).expect("Parsing script failed");
}
#[test]
fn test_comments() {
let script = r#"
# Define a variable `x`
let x = 10
# Define a variable `y` which is `x * x`
let xx = x * x
"#;
parse(script).expect("Parsing script failed");
}
#[test]
fn test_function_defs() {
let script = r#"
fn squared(x) {
x * x
}
"#;
parse(script).expect("Parsing script failed");
}
#[test]
fn test_lambda_defs() {
let script = r#"
let add_one = |x| x + 1
let coordinates = [
{x: 20, y: 50},
{x: 23, y: 34},
{x: 10, y: 20},
{x: 14, y: 10}
]
coordinates.map(|coord| coord.x - 1)
"#;
parse(script).expect("Parsing script failed");
}
#[test]
fn test_range_def() {
let script = r#"
(0..5).for_each(|i| {
print(i)
})
"#;
parse(script).expect("Parsing script with range failed");
}