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:
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user