Refactor: Replace optimization level with boolean flag
The optimizer now uses a simple boolean flag (`optimization`) instead of an `optimization_level` (u32). This simplifies the optimizer's logic and makes it easier to enable or disable optimizations. The command-line interface and internal testing have been updated to reflect this change.
This commit is contained in:
+6
-6
@@ -18,17 +18,17 @@ pub struct BenchmarkResult {
|
||||
}
|
||||
|
||||
pub fn run_functional_tests() -> Vec<TestResult> {
|
||||
run_functional_tests_with_level(0)
|
||||
run_functional_tests_with_optimization(false)
|
||||
}
|
||||
|
||||
pub fn run_functional_tests_with_level(level: u32) -> Vec<TestResult> {
|
||||
pub fn run_functional_tests_with_optimization(enabled: bool) -> Vec<TestResult> {
|
||||
let mut results = Vec::new();
|
||||
let entries = fs::read_dir("examples").unwrap();
|
||||
let output_re = Regex::new(r";; Output: (.*)").unwrap();
|
||||
|
||||
for entry in entries.filter_map(|e| e.ok()) {
|
||||
let mut env = Environment::new(); // Fresh environment per test file
|
||||
env.optimization_level = level;
|
||||
env.optimization = enabled;
|
||||
let path = entry.path();
|
||||
if path.extension().is_some_and(|ext| ext == "myc") {
|
||||
let content = fs::read_to_string(&path).unwrap();
|
||||
@@ -53,8 +53,8 @@ pub fn run_functional_tests_with_level(level: u32) -> Vec<TestResult> {
|
||||
name,
|
||||
success: false,
|
||||
message: format!(
|
||||
"Level {}: Expected {}, got {}",
|
||||
level, expected, val_str
|
||||
"Opt {}: Expected {}, got {}",
|
||||
if enabled { "ON" } else { "OFF" }, expected, val_str
|
||||
),
|
||||
});
|
||||
}
|
||||
@@ -62,7 +62,7 @@ pub fn run_functional_tests_with_level(level: u32) -> Vec<TestResult> {
|
||||
Err(e) => results.push(TestResult {
|
||||
name,
|
||||
success: false,
|
||||
message: format!("Level {}: Error: {}", level, e),
|
||||
message: format!("Opt {}: Error: {}", if enabled { "ON" } else { "OFF" }, e),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user