1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#![allow(missing_docs)]
//! RUNTIME-001: Fix `MacroInvocation` runtime support (GitHub Issue #74)
//!
//! ROOT CAUSE: FORMATTER-088 changed parser to emit `ExprKind::MacroInvocation` instead of
//! `ExprKind::Macro`, but forgot to update interpreter to handle the new variant.
//!
//! FIX: Add match arm for `ExprKind::MacroInvocation` in interpreter.
use predicates::prelude::*;
/// Test vec! macro with `MacroInvocation` variant (Issue #74 regression)
#[test]
fn test_runtime_001_vec_macro_invocation() {
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("ruchy");
cmd.arg("-e")
.arg("let x = vec![1, 2, 3]; x")
.timeout(std::time::Duration::from_secs(5))
.assert()
.success();
}
/// Test println! macro with `MacroInvocation` variant
#[test]
fn test_runtime_001_println_macro_invocation() {
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("ruchy");
cmd.arg("-e")
.arg("println!(\"Hello\")")
.timeout(std::time::Duration::from_secs(5))
.assert()
.success()
.stdout(predicate::str::contains("Hello"));
}
/// Test that both Macro and `MacroInvocation` work the same
#[test]
fn test_runtime_001_macro_backward_compat() {
// This test verifies that the fix works with CURRENT parser output (MacroInvocation)
let mut cmd = assert_cmd::cargo::cargo_bin_cmd!("ruchy");
cmd.arg("-e")
.arg("let x = vec![1, 2]; x")
.assert()
.success();
}