suicmez/tests/codegen/INDEX.md
2025-12-17 13:18:12 +05:30

136 lines
3.4 KiB
Markdown

# Codegen Tests Index
Quick reference guide for all codegen tests.
## 📋 Test Overview
| Test | Type | Features | Lines |
|------|------|----------|-------|
| `test_executable` | Basic | Integer math, functions | 4 |
| `test_array_simple` | Arrays | Literals, indexing, pointers | 4 |
| `test_enum_simple` | Enums | Variants, discriminant | 2 |
| `test_comprehensive` | Mixed | All basic types, structs | 18 |
| `test_all_types` | Coverage | Complete type test | 16 |
## 🚀 Quick Commands
### Generate C from all tests
```bash
for f in tests/codegen/*.sui; do
./target/debug/suicmez "$f"
done
```
### Compile all tests
```bash
for f in tests/codegen/*.c; do
gcc "$f" -o "/tmp/$(basename ${f%.c})"
done
```
### Run all tests
```bash
for exe in /tmp/test_*; do
echo "=== $(basename $exe) ==="
"$exe" 2>&1
done
```
### Run single test
```bash
./target/debug/suicmez tests/codegen/test_comprehensive.sui
gcc tests/codegen/test_comprehensive.c -o /tmp/test
/tmp/test
```
## 📖 Documentation Files
- **README.md** - Full documentation of all tests
- **TESTING.md** - How to run and debug tests
- **SUMMARY.md** - Organization and cleanup summary
- **INDEX.md** - This file
## 🎯 Test Selection Guide
**I want to test:**
- **Simple execution** → Use `test_executable`
- **Arrays** → Use `test_array_simple`
- **Enums** → Use `test_enum_simple`
- **Everything together** → Use `test_comprehensive`
- **All types** → Use `test_all_types`
## ✅ Verification Checklist
Before pushing:
- [ ] All `.sui` files transpile: `for f in tests/codegen/*.sui; do suicmez "$f" > /dev/null; done`
- [ ] All `.c` files compile: `for f in tests/codegen/*.c; do gcc "$f" -c; done`
- [ ] All tests execute: `for f in tests/codegen/*.c; do gcc "$f" -o /tmp/t && /tmp/t > /dev/null; done`
- [ ] Debug output works: `gcc tests/codegen/test_comprehensive.c -o /tmp/t && /tmp/t | head -3`
## 🔧 Debug Features
Each test includes debug output:
```
| <statement> |
<value>
```
Example:
```
| int x = 10 |
10
```
Format specifiers are automatic:
- `%d` - integers
- `%f` - floats
- `%s` - strings
- `%p` - pointers
## 📦 File Organization
```
tests/codegen/
├── test_executable.sui ← Source
├── test_executable.c ← Generated
├── test_array_simple.sui
├── test_array_simple.c
├── test_enum_simple.sui
├── test_enum_simple.c
├── test_comprehensive.sui
├── test_comprehensive.c
├── test_all_types.sui
├── test_all_types.c
├── README.md ← Documentation
├── TESTING.md
├── SUMMARY.md
└── INDEX.md ← This file
```
Each `.sui` file has a corresponding `.c` file containing the generated C code with debug output.
## 🎓 Learning Path
1. Start with `test_executable` - understand basic code generation
2. Move to `test_array_simple` - learn array handling
3. Check `test_enum_simple` - understand enum codegen
4. Study `test_comprehensive` - see everything together
5. Review `test_all_types` - verify complete coverage
## 💡 Tips
- Look at generated `.c` files to understand transpilation
- Run tests with output redirection: `./test 2>&1 | less`
- Compare `.sui` and `.c` files side by side
- Check debug output for execution trace
- Modify `.sui` files to experiment with codegen
## 📞 Getting Help
See **TESTING.md** for:
- Common issues and solutions
- Compilation troubleshooting
- Debug output interpretation
- Verification procedures