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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#![allow(clippy::ignore_without_reason)] // Test file with known limitations
#![allow(missing_docs)]
// RUNTIME-001: Baseline Audit - Parser vs Runtime Status
// Purpose: Document what parses vs what executes for parser-only features
// Status: These tests DOCUMENT CURRENT STATE (parser succeeds, runtime fails)
//
// EXTREME TDD Protocol: RED phase - these tests currently FAIL (runtime not implemented)
// Once features are implemented (GREEN phase), these tests will PASS
//
// Features being audited:
// 1. Structs (value types)
// 2. Classes (reference types)
// 3. Actors (message-passing)
// 4. Async/Await (concurrency)
use assert_cmd::Command;
use predicates::prelude::*;
/// Helper to get ruchy binary command
fn ruchy_cmd() -> Command {
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
}
// ==================== STRUCTS: Parser vs Runtime ====================
#[test]
fn test_runtime_001_struct_parser_accepts_definition() {
// Parser SHOULD accept struct definition
// NOTE: Using -e flag for inline code evaluation
ruchy_cmd()
.arg("-e")
.arg("struct Point { x: i32, y: i32 }; 42")
.assert()
.success(); // ✅ Parser accepts it
}
#[test]
#[ignore = "RED phase: Currently FAILS because structs don't execute"]
fn test_runtime_001_struct_runtime_executes_instantiation() {
// Runtime SHOULD execute struct instantiation (this currently fails)
ruchy_cmd()
.arg("-e")
.arg("struct Point { x: i32, y: i32 }; let p = Point { x: 10, y: 20 }; println!(p.x)")
.assert()
.success() // ❌ Currently fails - runtime not implemented
.stdout(predicate::str::contains("10"));
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_struct_runtime_field_access() {
ruchy_cmd()
.arg("-e")
.arg("struct Point { x: i32, y: i32 }; let p = Point { x: 10, y: 20 }; println!(p.y)")
.assert()
.success()
.stdout(predicate::str::contains("20"));
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_struct_runtime_value_semantics() {
// Test that structs have value semantics (copy on assign)
ruchy_cmd()
.arg("-e")
.arg("struct Point { x: i32, y: i32 }; let p1 = Point { x: 0, y: 0 }; let p2 = p1; p2.x = 10; println!(p1.x)")
.assert()
.success()
.stdout(predicate::str::contains("0")); // p1 unchanged (value semantics)
}
// ==================== CLASSES: Parser vs Runtime ====================
#[test]
fn test_runtime_001_class_parser_accepts_definition() {
// Parser SHOULD accept class definition
ruchy_cmd()
.arg("-e")
.arg("class Person { name: String, age: i32 }; 42")
.assert()
.success(); // ✅ Parser accepts it
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_class_runtime_executes_instantiation() {
// Runtime SHOULD execute class instantiation (this currently fails)
ruchy_cmd()
.arg("-e")
.arg("class Person { name: String, age: i32 init(name: String, age: i32) { self.name = name; self.age = age; } }; let person = Person(name: \"Alice\", age: 30); println!(person.name)")
.assert()
.success()
.stdout(predicate::str::contains("Alice"));
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_class_runtime_reference_semantics() {
// Test that classes have reference semantics (shared on assign)
ruchy_cmd()
.arg("-e")
.arg("class Person { age: i32 init(age: i32) { self.age = age; } }; let person1 = Person(age: 30); let person2 = person1; person2.age = 31; println!(person1.age)")
.assert()
.success()
.stdout(predicate::str::contains("31")); // person1 sees change (reference semantics)
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_class_runtime_identity_comparison() {
// Test identity comparison (===)
ruchy_cmd()
.arg("-e")
.arg("class Person { age: i32 init(age: i32) { self.age = age; } }; let person1 = Person(age: 30); let person2 = person1; let result = person1 === person2; println!(result)")
.assert()
.success()
.stdout(predicate::str::contains("true")); // Same instance
}
// ==================== ACTORS: Parser vs Runtime ====================
#[test]
fn test_runtime_001_actor_parser_accepts_definition() {
// Parser SHOULD accept actor definition
ruchy_cmd()
.arg("-e")
.arg("actor Counter { count: i32 receive { Increment => self.count += 1, GetCount => self.count } }; 42")
.assert()
.success(); // ✅ Parser accepts it
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_actor_runtime_spawn_and_send() {
// Runtime SHOULD execute actor spawn and message sending (currently fails)
ruchy_cmd()
.arg("-e")
.arg("actor Counter { count: i32 receive { Increment => self.count += 1, GetCount => self.count } }; let counter = Counter.spawn(); counter.send(Increment); counter.send(Increment); let result = counter.ask(GetCount); println!(result)")
.assert()
.success()
.stdout(predicate::str::contains("2"));
}
// ==================== ASYNC/AWAIT: Parser vs Runtime ====================
#[test]
#[ignore = "NOT IMPLEMENTED: async keyword not recognized by parser"]
fn test_runtime_001_async_parser_accepts_async_fn() {
// Parser SHOULD accept async fn (currently DOES NOT)
// Error: "Expected 'fun', '{', '|', or identifier after 'async'"
ruchy_cmd()
.arg("-e")
.arg("async fn fetch_data() -> String { \"data\" }; 42")
.assert()
.success(); // ❌ Parser does NOT accept it (keyword not implemented)
}
#[test]
#[ignore = "NOT IMPLEMENTED: async keyword not recognized by parser"]
fn test_runtime_001_async_parser_accepts_await() {
// Parser SHOULD accept await expression (currently DOES NOT)
ruchy_cmd()
.arg("-e")
.arg("async fn fetch_data() -> String { \"data\" }; async fn main() { let result = await fetch_data(); }; 42")
.assert()
.success(); // ❌ Parser does NOT accept it
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_async_runtime_executes_async_fn() {
// Runtime SHOULD execute async fn (currently fails)
ruchy_cmd()
.arg("-e")
.arg("async fn fetch_data() -> String { \"data\" }; async fn main() { let result = await fetch_data(); println!(result); }")
.assert()
.success()
.stdout(predicate::str::contains("data"));
}
#[test]
#[ignore = "RED phase: Currently FAILS"]
fn test_runtime_001_async_runtime_concurrent_execution() {
// Test that async functions can run concurrently
ruchy_cmd()
.arg("-e")
.arg("async fn task1() -> i32 { 1 }; async fn task2() -> i32 { 2 }; async fn main() { let result1 = await task1(); let result2 = await task2(); println!(result1 + result2); }")
.assert()
.success()
.stdout(predicate::str::contains("3"));
}
// ==================== BASELINE SUMMARY ====================
#[test]
fn test_runtime_001_baseline_summary() {
// This test documents the current state for the baseline audit
//
// Parser Status (✅ = passes, ❌ = fails):
// ✅ Structs: Parser accepts struct definitions (test_runtime_001_struct_parser_accepts_definition PASSING)
// ✅ Classes: Parser accepts class definitions (test_runtime_001_class_parser_accepts_definition PASSING)
// ✅ Actors: Parser accepts actor definitions (test_runtime_001_actor_parser_accepts_definition PASSING)
// ❌ Async/Await: Parser REJECTS async fn and await (keyword not implemented in parser!)
//
// Runtime Status (all currently ❌):
// ❌ Structs: Runtime does NOT execute struct instantiation/field access (tests ignored)
// ❌ Classes: Runtime does NOT execute class instantiation/methods (tests ignored)
// ❌ Actors: Runtime does NOT execute actor spawn/message passing (tests ignored)
// ❌ Async/Await: NOT IMPLEMENTED at parser level (must implement parser first, then runtime)
//
// Priority for Implementation (REVISED based on baseline findings):
// 1. Structs (simplest - parser works, need runtime only)
// 2. Classes (parser works, need runtime only)
// 3. Actors (parser works, need runtime only)
// 4. Async/Await (BLOCKED - must implement parser keyword first, then runtime)
//
// CRITICAL FINDING: Async/Await is NOT parser-only - it's COMPLETELY UNIMPLEMENTED!
// The specification incorrectly stated "await parses but NOT runtime-functional"
// Reality: "async" keyword not recognized by parser at all
//
// Test Results Summary:
// - 4 tests PASSING (3 parser accept tests + this summary)
// - 9 tests IGNORED (runtime execution not implemented)
// - 2 tests show async/await not implemented at parser level
// This test always passes - it's documentation
assert!(
true,
"Baseline audit documented - 3 features parse correctly, 1 not implemented"
);
}