Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions core/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,3 @@ fn collect_diagnostics(genv: &GlobalEnv, file_path: &Path) -> Vec<Diagnostic> {

diagnostics
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_file_checker_creation() {
// This test will fail if RBS cache doesn't exist
// That's expected - cache should be generated from Ruby side first
let result = FileChecker::new();
assert!(result.is_ok() || result.is_err()); // Just check it doesn't panic
}
}
41 changes: 0 additions & 41 deletions core/src/diagnostics/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,44 +79,3 @@ impl Diagnostic {
Self::warning(location, message)
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_diagnostic_creation() {
let loc = Location {
file: PathBuf::from("test.rb"),
line: 10,
column: 5,
length: None,
};

let diag = Diagnostic::undefined_method(loc.clone(), "Integer", "upcase");
assert_eq!(diag.level, DiagnosticLevel::Error);
assert_eq!(diag.message, "undefined method `upcase` for Integer");
}

#[test]
fn test_union_partial_error() {
let loc = Location {
file: PathBuf::from("test.rb"),
line: 15,
column: 3,
length: None,
};

let diag = Diagnostic::union_partial_error(
loc,
vec!["String".to_string()],
vec!["Integer".to_string()],
"upcase",
);

assert_eq!(diag.level, DiagnosticLevel::Warning);
assert!(diag
.message
.contains("method `upcase` is defined for String but not for Integer"));
}
}
38 changes: 0 additions & 38 deletions core/src/diagnostics/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,41 +78,3 @@ pub fn format_diagnostics_with_file(diagnostics: &[Diagnostic], file_path: &Path
Err(_) => format_diagnostics(diagnostics), // Fallback to simple format
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::diagnostics::diagnostic::{Diagnostic, Location};
use std::path::PathBuf;

#[test]
fn test_format_diagnostics() {
let diagnostics = vec![
Diagnostic::undefined_method(
Location {
file: PathBuf::from("test.rb"),
line: 10,
column: 5,
length: None,
},
"Integer",
"upcase",
),
Diagnostic::union_partial_error(
Location {
file: PathBuf::from("test.rb"),
line: 15,
column: 3,
length: None,
},
vec!["String".to_string()],
vec!["Integer".to_string()],
"upcase",
),
];

let output = format_diagnostics(&diagnostics);
assert!(output.contains("test.rb:10:5: error:"));
assert!(output.contains("test.rb:15:3: warning:"));
}
}
77 changes: 0 additions & 77 deletions core/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,80 +77,3 @@ impl Default for ParseSession {
Self::new()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_parse_simple_ruby() {
let source = r#"x = 1
puts x"#;
let session = ParseSession::new();
let result = session.parse_source(source, "test.rb");
assert!(result.is_ok());
}

#[test]
fn test_parse_string_literal() {
let source = r#""hello".upcase"#;
let session = ParseSession::new();
let result = session.parse_source(source, "test.rb");
assert!(result.is_ok());
}

#[test]
fn test_parse_array_literal() {
let source = r#"[1, 2, 3].map { |x| x * 2 }"#;
let session = ParseSession::new();
let result = session.parse_source(source, "test.rb");
assert!(result.is_ok());
}

#[test]
fn test_parse_method_definition() {
let source = r#"def test_method
x = "hello"
x.upcase
end"#;
let session = ParseSession::new();
let result = session.parse_source(source, "test.rb");
assert!(result.is_ok());
}

#[test]
fn test_parse_invalid_ruby() {
let source = "def\nend end";
let session = ParseSession::new();
let result = session.parse_source(source, "test.rb");
assert!(result.is_err());
}

#[test]
fn test_parse_method_call() {
let source = r#"user = User.new
user.save"#;
let session = ParseSession::new();
let result = session.parse_source(source, "test.rb");
assert!(result.is_ok());
}

#[test]
fn test_parse_session_memory_tracking() {
let session = ParseSession::new();
let source = "x = 1";
let _ = session.parse_source(source, "test.rb").unwrap();
assert!(session.allocated_bytes() > 0);
}

#[test]
fn test_parse_session_reset() {
let mut session = ParseSession::new();
let source = "x = 1";
let _ = session.parse_source(source, "test.rb").unwrap();
let before_reset = session.allocated_bytes();
session.reset();
// After reset, allocated_bytes may still report used chunks but internal data is cleared
assert!(before_reset > 0);
}
}