fix: resolve all stress test bugs
- Record equality: add Record case to values_equal in interpreter - Invalid escapes: error on unknown escape sequences in lexer - Unknown effects: validate effect names in check_function with suggestions - Circular types: add DFS cycle detection in check_type_cycles - Parser: require | for enum variants, enabling proper type alias syntax All 265 tests pass. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
41
src/main.rs
41
src/main.rs
@@ -1813,6 +1813,46 @@ c")"#;
|
||||
assert_eq!(eval(r#"let x = typeOf("hello")"#).unwrap(), r#""String""#);
|
||||
}
|
||||
|
||||
// Bug fix tests
|
||||
#[test]
|
||||
fn test_record_equality() {
|
||||
assert_eq!(eval("let x = { a: 1, b: 2 } == { a: 1, b: 2 }").unwrap(), "true");
|
||||
assert_eq!(eval("let x = { a: 1 } == { a: 2 }").unwrap(), "false");
|
||||
assert_eq!(eval("let x = { a: 1, b: 2 } == { a: 1, b: 3 }").unwrap(), "false");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_escape_sequence() {
|
||||
let result = eval(r#"let x = "\z""#);
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("Invalid escape sequence"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unknown_effect_error() {
|
||||
let result = eval("fn test(): Unit with {FakeEffect} = ()");
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("Unknown effect"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_circular_type_definitions() {
|
||||
let result = eval("type A = B\ntype B = A");
|
||||
assert!(result.is_err(), "Should detect circular type definitions");
|
||||
let err = result.unwrap_err();
|
||||
assert!(err.contains("Circular"), "Error should mention 'Circular': {}", err);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mutual_recursion() {
|
||||
let source = r#"
|
||||
fn isEven(n: Int): Bool = if n == 0 then true else isOdd(n - 1)
|
||||
fn isOdd(n: Int): Bool = if n == 0 then false else isEven(n - 1)
|
||||
let result = isEven(10)
|
||||
"#;
|
||||
assert_eq!(eval(source).unwrap(), "true");
|
||||
}
|
||||
|
||||
// Pipe with stdlib tests
|
||||
#[test]
|
||||
fn test_pipe_with_list() {
|
||||
@@ -2948,7 +2988,6 @@ c")"#;
|
||||
mod example_tests {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
fn check_file(path: &str) -> Result<(), String> {
|
||||
let source = fs::read_to_string(path)
|
||||
|
||||
Reference in New Issue
Block a user