From ccdcc7c7913e53310ec2516f314f4c42638f5657 Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 18 Jun 2024 22:03:41 -0400 Subject: [PATCH] Fix tests and comment some out --- dust-lang/tests/structs.rs | 227 ++++++++++++++++++----------------- dust-lang/tests/variables.rs | 6 +- 2 files changed, 117 insertions(+), 116 deletions(-) diff --git a/dust-lang/tests/structs.rs b/dust-lang/tests/structs.rs index 99b2bea..a5fc082 100644 --- a/dust-lang/tests/structs.rs +++ b/dust-lang/tests/structs.rs @@ -1,120 +1,121 @@ -use dust_lang::{ - abstract_tree::{Type, WithPos}, - error::{DustError, TypeConflict, ValidationError}, - identifier::Identifier, - interpret, Value, -}; +// Reuse these tests when structures are reimplemented +// use dust_lang::{ +// abstract_tree::{Type, WithPos}, +// error::{DustError, TypeConflict, ValidationError}, +// identifier::Identifier, +// interpret, Value, +// }; -#[test] -fn simple_structure() { - assert_eq!( - interpret( - "test", - " - struct Foo { - bar : int, - baz : str, - } +// #[test] +// fn simple_structure() { +// assert_eq!( +// interpret( +// "test", +// " +// struct Foo { +// bar : int, +// baz : str, +// } - Foo { - bar = 42, - baz = 'hiya', - } - " - ), - Ok(Some(Value::structure( - Identifier::new("Foo").with_position((127, 130)), - vec![ - (Identifier::new("bar"), Value::integer(42)), - (Identifier::new("baz"), Value::string("hiya".to_string())), - ] - ))) - ) -} +// Foo { +// bar = 42, +// baz = 'hiya', +// } +// " +// ), +// Ok(Some(Value::structure( +// Identifier::new("Foo").with_position((127, 130)), +// vec![ +// (Identifier::new("bar"), Value::integer(42)), +// (Identifier::new("baz"), Value::string("hiya".to_string())), +// ] +// ))) +// ) +// } -#[test] -fn field_type_error() { - assert_eq!( - interpret( - "test", - " - struct Foo { - bar : int, - } +// #[test] +// fn field_type_error() { +// assert_eq!( +// interpret( +// "test", +// " +// struct Foo { +// bar : int, +// } - Foo { - bar = 'hiya', - } - " - ) - .unwrap_err() - .errors(), - &vec![DustError::Validation { - error: ValidationError::TypeCheck { - conflict: TypeConflict { - actual: Type::String, - expected: Type::Integer - }, - actual_position: (128, 134).into(), - expected_position: Some((56, 59).into()), - }, - position: (96, 153).into() - }] - ) -} +// Foo { +// bar = 'hiya', +// } +// " +// ) +// .unwrap_err() +// .errors(), +// &vec![DustError::Validation { +// error: ValidationError::TypeCheck { +// conflict: TypeConflict { +// actual: Type::String, +// expected: Type::Integer +// }, +// actual_position: (128, 134).into(), +// expected_position: Some((56, 59).into()), +// }, +// position: (96, 153).into() +// }] +// ) +// } -#[test] -fn nested_structure() { - assert_eq!( - interpret( - "test", - " - struct Bar { - baz : int - } - struct Foo { - bar : Bar - } +// #[test] +// fn nested_structure() { +// assert_eq!( +// interpret( +// "test", +// " +// struct Bar { +// baz : int +// } +// struct Foo { +// bar : Bar +// } - Foo { - bar = Bar { - baz = 42 - } - } - " - ), - Ok(Some(Value::structure( - Identifier::new("Foo").with_position((172, 175)), - vec![( - Identifier::new("bar"), - Value::structure( - Identifier::new("Bar").with_position((204, 207)), - vec![(Identifier::new("baz"), Value::integer(42))] - ) - ),] - ))) - ) -} +// Foo { +// bar = Bar { +// baz = 42 +// } +// } +// " +// ), +// Ok(Some(Value::structure( +// Identifier::new("Foo").with_position((172, 175)), +// vec![( +// Identifier::new("bar"), +// Value::structure( +// Identifier::new("Bar").with_position((204, 207)), +// vec![(Identifier::new("baz"), Value::integer(42))] +// ) +// ),] +// ))) +// ) +// } -#[test] -fn undefined_struct() { - assert_eq!( - interpret( - "test", - " - Foo { - bar = 42 - } - " - ) - .unwrap_err() - .errors(), - &vec![DustError::Validation { - error: ValidationError::VariableNotFound { - identifier: Identifier::new("Foo"), - position: (17, 20).into() - }, - position: (17, 69).into() - }] - ) -} +// #[test] +// fn undefined_struct() { +// assert_eq!( +// interpret( +// "test", +// " +// Foo { +// bar = 42 +// } +// " +// ) +// .unwrap_err() +// .errors(), +// &vec![DustError::Validation { +// error: ValidationError::VariableNotFound { +// identifier: Identifier::new("Foo"), +// position: (17, 20).into() +// }, +// position: (17, 69).into() +// }] +// ) +// } diff --git a/dust-lang/tests/variables.rs b/dust-lang/tests/variables.rs index 4cb9f6b..9a6fa3c 100644 --- a/dust-lang/tests/variables.rs +++ b/dust-lang/tests/variables.rs @@ -44,13 +44,13 @@ fn set_variable_with_type_error() { #[test] fn function_variable() { assert_eq!( - interpret("test", "foobar = fn (x: int) int { x }; foobar"), + interpret("test", "foobar = fn (x: int) -> int { x }; foobar"), Ok(Some(Value::function( - Some(Vec::with_capacity(0)), + None, vec![(Identifier::new("x"), Type::Integer)], Type::Integer, Block::new(vec![Statement::Expression(Expression::Identifier( - Identifier::new("x").with_position((27, 28)) + Identifier::new("x").with_position((30, 31)) ))]) ))) );