feat: add stress test projects and testing documentation

- Add String.fromChar function to convert Char to String
- Create four stress test projects demonstrating Lux features:
  - json-parser: recursive descent parsing with Char handling
  - markdown-converter: string manipulation and ADTs
  - todo-app: list operations and pattern matching
  - mini-interpreter: AST evaluation and environments
- Add comprehensive testing documentation (docs/testing.md)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 18:53:27 -05:00
parent a6eb349d59
commit 730112a917
7 changed files with 900 additions and 0 deletions

View File

@@ -83,6 +83,7 @@ pub enum BuiltinFn {
StringToUpper,
StringToLower,
StringSubstring,
StringFromChar,
// JSON operations
JsonParse,
@@ -809,6 +810,10 @@ impl Interpreter {
"substring".to_string(),
Value::Builtin(BuiltinFn::StringSubstring),
),
(
"fromChar".to_string(),
Value::Builtin(BuiltinFn::StringFromChar),
),
]));
env.define("String", string_module);
@@ -2293,6 +2298,17 @@ impl Interpreter {
Ok(EvalResult::Value(Value::String(result)))
}
BuiltinFn::StringFromChar => {
if args.len() != 1 {
return Err(err("String.fromChar requires 1 argument: char"));
}
let c = match &args[0] {
Value::Char(c) => *c,
v => return Err(err(&format!("String.fromChar expects Char, got {}", v.type_name()))),
};
Ok(EvalResult::Value(Value::String(c.to_string())))
}
// JSON operations
BuiltinFn::JsonParse => {
let s = Self::expect_arg_1::<String>(&args, "Json.parse", span)?;

View File

@@ -1307,6 +1307,10 @@ impl TypeEnv {
"substring".to_string(),
Type::function(vec![Type::String, Type::Int, Type::Int], Type::String),
),
(
"fromChar".to_string(),
Type::function(vec![Type::Char], Type::String),
),
]);
env.bind("String", TypeScheme::mono(string_module_type));