49ad76e7c3
This commit refactors the test suite by removing the monolithic `integration_test.rs` file. The tests have been categorized and moved into dedicated modules within the `tests/` directory: - `tests/parser.rs`: Contains tests for parsing various literal values. - `tests/destructuring.rs`: Houses tests related to destructuring syntax. - `tests/closures.rs`: Includes tests for closure behavior and related optimizations. - `tests/optimizer.rs`: Contains tests specifically targeting optimizer logic and regressions. - `tests/records.rs`: Holds tests for record syntax and associated optimizations. - `tests/rtl.rs`: Contains tests for runtime library operators and functions. - `tests/pipeline.rs`: Tests for pipeline functionality. - `tests/macros.rs`: Tests for macro expansion and related issues. - `tests/error_recovery.rs`: Includes tests for compiler error handling and recovery mechanisms. - `tests/examples.rs`: Verifies the execution of example scripts. This reorganization improves test discoverability and maintainability. The `lib.rs` file has also been updated to reflect these changes by removing the reference to the old `integration_test` module. The `type_checker.rs` file has had some tests removed, as they are now covered by the more specific tests in `tests/error_recovery.rs`.
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
use myc::ast::nodes::SyntaxKind;
|
|
use myc::ast::parser::Parser;
|
|
use myc::ast::types::Value;
|
|
|
|
#[test]
|
|
fn test_parse_integer_constant() {
|
|
let source = "123";
|
|
let mut parser = Parser::new(source);
|
|
let ast = parser.parse_expression();
|
|
|
|
if let SyntaxKind::Constant(Value::Int(val)) = ast.kind {
|
|
assert_eq!(val, 123);
|
|
} else {
|
|
panic!("Expected Integer constant, got {:?}", ast.kind);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_parse_negative_integer() {
|
|
let source = "-42";
|
|
let mut parser = Parser::new(source);
|
|
let ast = parser.parse_expression();
|
|
|
|
if let SyntaxKind::Constant(Value::Int(val)) = ast.kind {
|
|
assert_eq!(val, -42);
|
|
} else {
|
|
panic!("Expected Integer constant, got {:?}", ast.kind);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_parse_float_constant() {
|
|
let source = "123.45";
|
|
let mut parser = Parser::new(source);
|
|
let ast = parser.parse_expression();
|
|
|
|
if let SyntaxKind::Constant(Value::Float(val)) = ast.kind {
|
|
assert_eq!(val, 123.45);
|
|
} else {
|
|
panic!("Expected Float constant, got {:?}", ast.kind);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_parse_negative_float() {
|
|
let source = "-10.5";
|
|
let mut parser = Parser::new(source);
|
|
let ast = parser.parse_expression();
|
|
|
|
if let SyntaxKind::Constant(Value::Float(val)) = ast.kind {
|
|
assert_eq!(val, -10.5);
|
|
} else {
|
|
panic!("Expected Float constant, got {:?}", ast.kind);
|
|
}
|
|
}
|